From 8356902e3a9029ff36b12ea1f543d6d04446978d Mon Sep 17 00:00:00 2001 From: Jannis Portmann Date: Thu, 18 May 2023 15:27:41 +0200 Subject: [PATCH 01/10] Fix titles --- pflaenzli/pflaenzli/templates/403.html | 2 +- pflaenzli/pflaenzli/templates/403_csrf.html | 2 +- pflaenzli/pflaenzli/templates/500.html | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pflaenzli/pflaenzli/templates/403.html b/pflaenzli/pflaenzli/templates/403.html index 75dc473..f8dafaf 100644 --- a/pflaenzli/pflaenzli/templates/403.html +++ b/pflaenzli/pflaenzli/templates/403.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% load i18n %} {% block title %} - {% trans "Not found" %} + {% trans "Forbidden" %} {% endblock title %} {% block content %}
diff --git a/pflaenzli/pflaenzli/templates/403_csrf.html b/pflaenzli/pflaenzli/templates/403_csrf.html index 541ecb2..752cc1f 100644 --- a/pflaenzli/pflaenzli/templates/403_csrf.html +++ b/pflaenzli/pflaenzli/templates/403_csrf.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% load i18n %} {% block title %} - {% trans "Not found" %} + {% trans "Forbidden" %} {% endblock title %} {% block content %}
diff --git a/pflaenzli/pflaenzli/templates/500.html b/pflaenzli/pflaenzli/templates/500.html index 79184d8..f833ec0 100644 --- a/pflaenzli/pflaenzli/templates/500.html +++ b/pflaenzli/pflaenzli/templates/500.html @@ -1,12 +1,12 @@ {% extends 'base.html' %} {% load i18n %} {% block title %} - {% trans "Not found" %} + {% trans "Server error" %} {% endblock title %} {% block content %}

- Error 500 {% trans "Forbidden" %} + Error 500 {% trans "Server error" %}

{% blocktrans %}Uh-oh! The delicate balance of the botanical realms has been disrupted. The forces of nature are in disarray, and our plant guardians are diligently working to restore harmony. We apologize for any inconvenience caused during this mystical turbulence. Please bear with us as we channel our magic to mend the rupture. Please contact us, if you have any information that could help to dispel the dark magic!{% endblocktrans %} -- 2.43.0 From 3a689a7cae2a57dc4a279e37d490314fb84b88c9 Mon Sep 17 00:00:00 2001 From: Jannis Portmann Date: Thu, 18 May 2023 15:50:48 +0200 Subject: [PATCH 02/10] Add titles and meta description --- pflaenzli/pflaenzli/templates/app/faq.html | 4 +++- pflaenzli/pflaenzli/templates/app/imprint.html | 8 +++++++- pflaenzli/pflaenzli/templates/app/index.html | 5 ++++- pflaenzli/pflaenzli/templates/base.html | 5 ++++- pflaenzli/pflaenzli/templates/offer/search.html | 5 ++++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/pflaenzli/pflaenzli/templates/app/faq.html b/pflaenzli/pflaenzli/templates/app/faq.html index d43616e..57bf1ef 100644 --- a/pflaenzli/pflaenzli/templates/app/faq.html +++ b/pflaenzli/pflaenzli/templates/app/faq.html @@ -1,5 +1,7 @@ {% extends 'base.html' %} -{% block title %}Privacy Policy{% endblock %} +{% load i18n %} +{% block title %}FAQ{% endblock %} +{% block meta %}{% endblock %} {% block content %}

Frequently Asked Questions

Is it free?

diff --git a/pflaenzli/pflaenzli/templates/app/imprint.html b/pflaenzli/pflaenzli/templates/app/imprint.html index 38708cc..757ef73 100644 --- a/pflaenzli/pflaenzli/templates/app/imprint.html +++ b/pflaenzli/pflaenzli/templates/app/imprint.html @@ -1,5 +1,11 @@ {% extends 'base.html' %} -{% block title %}Privacy Policy{% endblock %} +{% load i18n %} +{% block title %} + {% trans 'Imprint' %} +{% endblock %} +{% block meta %} + +{% endblock %} {% block content %}

Privacy Policy

