Skip to content

Commit

Permalink
Upgrading dependencies and code
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersSeverinsen committed Oct 17, 2024
1 parent 248ab07 commit 38ad7d6
Show file tree
Hide file tree
Showing 32 changed files with 386 additions and 294 deletions.
2 changes: 1 addition & 1 deletion bartab/forms.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion bartab/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion bartab/sumfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down
6 changes: 4 additions & 2 deletions bartenders/forms.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,7 +15,7 @@


class BartenderApplicationForm(forms.ModelForm):
captcha = ReCaptchaField()
captcha = ReCaptchaField(widget=ReCaptchaV2Invisible)

class Meta:
model = BartenderApplication
Expand Down Expand Up @@ -82,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):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Generated by Django 3.2.4 on 2024-10-17 18:29
# Generated by Django 4.2 on 2024-10-17 19:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("bartenders", "0002_ballotlink_poll"),
("bartenders", "0003_auto_20240915_2045"),
]

operations = [
Expand Down

This file was deleted.

35 changes: 35 additions & 0 deletions bartenders/migrations/0005_alter_bartender_email_and_more.py
Original file line number Diff line number Diff line change
@@ -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",
),
),
]
9 changes: 5 additions & 4 deletions bartenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,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

Expand Down Expand Up @@ -53,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"),
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions bartenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_accepting_application(self):
phoneNumber=42345123,
)
ap = BartenderApplication.objects.create(
**d, tshirt_size="L", study="Datalogi", study_year=1
**d, tshirt_size=2, study="Datalogi", study_year=1
)
ap.accept()

Expand Down Expand Up @@ -66,7 +66,7 @@ def test_sending_application(self):
email="[email protected]",
studentNumber=123123,
phoneNumber=12312312,
tshirt_size="L",
tshirt_size=2,
study="Datalogi",
study_year=1,
info="Hkll",
Expand Down
2 changes: 1 addition & 1 deletion bartenders/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.db import IntegrityError
from django.shortcuts import get_object_or_404, redirect, reverse
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.views.generic import (
CreateView,
FormView,
Expand Down
2 changes: 1 addition & 1 deletion events/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django import forms
from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from bartenders.models import Bartender

Expand Down
2 changes: 1 addition & 1 deletion events/forms.py
Original file line number Diff line number Diff line change
@@ -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 EventChoiceOption, EventResponse

Expand Down
2 changes: 1 addition & 1 deletion events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.contrib import messages
from django.http import HttpResponseBadRequest, HttpResponseForbidden
from django.shortcuts import redirect
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
from django_ical.views import ICalFeed

Expand Down
12 changes: 11 additions & 1 deletion fredagscafeen/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

from django.contrib import messages
from dotenv import load_dotenv

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
Expand Down Expand Up @@ -134,6 +135,13 @@
"success_css_class": "",
}

MESSAGE_TAGS = {
messages.DEBUG: "alert-info",
messages.INFO: "alert-info",
messages.SUCCESS: "alert-success",
messages.WARNING: "alert-warning",
messages.ERROR: "alert-danger",
}

# SECURITY WARNING: don't run with debug turned on in production!

Expand All @@ -156,7 +164,7 @@
"bootstrap5",
"django_bootstrap_icons",
"bootstrap_datepicker_plus",
"captcha",
"django_recaptcha",
"rest_framework",
"django_celery_beat",
"corsheaders",
Expand Down Expand Up @@ -291,6 +299,8 @@
# Use the new NoCaptcha
NOCAPTCHA = True

RECAPTCHA_REQUIRED_SCORE = 0.85

# CORS Setup
CORS_URLS_REGEX = r"^/api/.*$" # Only allow CORS requests in /api
CORS_ORIGIN_ALLOW_ALL = True
Expand Down
2 changes: 1 addition & 1 deletion fredagscafeen/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

SILENCED_SYSTEM_CHECKS = ["captcha.recaptcha_test_key_error"]
SILENCED_SYSTEM_CHECKS = ["django_recaptcha.recaptcha_test_key_error"]

AUTOLOGIN_USERNAME = os.environ.get("AUTOLOGIN_USERNAME")

Expand Down
2 changes: 1 addition & 1 deletion guides/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _


class Guide(models.Model):
Expand Down
2 changes: 1 addition & 1 deletion items/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.utils.translation import ugettext as _
from django.utils.translation import gettext_lazy as _
from django.views.generic import ListView, TemplateView

from .models import Item
Expand Down
Binary file modified locale/da/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 38ad7d6

Please sign in to comment.