Skip to content
Snippets Groups Projects
Commit 7372502e authored by Tom Teichler's avatar Tom Teichler :beers:
Browse files

Reformat and make lint clean

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