diff --git a/pflaenzli/pflaenzli/templates/app/index.html b/pflaenzli/pflaenzli/templates/app/index.html index c3acfd1..345990f 100644 --- a/pflaenzli/pflaenzli/templates/app/index.html +++ b/pflaenzli/pflaenzli/templates/app/index.html @@ -2,7 +2,10 @@ {% load static %} {% load i18n %} {% block title %}Home{% endblock %} -{% block meta %}{% endblock %} +{% block meta %} + +{% endblock %} {% block background %}home-background{% endblock %} {% block content %}

diff --git a/pflaenzli/pflaenzli/templates/base.html b/pflaenzli/pflaenzli/templates/base.html index 66ec25a..cf44b72 100644 --- a/pflaenzli/pflaenzli/templates/base.html +++ b/pflaenzli/pflaenzli/templates/base.html @@ -4,9 +4,12 @@ Pflänz.li - - {% block title %}{% endblock %} + {% block title %} + {% endblock title %} + {% block meta %} + {% endblock meta %} {% endblock %} {% block content %}

-- 2.43.0 From 9d2bfc4371d63e3fbe78dc856f96bf26f6460830 Mon Sep 17 00:00:00 2001 From: Jannis Portmann Date: Fri, 19 May 2023 10:59:16 +0200 Subject: [PATCH 03/10] Ignore generated files --- .gitignore | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f4bfa8e..8a19bc4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,14 @@ +# Project +plz_verzeichnis_v2.json +django.po +plz.pkl + .vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -!.vscode/*.code-snippets +.vscode/settings.json +.vscode/tasks.json +.vscode/launch.json +.vscode/extensions.json +.vscode/*.code-snippets # Local History for Visual Studio Code .history/ -- 2.43.0 From 8370050f2c8306240d5893fbf9d8718b4ecf4728 Mon Sep 17 00:00:00 2001 From: Jannis Portmann Date: Fri, 7 Jul 2023 13:47:56 +0200 Subject: [PATCH 04/10] Add categories for offers --- pflaenzli/pflaenzli/forms.py | 7 ++++- .../migrations/0004_offer_category.py | 28 +++++++++++++++++++ pflaenzli/pflaenzli/models.py | 9 ++++++ .../pflaenzli/templates/offer/detail.html | 4 ++- .../pflaenzli/templates/offer/search.html | 4 ++- pflaenzli/pflaenzli/views.py | 3 ++ 6 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 pflaenzli/pflaenzli/migrations/0004_offer_category.py diff --git a/pflaenzli/pflaenzli/forms.py b/pflaenzli/pflaenzli/forms.py index b4f8bfa..c3ae634 100644 --- a/pflaenzli/pflaenzli/forms.py +++ b/pflaenzli/pflaenzli/forms.py @@ -10,7 +10,7 @@ from .models import Offer, PflaenzliUser, Wish class CreateOfferForm(forms.ModelForm): class Meta: model = Offer - fields = ['title', 'description', 'zipcode', 'image'] + fields = ['title', 'description', 'category', 'zipcode', 'image'] class RegistrationForm(UserCreationForm): @@ -22,6 +22,7 @@ class RegistrationForm(UserCreationForm): class FilterForm(forms.Form): + category = forms.ChoiceField(choices=Offer.CATEGORIES) text = forms.CharField(max_length=128, required=False, label=_("Search")) zipcode = forms.CharField(max_length=4, required=False, label=_("ZIP code")) distance = forms.IntegerField(required=False, label=_("Distance")) @@ -30,6 +31,10 @@ class FilterForm(forms.Form): super().__init__(*args, **kwargs) # Set the translated labels with the selected language and icons for each form field + self.fields['category'].label = mark_safe( + f' {self.fields["category"].label}' + ) + self.fields['text'].label = mark_safe( f' {self.fields["text"].label}' ) diff --git a/pflaenzli/pflaenzli/migrations/0004_offer_category.py b/pflaenzli/pflaenzli/migrations/0004_offer_category.py new file mode 100644 index 0000000..3d4910f --- /dev/null +++ b/pflaenzli/pflaenzli/migrations/0004_offer_category.py @@ -0,0 +1,28 @@ +# Generated by Django 4.1.7 on 2023-05-19 10:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("pflaenzli", "0003_alter_offer_description_alter_offer_image_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="offer", + name="category", + field=models.CharField( + choices=[ + ("PLNT", "Plant"), + ("SEED", "Seedling"), + ("POT", "Pot"), + ("TOOL", "Tools"), + ("OTHR", "Other"), + ], + default="PLNT", + max_length=4, + ), + ), + ] diff --git a/pflaenzli/pflaenzli/models.py b/pflaenzli/pflaenzli/models.py index cc0a54a..f39585c 100644 --- a/pflaenzli/pflaenzli/models.py +++ b/pflaenzli/pflaenzli/models.py @@ -14,12 +14,21 @@ class PflaenzliUser(AbstractUser): class Offer(models.Model): + CATEGORIES = [ + ('PLNT', _('Plant')), + ('SEED', _('Seedling')), + ('POT', _('Pots')), + ('TOOL', _('Tools')), + ('OTHR', _('Other')), + ] + created = models.DateTimeField(default=timezone.now) user = models.ForeignKey(PflaenzliUser, on_delete=models.CASCADE) title = models.CharField(max_length=50, verbose_name=_('Title')) description = models.TextField(max_length=5000, verbose_name=_('Description')) zipcode = models.IntegerField(blank=True, default=0, verbose_name=_('ZIP code')) image = models.ImageField(upload_to="uploads/", verbose_name=_('Image')) + category = models.CharField(choices=CATEGORIES, max_length=4, default='PLNT', verbose_name=_('Category')) class Wish(models.Model): diff --git a/pflaenzli/pflaenzli/templates/offer/detail.html b/pflaenzli/pflaenzli/templates/offer/detail.html index a4d1d51..8b6ae9e 100644 --- a/pflaenzli/pflaenzli/templates/offer/detail.html +++ b/pflaenzli/pflaenzli/templates/offer/detail.html @@ -17,7 +17,9 @@ src="{{ offer.image.url }}">

