sandwitches 2.1.1__py3-none-any.whl → 2.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
sandwitches/forms.py CHANGED
@@ -149,8 +149,8 @@ class RecipeForm(forms.ModelForm):
149
149
  # PIL rotates counter-clockwise by default, our 'rotation' is clockwise
150
150
  img = img.rotate(-rotation, expand=True)
151
151
  img.save(recipe.image.path)
152
- except Exception:
153
- pass
152
+ except Exception as e:
153
+ print(f"Error rotating image: {e}")
154
154
 
155
155
  if commit:
156
156
  recipe.set_tags_from_string(self.cleaned_data.get("tags_string", ""))
@@ -81,7 +81,7 @@
81
81
 
82
82
  <div class="relative mb-1" style="overflow: hidden; min-height: 200px; display: flex; align-items: center; justify-content: center;">
83
83
  {% if recipe.image %}
84
- <img src="{{ recipe.image_medium.url }}" class="responsive round" id="image-preview" style="max-height: 300px; width: 100%; object-fit: contain; transition: transform 0.3s ease;">
84
+ <img src="{{ recipe.image_medium.url }}?v={% now "U" %}" class="responsive round" id="image-preview" style="max-height: 300px; width: 100%; object-fit: contain; transition: transform 0.3s ease;">
85
85
  {% else %}
86
86
  <div class="medium-height middle-align center-align gray1 round" id="image-placeholder" style="width: 100%;">
87
87
  <i class="extra">image</i>
@@ -21,7 +21,7 @@
21
21
  <img src="https://www.w3schools.com/howto/img_avatar.png" class="circle" data-ui="#user-menu">
22
22
  {% endif %}
23
23
  {% else %}
24
- <a href="{% url 'admin:login' %}"><button class="chip transparent border white-text">{% trans "Login" %}</button></a>
24
+ <a href="{% url 'login' %}"><button class="chip transparent border white-text">{% trans "Login" %}</button></a>
25
25
  <a href="{% url 'signup' %}"><button class="chip primary">{% trans "Sign up" %}</button></a>
26
26
  {% endif %}
27
27
  </nav>
@@ -44,7 +44,7 @@
44
44
  </form>
45
45
  </article>
46
46
  {% else %}
47
- <p><a href="{% url 'admin:login' %}" class="link">{% trans "Log in" %}</a> {% trans "to rate this recipe." %}</p>
47
+ <p><a href="{% url 'login' %}" class="link">{% trans "Log in" %}</a> {% trans "to rate this recipe." %}</p>
48
48
  {% endif %}
49
49
 
50
50
  {% if all_ratings %}
@@ -0,0 +1,57 @@
1
+ {% extends "base_beer.html" %}
2
+ {% load static i18n %}
3
+ {% block title %}{% trans "Login" %}{% endblock %}
4
+
5
+ {% block content %}
6
+ <div class="large-space"></div>
7
+
8
+ <div class="grid">
9
+ <div class="s12 m10 l8 xl6 middle-align center-align" style="margin: 0 auto;">
10
+ <article class="round elevate">
11
+ <div class="padding">
12
+ <h4 class="center-align primary-text">{% trans "Login to your account" %}</h4>
13
+ <p class="center-align">{% trans "Welcome back!" %}</p>
14
+ </div>
15
+
16
+ <form method="post" novalidate>
17
+ {% csrf_token %}
18
+
19
+ {% if form.non_field_errors %}
20
+ <div class="padding error surface round mb">
21
+ {% for error in form.non_field_errors %}
22
+ <div class="row align-center">
23
+ <i class="error-text">warning</i>
24
+ <span class="error-text">{{ error }}</span>
25
+ </div>
26
+ {% endfor %}
27
+ </div>
28
+ {% endif %}
29
+
30
+ <div class="field label border round {% if form.username.errors %}error{% endif %}">
31
+ <input type="text" name="{{ form.username.name }}" id="{{ form.username.id_for_label }}" value="{{ form.username.value|default:'' }}">
32
+ <label>{% trans "Username" %}</label>
33
+ {% if form.username.errors %}
34
+ <span class="helper error-text">{{ form.username.errors.0 }}</span>
35
+ {% endif %}
36
+ </div>
37
+
38
+ <div class="field label border round {% if form.password.errors %}error{% endif %}">
39
+ <input type="password" name="{{ form.password.name }}" id="{{ form.password.id_for_label }}">
40
+ <label>{% trans "Password" %}</label>
41
+ {% if form.password.errors %}
42
+ <span class="helper error-text">{{ form.password.errors.0 }}</span>
43
+ {% endif %}
44
+ </div>
45
+
46
+ <div class="large-space"></div>
47
+
48
+ <nav class="right-align">
49
+ <a class="button transparent border round" href="{% url 'index' %}">{% trans "Cancel" %}</a>
50
+ <button type="submit" class="button primary round">{% trans "Login" %}</button>
51
+ </nav>
52
+
53
+ </form>
54
+ </article>
55
+ </div>
56
+ </div>
57
+ {% endblock %}
sandwitches/urls.py CHANGED
@@ -21,6 +21,7 @@ from . import views
21
21
  from .api import api
