From 7372502e4e8cf2ee94f0e7dfc54386f5832f7b54 Mon Sep 17 00:00:00 2001
From: Tom Teichler <tom.teichler@teckids.org>
Date: Sun, 20 Feb 2022 21:27:23 +0100
Subject: [PATCH] Reformat and make lint clean

---
 aleksis/apps/paweljong/apps.py    |  5 +-
 aleksis/apps/paweljong/filters.py |  2 +-
 aleksis/apps/paweljong/forms.py   | 21 ++++----
 aleksis/apps/paweljong/menus.py   |  1 -
 aleksis/apps/paweljong/models.py  |  6 +--
 aleksis/apps/paweljong/rules.py   |  5 +-
 aleksis/apps/paweljong/tables.py  |  5 +-
 aleksis/apps/paweljong/urls.py    |  7 ++-
 aleksis/apps/paweljong/util.py    |  2 -
 aleksis/apps/paweljong/views.py   | 89 +++++++++++++++++++------------
 10 files changed, 86 insertions(+), 57 deletions(-)

diff --git a/aleksis/apps/paweljong/apps.py b/aleksis/apps/paweljong/apps.py
index 5760f9a..2699ec4 100644
--- a/aleksis/apps/paweljong/apps.py
+++ b/aleksis/apps/paweljong/apps.py
@@ -10,4 +10,7 @@ class DefaultConfig(AppConfig):
         "Repository": "https://edugit.org/Teckids/hacknfun/AlekSIS-App-Paweljong",
     }
     licence = "EUPL-1.2+"
-    copyright_info = (([2018, 2021], "Dominik George", "dominik.george@teckids.org"), ([2019, 2022], "Tom Teichler", "tom.teichler@teckids.org"),)
+    copyright_info = (
+        ([2018, 2021], "Dominik George", "dominik.george@teckids.org"),
+        ([2019, 2022], "Tom Teichler", "tom.teichler@teckids.org"),
+    )
diff --git a/aleksis/apps/paweljong/filters.py b/aleksis/apps/paweljong/filters.py
index 321a2a2..1bdf0aa 100644
--- a/aleksis/apps/paweljong/filters.py
+++ b/aleksis/apps/paweljong/filters.py
@@ -5,7 +5,7 @@ from material import Layout, Row
 
 from aleksis.core.filters import MultipleCharFilter
 
-from .models import Event, EventRegistration, Voucher, Terms
+from .models import Event, EventRegistration, Terms, Voucher
 
 
 class EventRegistrationFilter(FilterSet):
diff --git a/aleksis/apps/paweljong/forms.py b/aleksis/apps/paweljong/forms.py
index e9c98a2..b435e50 100644
--- a/aleksis/apps/paweljong/forms.py
+++ b/aleksis/apps/paweljong/forms.py
@@ -4,14 +4,13 @@ from django.utils.translation import ugettext_lazy as _
 
 from allauth.account.views import SignupForm
 from django_select2.forms import ModelSelect2MultipleWidget, ModelSelect2Widget
-from django_starfield import Stars
 from material import Fieldset, Layout, Row
 from phonenumber_field.formfields import PhoneNumberField
 
 from aleksis.core.mixins import ExtensibleForm
 from aleksis.core.models import Group, Person
 