-

{{ offer.title }}

+

+ {{ offer.title }}{{ offer.get_category_display }} +

diff --git a/pflaenzli/pflaenzli/templates/offer/search.html b/pflaenzli/pflaenzli/templates/offer/search.html index 1e60240..bd65b74 100644 --- a/pflaenzli/pflaenzli/templates/offer/search.html +++ b/pflaenzli/pflaenzli/templates/offer/search.html @@ -40,7 +40,9 @@ {% endif %}

-
{{ offer.title }}
+
+ {{ offer.title }}{{ offer.get_category_display }} +
{% endblock content %} diff --git a/pflaenzli/pflaenzli/templates/403_csrf.html b/pflaenzli/pflaenzli/templates/403_csrf.html index 752cc1f..a448edc 100644 --- a/pflaenzli/pflaenzli/templates/403_csrf.html +++ b/pflaenzli/pflaenzli/templates/403_csrf.html @@ -13,6 +13,6 @@

{% trans "What now?" %}

{% trans "Go home" %} - {% trans "Report error" %} + {% trans "Report error" %}
{% endblock content %} diff --git a/pflaenzli/pflaenzli/templates/404.html b/pflaenzli/pflaenzli/templates/404.html index ab7fa5d..ed0b68f 100644 --- a/pflaenzli/pflaenzli/templates/404.html +++ b/pflaenzli/pflaenzli/templates/404.html @@ -13,6 +13,6 @@

{% trans "What now?" %}

{% trans "Go home" %} - {% trans "Report error" %} + {% trans "Report error" %}
{% endblock content %} diff --git a/pflaenzli/pflaenzli/templates/500.html b/pflaenzli/pflaenzli/templates/500.html index f833ec0..03bd578 100644 --- a/pflaenzli/pflaenzli/templates/500.html +++ b/pflaenzli/pflaenzli/templates/500.html @@ -13,6 +13,6 @@

{% trans "What now?" %}

{% trans "Go home" %} - {% trans "Report error" %} + {% trans "Report error" %}
{% endblock content %} diff --git a/pflaenzli/pflaenzli/templates/app/index.html b/pflaenzli/pflaenzli/templates/app/index.html index 345990f..ce5e1ab 100644 --- a/pflaenzli/pflaenzli/templates/app/index.html +++ b/pflaenzli/pflaenzli/templates/app/index.html @@ -23,7 +23,7 @@ class="btn btn-pfl btn-lg mb-3" type="button">{% trans "Show offers" %} {% trans "Register" %}
diff --git a/pflaenzli/pflaenzli/templates/offer/detail.html b/pflaenzli/pflaenzli/templates/offer/detail.html index 8b6ae9e..10088bd 100644 --- a/pflaenzli/pflaenzli/templates/offer/detail.html +++ b/pflaenzli/pflaenzli/templates/offer/detail.html @@ -68,7 +68,7 @@