diff --git a/bartab/forms.py b/bartab/forms.py index 6288577..2969f1d 100644 --- a/bartab/forms.py +++ b/bartab/forms.py @@ -1,5 +1,5 @@ from django import forms -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from .models import BarTabSnapshot diff --git a/bartab/models.py b/bartab/models.py index 8778996..4632b21 100644 --- a/bartab/models.py +++ b/bartab/models.py @@ -6,7 +6,7 @@ from django.db.models import F, Sum, Value from django.db.models.functions import Coalesce from django.utils import timezone -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from bartenders.models import BartenderShift diff --git a/bartab/sumfield.py b/bartab/sumfield.py index 9fee0f9..ad38037 100644 --- a/bartab/sumfield.py +++ b/bartab/sumfield.py @@ -4,7 +4,7 @@ from django import forms from django.core.exceptions import ValidationError from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ SumValue = namedtuple("SumValue", ["string", "value"]) diff --git a/bartenders/forms.py b/bartenders/forms.py index a0abf87..09d3808 100644 --- a/bartenders/forms.py +++ b/bartenders/forms.py @@ -1,11 +1,12 @@ from urllib.parse import urljoin -from captcha.fields import ReCaptchaField from django import forms from django.conf import settings from django.contrib.auth.models import User from django.urls import reverse from django.utils.safestring import mark_safe +from django_recaptcha.fields import ReCaptchaField +from django_recaptcha.widgets import ReCaptchaV2Invisible from bartab.models import BarTabUser from fredagscafeen.email import send_template_email @@ -14,7 +15,7 @@ class BartenderApplicationForm(forms.ModelForm): - captcha = ReCaptchaField() + captcha = ReCaptchaField(widget=ReCaptchaV2Invisible) class Meta: model = BartenderApplication @@ -23,6 +24,7 @@ class Meta: def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + self.fields["tshirt_size"].widget.attrs.update({"class": "form-control"}) for name in self.fields: self.fields[name].required = name != "info" @@ -81,6 +83,7 @@ class Meta: def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + self.fields["tshirt_size"].widget.attrs.update({"class": "form-control"}) self.fields["username"].disabled = True def save(self, *args, **kwargs): diff --git a/bartenders/migrations/0004_alter_bartender_tshirt_size_and_more.py b/bartenders/migrations/0004_alter_bartender_tshirt_size_and_more.py new file mode 100644 index 0000000..216205e --- /dev/null +++ b/bartenders/migrations/0004_alter_bartender_tshirt_size_and_more.py @@ -0,0 +1,49 @@ +# Generated by Django 4.2 on 2024-10-17 19:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bartenders", "0003_auto_20240915_2045"), + ] + + operations = [ + migrations.AlterField( + model_name="bartender", + name="tshirt_size", + field=models.IntegerField( + blank=True, + choices=[ + (0, "XS"), + (1, "S"), + (2, "M"), + (3, "L"), + (4, "XL"), + (5, "XXL"), + (6, "XXXL"), + ], + null=True, + verbose_name="T-shirt størrelse", + ), + ), + migrations.AlterField( + model_name="bartenderapplication", + name="tshirt_size", + field=models.IntegerField( + blank=True, + choices=[ + (0, "XS"), + (1, "S"), + (2, "M"), + (3, "L"), + (4, "XL"), + (5, "XXL"), + (6, "XXXL"), + ], + null=True, + verbose_name="T-shirt størrelse", + ), + ), + ] diff --git a/bartenders/migrations/0005_alter_bartender_email_and_more.py b/bartenders/migrations/0005_alter_bartender_email_and_more.py new file mode 100644 index 0000000..4e35fe6 --- /dev/null +++ b/bartenders/migrations/0005_alter_bartender_email_and_more.py @@ -0,0 +1,35 @@ +# Generated by Django 5.1.2 on 2024-10-17 21:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bartenders", "0004_alter_bartender_tshirt_size_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="bartender", + name="email", + field=models.EmailField( + blank=True, + help_text="En post.au mail fungerer ikke", + max_length=254, + unique=True, + verbose_name="E-mail", + ), + ), + migrations.AlterField( + model_name="bartenderapplication", + name="email", + field=models.EmailField( + blank=True, + help_text="En post.au mail fungerer ikke", + max_length=254, + unique=True, + verbose_name="E-mail", + ), + ), + ] diff --git a/bartenders/models.py b/bartenders/models.py index 8725f69..248dd38 100644 --- a/bartenders/models.py +++ b/bartenders/models.py @@ -2,6 +2,7 @@ from enum import IntEnum from urllib.parse import urljoin +from django import forms from django.conf import settings from django.db import models from django.db.models import Q @@ -10,7 +11,7 @@ from django.urls import reverse from django.utils import timezone from django.utils.safestring import mark_safe -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from fredagscafeen.email import send_template_email @@ -36,13 +37,13 @@ def date_format(dt, format): # but we enforce that in BartenderApplicationForm for new applications. class BartenderCommon(models.Model): TSHIRT_SIZE_CHOICES = ( - ("XS", "XS"), - ("S", "S"), - ("M", "M"), - ("L", "L"), - ("XL", "XL"), - ("XXL", "XXL"), - ("XXXL", "XXXL"), + (0, "XS"), + (1, "S"), + (2, "M"), + (3, "L"), + (4, "XL"), + (5, "XXL"), + (6, "XXXL"), ) class Meta: @@ -52,8 +53,7 @@ class Meta: username = models.CharField( max_length=140, unique=True, verbose_name=_("Brugernavn") ) - email = models.CharField( - max_length=255, + email = models.EmailField( unique=True, blank=True, verbose_name=_("E-mail"), @@ -65,9 +65,8 @@ class Meta: phoneNumber = models.IntegerField( blank=True, null=True, verbose_name=_("Telefonnummer") ) - tshirt_size = models.CharField( + tshirt_size = models.IntegerField( choices=TSHIRT_SIZE_CHOICES, - max_length=10, blank=True, null=True, verbose_name=_("T-shirt størrelse"), @@ -337,7 +336,9 @@ def next_bartender_shift_start(last_date=None): next_date = next_date_with_weekday(last_date, Weekday.FRIDAY) dt = datetime.datetime.combine(next_date, BartenderShift.DEFAULT_START_TIME) - return timezone.get_default_timezone().localize(dt) + tz = timezone.get_current_timezone() + aware_datetime = timezone.make_aware(dt, tz) + return aware_datetime def next_bartender_shift_dates(count): diff --git a/bartenders/templates/ballots.html b/bartenders/templates/ballots.html index 325a135..92a0903 100644 --- a/bartenders/templates/ballots.html +++ b/bartenders/templates/ballots.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% load static %} -{% load bootstrap3 %} +{% load bootstrap5 %} {% block content %} diff --git a/bartenders/templates/ballots_update.html b/bartenders/templates/ballots_update.html index cbe49c1..60fac06 100644 --- a/bartenders/templates/ballots_update.html +++ b/bartenders/templates/ballots_update.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% load i18n %} {% load static %} -{% load bootstrap3 %} +{% load bootstrap5 bootstrap_icons %} {% block content %} @@ -16,7 +16,9 @@