-from .models import Event, EventRegistration, Voucher, Terms
+from .models import Event, EventRegistration, Terms, Voucher
 
 COMMENT_CHOICES = [
     ("first", _("Only first name")),
@@ -248,9 +247,11 @@ class RegisterEventContactDetails(ExtensibleForm):
 
     email = forms.EmailField(
         label=_("Email address"),
-        help_text=_("Please use your personal e-mail address here, which you will check "
-                    "personally. Important information will always be sent to your parents "
-                    "as well. Do not use an e-mail address owned by your parents here."),
+        help_text=_(
+            "Please use your personal e-mail address here, which you will check "
+            "personally. Important information will always be sent to your parents "
+            "as well. Do not use an e-mail address owned by your parents here."
+        ),
     )
 
     school = forms.CharField(
@@ -286,9 +287,11 @@ class RegisterEventAdditional(ExtensibleForm):
         model = EventRegistration
         fields = ["medical_information", "comment"]
         help_texts = {
-            "medical_informaiton": _("If there are any medically important things we need to "
-                                     "consider, e.g. when making food or to make sure you take "
-                                     "prescribed medication, please enter it here."),
+            "medical_informaiton": _(
+                "If there are any medically important things we need to "
+                "consider, e.g. when making food or to make sure you take "
+                "prescribed medication, please enter it here."
+            ),
             "comment": _("You can write down any remarks you want to tell us here."),
         }
 
@@ -354,7 +357,6 @@ class RegisterEventFinancial(ExtensibleForm):
 
 
 class RegisterEventConsent(ExtensibleForm):
-
     class Meta:
         model = EventRegistration
         fields = []
@@ -371,6 +373,7 @@ class RegisterEventConsent(ExtensibleForm):
             node = Fieldset(f"{field.title}", f"{field.title}")
             self.add_node_to_layout(node)
 
+
 class EditEventRegistrationForm(forms.ModelForm):
 
     layout = Layout(
diff --git a/aleksis/apps/paweljong/menus.py b/aleksis/apps/paweljong/menus.py
index 0a8cb25..227309d 100644
--- a/aleksis/apps/paweljong/menus.py
+++ b/aleksis/apps/paweljong/menus.py
@@ -36,7 +36,6 @@ MENUS = {
                         )
                     ],
                 },
-
                 {
                     "name": _("Generate participant list"),
                     "url": "generate_lists",
diff --git a/aleksis/apps/paweljong/models.py b/aleksis/apps/paweljong/models.py
index a065677..777d629 100644
--- a/aleksis/apps/paweljong/models.py
+++ b/aleksis/apps/paweljong/models.py
@@ -125,9 +125,9 @@ class EventRegistration(ExtensibleModel):
     person = models.ForeignKey(Person, on_delete=models.CASCADE, verbose_name=_("Person"))
     date_registred = models.DateTimeField(auto_now_add=True, verbose_name=_("Registration date"))
 
-    school=models.CharField(verbose_name=_("Name of school"), max_length=255)
-    school_class=models.CharField(verbose_name=_("School class"), max_length=255)
-    school_place=models.CharField(verbose_name=_("Place of the school"), max_length=255)
+    school = models.CharField(verbose_name=_("Name of school"), max_length=255)
+    school_class = models.CharField(verbose_name=_("School class"), max_length=255)
+    school_place = models.CharField(verbose_name=_("Place of the school"), max_length=255)
 
     comment = models.TextField(verbose_name=_("Comment / remarks"), blank=True, default="")
     medical_information = models.TextField(
diff --git a/aleksis/apps/paweljong/rules.py b/aleksis/apps/paweljong/rules.py
index e82fe84..99254b8 100644
--- a/aleksis/apps/paweljong/rules.py
+++ b/aleksis/apps/paweljong/rules.py
@@ -9,7 +9,7 @@ from aleksis.core.util.predicates import (
     is_group_member,
 )
 
-from .models import Event, EventRegistration, Voucher, Terms
+from .models import Event, EventRegistration, Terms, Voucher
 from .predicates import (
     is_own_registration,
     is_own_voucher,
@@ -106,7 +106,6 @@ rules.add_perm("paweljong.is_own_voucher_rule", is_own_voucher_predicate)
 
 # View terms
 view_terms_predicate = has_person & (
-    has_global_perm("paweljong.view_term")
-    | has_any_object("paweljong.view_term", Terms)
+    has_global_perm("paweljong.view_term") | has_any_object("paweljong.view_term", Terms)
 )
 rules.add_perm("paweljong.view_terms_rule", view_terms_predicate)
diff --git a/aleksis/apps/paweljong/tables.py b/aleksis/apps/paweljong/tables.py
index f50337f..356539f 100644
--- a/aleksis/apps/paweljong/tables.py
+++ b/aleksis/apps/paweljong/tables.py
@@ -14,7 +14,10 @@ class ManageEventsTable(tables.Table):
     date_registration = tables.Column(verbose_name=_("Registration until"))
 
     edit = tables.LinkColumn(
-        "edit_event_by_slug", args=[A("linked_group__short_name")], verbose_name=_("Edit"), text=_("Edit")
+        "edit_event_by_slug",
+        args=[A("linked_group__short_name")],
+        verbose_name=_("Edit"),
+        text=_("Edit"),
     )
 
 
diff --git a/aleksis/apps/paweljong/urls.py b/aleksis/apps/paweljong/urls.py
index 89ef768..7dd949c 100644
--- a/aleksis/apps/paweljong/urls.py
+++ b/aleksis/apps/paweljong/urls.py
@@ -34,7 +34,11 @@ urlpatterns = [
         name="register_event_by_slug",
     ),
     path("event/<slug:slug>", views.EventFullView.as_view(), name="event_by_name"),
-    path("event/<slug:slug>/start", views.RegisterEventStart.as_view(), name="register_event_by_slug_start"),
+    path(
+        "event/<slug:slug>/start",
+        views.RegisterEventStart.as_view(),
+        name="register_event_by_slug_start",
+    ),
     path("misc/set_email_needed/<slug:slug>", views.set_email_needed, name="set_email_needed"),
     path("events/create", views.CreateEventView.as_view(), name="create_event"),
     path("events/manage", views.manage_events, name="manage_events"),
@@ -77,5 +81,4 @@ urlpatterns = [
         views.TermEditView.as_view(),
         name="edit_term_by_pk",
     ),
-
 ]
diff --git a/aleksis/apps/paweljong/util.py b/aleksis/apps/paweljong/util.py
index 3792c6d..f540e7e 100644
--- a/aleksis/apps/paweljong/util.py
+++ b/aleksis/apps/paweljong/util.py
@@ -1,6 +1,4 @@
 import os
-import random
-import string
 from tempfile import mkstemp
 from textwrap import wrap
 
diff --git a/aleksis/apps/paweljong/views.py b/aleksis/apps/paweljong/views.py
index be7b56a..dda970f 100644
--- a/aleksis/apps/paweljong/views.py
+++ b/aleksis/apps/paweljong/views.py
@@ -1,6 +1,5 @@
 from django.conf import settings
 from django.contrib.auth import get_user_model
-from django.contrib.auth.decorators import login_required
 from django.http import HttpRequest, HttpResponse
 from django.shortcuts import redirect, render
 from django.urls import reverse_lazy
@@ -25,16 +24,16 @@ from aleksis.core.models import Activity, Person
 from aleksis.core.util import messages
 from aleksis.core.util.core_helpers import lazy_preference, objectgetter_optional
 
-from .filters import EventFilter, EventRegistrationFilter, VoucherFilter, TermsFilter
+from .filters import EventFilter, EventRegistrationFilter, VoucherFilter
 from .forms import (
     EditEventForm,
     EditEventRegistrationForm,
+    EditTermForm,
     EditVoucherForm,
     GenerateListForm,
-    EditTermForm,
 )
-from .models import Event, EventRegistration, Voucher, Terms
-from .tables import EventRegistrationsTable, ManageEventsTable, VouchersTable, TermsTable
+from .models import Event, EventRegistration, Terms, Voucher
+from .tables import EventRegistrationsTable, ManageEventsTable, TermsTable, VouchersTable
 
 User = get_user_model()
 
@@ -285,52 +284,66 @@ class RegisterEventWizardView(SessionWizardView):
             context["page_title"] = ""
             context["browser_title"] = ""
             context["info_title"] = _("Create e-mail address")
-            context["info_text"] = _("All participants need a personal e-mail address, which they check and read "
-                                     "temselves. We offer the possibility to register an e-mail address "
-                                     "on our secure servers, made for young users.")
+            context["info_text"] = _(
+                "All participants need a personal e-mail address, which they check and read "
+                "temselves. We offer the possibility to register an e-mail address "
+                "on our secure servers, made for young users."
+            )
         elif self.steps.current == "register":
             context["page_title"] = ""
             context["browser_title"] = ""
             context["info_title"] = _("Event registration")
-            context["info_text"] = _("First, please enter some basic information about yourself, and check "
-                                     "whether all information is correct.")
+            context["info_text"] = _(
+                "First, please enter some basic information about yourself, and check "
+                "whether all information is correct."
+            )
         elif self.steps.current == "contact_details":
             context["page_title"] = ""
             context["browser_title"] = ""
             context["info_title"] = _("Contact information")
-            context["info_text"] = _("Tell us how we can contact you. You will receive information about "
-                                     "the event by e-mail. Please use your personal e-mail address "
-                                     "where you will read mails yourself, not an address of your parents. "
-                                     "We will always send all important information to your parents as well, "
-                                     "and you will enter their e-mail address on the next page.")
+            context["info_text"] = _(
+                "Tell us how we can contact you. You will receive information about "
+                "the event by e-mail. Please use your personal e-mail address "
+                "where you will read mails yourself, not an address of your parents. "
+                "We will always send all important information to your parents as well, "
+                "and you will enter their e-mail address on the next page."
+            )
         elif self.steps.current == "guardians":
             context["page_title"] = ""
             context["browser_title"] = ""
             context["info_title"] = _("Legal guardians / parents")
-            context["info_text"] = _("Tell us how we can reach your parents or other legal guardians. "
-                                     "This should be the person who was present when you registered for the "
-                                     "event (which is now). If you want to add another parent, please tell us "
-                                     "later as a comment.")
+            context["info_text"] = _(
+                "Tell us how we can reach your parents or other legal guardians. "
+                "This should be the person who was present when you registered for the "
+                "event (which is now). If you want to add another parent, please tell us "
+                "later as a comment."
+            )
         elif self.steps.current == "additional":
             context["page_title"] = ""
             context["browser_title"] = ""
             context["info_title"] = _("Additional registration information")
-            context["info_text"] = _("Please answer the following questions as precisely as you can, so "
-                                     "we can make sure your event attendance will be organised as wel las possible.")
+            context["info_text"] = _(
+                "Please answer the following questions as precisely as you can, so "
+                "we can make sure your event attendance will be organised as wel las possible."
+            )
         elif self.steps.current == "financial":
             context["page_title"] = ""
             context["browser_title"] = ""
             context["info_title"] = _("Payment")
-            context["info_text"] = _("By default, we will send you an invoice, which you or your parents "
-                                     "can pay by bank transfer. You can also choose to pay by direct debit – "
-                                     "please make sure to enter exactly what your parents tell you.")
+            context["info_text"] = _(
+                "By default, we will send you an invoice, which you or your parents "
+                "can pay by bank transfer. You can also choose to pay by direct debit – "
+                "please make sure to enter exactly what your parents tell you."
+            )
         elif self.steps.current == "consent":
             context["page_title"] = ""
             context["browser_title"] = ""
             context["info_title"] = _("Consent")
-            context["info_text"] = _("Lastly, please read the terms and conditions carefully, together "
-                                     "with your parents. After that, you will need to confirm that you "
-                                     "agree with everything yourself, and that your parents also agree.")
+            context["info_text"] = _(
+                "Lastly, please read the terms and conditions carefully, together "
+                "with your parents. After that, you will need to confirm that you "
+                "agree with everything yourself, and that your parents also agree."
+            )
 
         return context
 
@@ -416,7 +429,9 @@ class RegisterEventWizardView(SessionWizardView):
         cleaned_data_consent = self.get_cleaned_data_for_step("consent")
 
         if cleaned_data_financial["voucher_code"] != "":
-            vouchers = Voucher.objects.filter(person=person, event=event, used=False, code=cleaned_data_financial["voucher_code"])
+            vouchers = Voucher.objects.filter(
+                person=person, event=event, used=False, code=cleaned_data_financial["voucher_code"]
+            )
             if vouchers:
                 voucher = vouchers.first()
             else:
@@ -446,7 +461,7 @@ class RegisterEventWizardView(SessionWizardView):
                 "email": cleaned_data_contact_details["email"],
                 "first_name": cleaned_data_contact_details["first_name"],
                 "last_name": cleaned_data_contact_details["last_name"],
-            }
+            },
         )
 
         if (
@@ -507,9 +522,9 @@ class RegisterEventWizardView(SessionWizardView):
             donation=cleaned_data_financial["donation"],
             accept_sepa=cleaned_data_financial["accept_sepa"],
             iban=cleaned_data_financial["iban"],
-            school = cleaned_data_contact_details["school"],
-            school_class = cleaned_data_contact_details["school_class"],
-            school_place = cleaned_data_contact_details["school_place"],
+            school=cleaned_data_contact_details["school"],
+            school_class=cleaned_data_contact_details["school_class"],
+            school_place=cleaned_data_contact_details["school_place"],
         )
         for field in event.linked_group.additional_fields.all():
             registration.extended_data[
@@ -517,12 +532,16 @@ class RegisterEventWizardView(SessionWizardView):
             ] = cleaned_data_additional[field.title]
 
         for field in event.terms.all():
-            registration.extended_data[slugify(field.title).replace("-", "_")] = cleaned_data_consent[field.title]
+            registration.extended_data[
+                slugify(field.title).replace("-", "_")
+            ] = cleaned_data_consent[field.title]
 
         registration.save()
 
         if cleaned_data_financial["voucher_code"] != "":
-            vouchers = Voucher.objects.filter(person=person, event=event, used=False, code=cleaned_data_financial["voucher_code"])
+            vouchers = Voucher.objects.filter(
+                person=person, event=event, used=False, code=cleaned_data_financial["voucher_code"]
+            )
             if vouchers:
                 voucher = vouchers.first()
                 registration.voucher = voucher
@@ -582,6 +601,7 @@ class EventFullView(DetailView):
         context["can_register"] = context["event"].can_register(request=self.request)
         return context
 
+
 class RegisterEventStart(DetailView):
 
     model = Event
@@ -595,6 +615,7 @@ class RegisterEventStart(DetailView):
         context["can_register"] = context["event"].can_register(request=self.request)
         return context
 
+
 class TermListView(PermissionRequiredMixin, SingleTableView):
     """Table of all terms."""
 
-- 
GitLab