22
22
  from django.conf.urls.i18n import i18n_patterns
23
23
  from .feeds import LatestRecipesFeed # Import the feed class
24
+ from django.contrib.auth.views import LogoutView # Import LogoutView
24
25
 
25
26
 
26
27
  import os
@@ -30,6 +31,8 @@ import sys
30
31
  urlpatterns = [
31
32
  path("i18n/", include("django.conf.urls.i18n")),
32
33
  path("signup/", views.signup, name="signup"),
34
+ path("login/", views.CustomLoginView.as_view(), name="login"),
35
+ path("logout/", LogoutView.as_view(next_page="index"), name="logout"),
33
36
  path("admin/", admin.site.urls),
34
37
  path("api/", api.urls),
35
38
  path("media/<path:file_path>", views.media, name="media"),
sandwitches/views.py CHANGED
@@ -23,12 +23,19 @@ import mimetypes
23
23
  from PIL import Image
24
24
  from django.db.models import Q, Avg
25
25
  from django_tasks.backends.database.models import DBTaskResult
26
+ from django.contrib.auth.views import LoginView
27
+
26
28
 
27
29
  from sandwitches import __version__ as sandwitches_version
28
30
 
29
31
  User = get_user_model()
30
32
 
31
33
 
34
+ class CustomLoginView(LoginView):
35
+ template_name = "login.html"
36
+ redirect_authenticated_user = True
37
+
38
+
32
39
  @staff_member_required
33
40
  def admin_dashboard(request):
34
41
  recipe_count = Recipe.objects.count() # ty:ignore[unresolved-attribute]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sandwitches
3
- Version: 2.1.1
3
+ Version: 2.1.2
4
4
  Summary: Add your description here
5
5
  Author: Martyn van Dijke
6
6
  Author-email: Martyn van Dijke <martijnvdijke600@gmail.com>
@@ -3,7 +3,7 @@ sandwitches/admin.py,sha256=3n73AD-j7vyajgoFdhPe3IXH6SFGIAq378gKDRr6ims,1852
3
3
  sandwitches/api.py,sha256=4Upjd78dHVZDOIFkZjPst0mLfVdiToB3RVVrBpttTYg,5714
4
4
  sandwitches/asgi.py,sha256=cygnXdXSSVspM7ZXuj47Ef6oz7HSTw4D7BPzgE2PU5w,399
5
5
  sandwitches/feeds.py,sha256=iz1d11dV0utA0ZNsB7VIAp0h8Zr5mFNSKJWHbw_j6YM,683
6
- sandwitches/forms.py,sha256=ODrwV52TSBxIatmVp_5A_l7WcDh9m1D3vLgL22HwLHo,5880
6
+ sandwitches/forms.py,sha256=QMSCpiy42AjretzEkj8FghfmBj-gkalSOXZVwiTtkOQ,5916
7
7
  sandwitches/locale/nl/LC_MESSAGES/django.mo,sha256=EzQWzIhz_Na3w9AS7F-YjB-Xv63t4sMRSAkEQ1-g32M,5965
8
8
  sandwitches/locale/nl/LC_MESSAGES/django.po,sha256=znxspEoMwkmktusZtbVrt1KG1LDUwIEi4ZEIE3XGeoI,25904
9
9
  sandwitches/migrations/0001_initial.py,sha256=hXnCAhoA91C6YCinXyUdIfQ7QL29NPBHFfTqLgulMsY,12507
@@ -20,7 +20,7 @@ sandwitches/templates/admin/admin_base.html,sha256=yPFo1K1LrRuPKfOuOGLEgQm29vWqz
20
20
  sandwitches/templates/admin/confirm_delete.html,sha256=HfsZI_gV8JQTKz215TYgPWBrgrFhGv1UB3N-0Hln-14,804
21
21
  sandwitches/templates/admin/dashboard.html,sha256=uHisWI3x-KehPDlwBFF5bIT5-tPsCVU5duA_ZPF-GHc,6168
22
22
  sandwitches/templates/admin/rating_list.html,sha256=ZTxu4emeYInlYyw7b19c8cYlj90fo1wtA-1BEJKZGt0,1256
23
- sandwitches/templates/admin/recipe_form.html,sha256=FeQgxDyj8z9vBltoneXNEcxa4YkbeatCkHB_GeHL8MU,7544
23
+ sandwitches/templates/admin/recipe_form.html,sha256=ssLnS63UobRFwPbDHMrnwniJEta3QHkWOJb8IPzYd_k,7560
24
24
  sandwitches/templates/admin/recipe_list.html,sha256=HDOmhK-XEPwTv1CCBqTXK79pLoH5y2xKPFjjue0HFeQ,2454
25
25
  sandwitches/templates/admin/tag_form.html,sha256=JRWgAl4fz_Oy-Kuo1K6Mex_CXdsHMABzzyPazthr1Kg,989
26
26
  sandwitches/templates/admin/tag_list.html,sha256=ttxwXgfdxkEs4Cmrz5RHaGmaqLd7JDmWhjv80XIQqyw,1246
@@ -36,8 +36,8 @@ sandwitches/templates/components/ingredients_scripts.html,sha256=2zKTC65GYF589uW
36
36
  sandwitches/templates/components/ingredients_section.html,sha256=XsaVXTs9MIwjfJeLjlzah3GWWj8oFU-_HJd9i9l1HAo,665
37
37
  sandwitches/templates/components/instructions_section.html,sha256=RFlA4uPiI6vf1e2QgiD5KzGoy7Vg7y7nFY7TFabCYLA,277
38
38
  sandwitches/templates/components/language_dialog.html,sha256=iz-6QhFe4f_dsVhGDhVx6KKKLgQz4grX8tbIqSQjDsg,1184
39
- sandwitches/templates/components/navbar.html,sha256=qGr2m-1vTeCdMsc16anYrCpREvYHv0oJh6lpvtWL3jY,1055
40
- sandwitches/templates/components/rating_section.html,sha256=Hq1t51ETQckUzNeZyvEnGKGIHfUiu6XJF8T4TzCZ3NU,2723
39
+ sandwitches/templates/components/navbar.html,sha256=CtWqAmPke7nm-UqSvGGl6TPaNwT2Zqkw9UySOCA8hfo,1049
40
+ sandwitches/templates/components/rating_section.html,sha256=8O5IsFfQwnElMQZLnDpJiuCvvQMLa3jCS67u_RhMi7o,2717
41
41
  sandwitches/templates/components/recipe_header.html,sha256=-LCp6KqkQO7a7yqR0jKUQ95-RczYU-_MFO058lE04_w,1473
42
42
  sandwitches/templates/components/search_form.html,sha256=B8579Jo44gLrlmvkkc2-Vuv_QD93Ljt6F2J1WgTDV60,6617
43
43
  sandwitches/templates/components/search_scripts.html,sha256=HvsO5e50DoTZeoFiYeNP5S8S5h7Zfr9VULOWKKR1i_M,3423
@@ -46,6 +46,7 @@ sandwitches/templates/components/user_menu.html,sha256=c20cBpyLheGvHdQ5nn-c4fjNl
46
46
  sandwitches/templates/detail.html,sha256=g-O_RsW9Ix9ivWC0nZ4FwHY2NhgYZ3bEGLpqGY0JSxg,5642
47
47
  sandwitches/templates/favorites.html,sha256=0cPpW07N6Isrb8XpvA5Eh97L2-12QFZ43EzeJvbOlXo,917
48
48
  sandwitches/templates/index.html,sha256=JqIeAY2Yz5yZ9MWSMjWXOQIohykcPlJHBRUrspahGCU,899
49
+ sandwitches/templates/login.html,sha256=LiQskhkOkfx0EE4ssA1ToqQ3oEll08OPYLDIkLjHfU8,2177
49
50
  sandwitches/templates/partials/recipe_list.html,sha256=AVzz_fIE4cBVU-E2E0VpE1tFmUV8jy7QpOninZEUMi8,3952
50
51
  sandwitches/templates/recipe_form.html,sha256=TzdlzeSqUoJTDTuCdFbeF5jCBZUTZEtlTIC_IQM3WL8,4754
51
52
  sandwitches/templates/setup.html,sha256=iNveFgePATsCSO4XMbGPa8TnWHyvj8S_5WwcW6i7pbo,4661
@@ -53,10 +54,10 @@ sandwitches/templates/signup.html,sha256=pNBSlRGZI_B5ccF3dWpUgWBcjODkdLlq7HhyJLY
53
54
  sandwitches/templatetags/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
55
  sandwitches/templatetags/custom_filters.py,sha256=0KDFlFz4b5LwlcURBAmzyYWKKea-LwydZytJGVkkuKA,243
55
56
  sandwitches/templatetags/markdown_extras.py,sha256=0ibmRzxE3r85x4k7kK71R-9UT0CgeegYF7MHzj3juTI,344
56
- sandwitches/urls.py,sha256=uhzsVpKC8Vo6ReDZk3BMg9Pxg4uSrFO8rUdNm18h-xI,3710
57
+ sandwitches/urls.py,sha256=fT4JYLMrTS1IDgb3Ruivj69lXcW86Th44Lt4Kr6Tchs,3922
57
58
  sandwitches/utils.py,sha256=SJP-TkeRZ0OIfaMigYrOSbxRqYXswoqoWhwll3nFuAM,7245
58
- sandwitches/views.py,sha256=BpJkrBVXYoDMFborpH0FEaYT5xk0Dg4adCurXbFl4-o,20215
59
+ sandwitches/views.py,sha256=DA2q1ZrzdimTyVGt9Sbnvvex20gzMuu3N4SGoLQFNtU,20372
59
60
  sandwitches/wsgi.py,sha256=Eyncpnahq_4s3Lr9ruB-R3Lu9j9zBXqgPbUj7qhIbwU,399
60
- sandwitches-2.1.1.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
61
- sandwitches-2.1.1.dist-info/METADATA,sha256=uf0NdPqZ5ObdsQpR1J_6yxKbNjluClyqe-NYQjklh3c,3111
62
- sandwitches-2.1.1.dist-info/RECORD,,
61
+ sandwitches-2.1.2.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
62
+ sandwitches-2.1.2.dist-info/METADATA,sha256=TH8TEmijKUIiOWXUBs-WBv8hZestoOqw0NldlLLJ6kM,3111
63
+ sandwitches-2.1.2.dist-info/RECORD,,