diff --git a/fiesta/apps/events/admin.py b/fiesta/apps/events/admin.py index 87736f8a..4843099b 100644 --- a/fiesta/apps/events/admin.py +++ b/fiesta/apps/events/admin.py @@ -1,14 +1,22 @@ +from __future__ import annotations from django.contrib import admin -from apps.plugins.models import BasePluginConfiguration -from .models import EventsConfiguration, Event, Organizer, Participant, Place, PriceVariant from ..plugins.admin import BaseChildConfigurationAdmin +from .models import Event, EventsConfiguration, Organizer, Participant, Place, PriceVariant +from apps.plugins.models import BasePluginConfiguration @admin.register(EventsConfiguration) class EventsConfigurationAdmin(BaseChildConfigurationAdmin): base_model = BasePluginConfiguration - list_display = ("name", "section", "shared", "require_confirmation", "members_can_create", "online_purchases",) + list_display = ( + "name", + "section", + "shared", + "require_confirmation", + "members_can_create", + "online_purchases", + ) show_in_index = True @@ -21,8 +29,8 @@ class EventAdmin(admin.ModelAdmin): # description=_("Filled"), # ) # def filled(self, obj: Section): - # return obj.memberships.count() - # TODO + # return obj.memberships.count() + # TODO @admin.register(Organizer) diff --git a/fiesta/apps/events/apps.py b/fiesta/apps/events/apps.py index cf250e33..a39a32b3 100644 --- a/fiesta/apps/events/apps.py +++ b/fiesta/apps/events/apps.py @@ -1,15 +1,17 @@ +from __future__ import annotations from django.utils.translation import gettext_lazy as _ + from apps.plugins.plugin import BasePluginAppConfig class EventsConfig(BasePluginAppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'apps.events' - verbose_name = _('Events') + default_auto_field = "django.db.models.BigAutoField" + name = "apps.events" + verbose_name = _("Events") emoji = "" - description = _('Fiesta plugin to handle events management and registrations.') + description = _("Fiesta plugin to handle events management and registrations.") - configuration_model = 'events.EventsConfiguration' + configuration_model = "events.EventsConfiguration" -__all__ = ['EventsConfig'] +__all__ = ["EventsConfig"] diff --git a/fiesta/apps/events/models/__init__.py b/fiesta/apps/events/models/__init__.py index 3cfe1c4e..56744c80 100644 --- a/fiesta/apps/events/models/__init__.py +++ b/fiesta/apps/events/models/__init__.py @@ -1,3 +1,4 @@ +from __future__ import annotations from .configuration import EventsConfiguration from .event import Event from .organizer import Organizer @@ -5,8 +6,6 @@ from .place import Place from .price_variant import PriceVariant - - __all__ = [ "EventsConfiguration", "Event", diff --git a/fiesta/apps/events/models/configuration.py b/fiesta/apps/events/models/configuration.py index df0c7cb7..5f63dc7d 100644 --- a/fiesta/apps/events/models/configuration.py +++ b/fiesta/apps/events/models/configuration.py @@ -1,3 +1,4 @@ +from __future__ import annotations from django.db import models from django.utils.translation import gettext_lazy as _ @@ -21,8 +22,8 @@ class EventsConfiguration(BasePluginConfiguration): ) class Meta: - verbose_name = _('events configuration') - verbose_name_plural = _('events configurations') + verbose_name = _("events configuration") + verbose_name_plural = _("events configurations") -__all__ = ['EventsConfiguration'] +__all__ = ["EventsConfiguration"] diff --git a/fiesta/apps/events/models/event.py b/fiesta/apps/events/models/event.py index cc75632d..9a9fb71f 100644 --- a/fiesta/apps/events/models/event.py +++ b/fiesta/apps/events/models/event.py @@ -9,6 +9,7 @@ # TODO Maybe pre-registration, registration and paused registration for different field. + class State(models.TextChoices): DRAFT = "draft", _("Draft") PUBLISHED = "published", _("Published") @@ -28,7 +29,7 @@ class Event(BaseTimestampedModel): "event-portrait-cover-photo", has_permission=has_permission_for_cover_photo_view, ) - + event_landscape_cover_photo_storage = NamespacedFilesStorage( "event-landscape-cover-photo", has_permission=has_permission_for_cover_photo_view, @@ -93,7 +94,7 @@ class Event(BaseTimestampedModel): null=True, blank=True, ) - + place = models.ForeignKey( "events.Place", on_delete=models.SET_NULL, @@ -129,9 +130,9 @@ def __str__(self): class Meta: ordering = ["start"] verbose_name = _("event") - verbose_name_plural = _('events') + verbose_name_plural = _("events") __all__ = ["Event"] -#TODO hybrid registration, default user, only online (qr), offline registrations (counter, subtract from capacity) \ No newline at end of file +# TODO hybrid registration, default user, only online (qr), offline registrations (counter, subtract from capacity) diff --git a/fiesta/apps/events/models/organizer.py b/fiesta/apps/events/models/organizer.py index a7043da3..6b156e02 100644 --- a/fiesta/apps/events/models/organizer.py +++ b/fiesta/apps/events/models/organizer.py @@ -3,8 +3,6 @@ from django.db import models from django.utils.translation import gettext_lazy as _ -from apps.files.storage import NamespacedFilesStorage -from apps.plugins.middleware.plugin import HttpRequest from apps.utils.models import BaseTimestampedModel @@ -36,13 +34,12 @@ class Organizer(BaseTimestampedModel): verbose_name=_("event"), db_index=True, ) - + class Meta: verbose_name = _("organizer") - verbose_name_plural = _('organizers') + verbose_name_plural = _("organizers") unique_together = (("user", "event"),) - def __str__(self): return self.user + self.event diff --git a/fiesta/apps/events/models/participant.py b/fiesta/apps/events/models/participant.py index 58c6038e..d27213aa 100644 --- a/fiesta/apps/events/models/participant.py +++ b/fiesta/apps/events/models/participant.py @@ -2,8 +2,8 @@ from django.db import models from django.utils.translation import gettext_lazy as _ + from apps.utils.models import BaseModel -from django.conf import settings class State(models.TextChoices): # TODO do we need a state if we have an expiration date @@ -13,7 +13,6 @@ class State(models.TextChoices): # TODO do we need a state if we have an expira class Participant(BaseModel): - created = models.DateTimeField( verbose_name=_("created at"), help_text=_("when the user placed the ordered (does not have to be paid)"), @@ -56,7 +55,6 @@ class Meta: ordering = ["created"] - __all__ = ["Participant"] -# TODO problematika ověřování lidí (QR check-in) \ No newline at end of file +# TODO problematika ověřování lidí (QR check-in) diff --git a/fiesta/apps/events/models/place.py b/fiesta/apps/events/models/place.py index 2ed56c2b..f8e83c0e 100644 --- a/fiesta/apps/events/models/place.py +++ b/fiesta/apps/events/models/place.py @@ -2,6 +2,7 @@ from django.db import models from django.utils.translation import gettext_lazy as _ + from apps.utils.models import BaseModel @@ -49,10 +50,9 @@ def __str__(self): class Meta: verbose_name = _("place") - verbose_name_plural = _('places') + verbose_name_plural = _("places") unique_together = (("section", "name"),) - # TODO nearest tram stop? def __str__(self): @@ -60,4 +60,3 @@ def __str__(self): __all__ = ["Place"] - diff --git a/fiesta/apps/events/models/price_variant.py b/fiesta/apps/events/models/price_variant.py index 645574e7..6de80813 100644 --- a/fiesta/apps/events/models/price_variant.py +++ b/fiesta/apps/events/models/price_variant.py @@ -20,10 +20,10 @@ def is_available(self, variant: PriceVariant, user: User): to_ = variant.available_to from_ = variant.available_from - if from_ is not None and from_ is not "" and from_ < datetime.now(): + if from_ is not None and from_ != "" and from_ < datetime.now(): return False - if to_ is not None and to_ is not "" and to_ > datetime.now(): + if to_ is not None and to_ != "" and to_ > datetime.now(): return False if variant.type == self.STANDARD: @@ -41,16 +41,18 @@ class PriceVariant(BaseModel): help_text=_("full name of the price"), ) - type = models.CharField(max_length=255, - choices=EventPriceVariantType.choices, - verbose_name=_("type"), - ) + type = models.CharField( + max_length=255, + choices=EventPriceVariantType.choices, + verbose_name=_("type"), + ) - amount = MoneyField(max_digits=10, - decimal_places=2, - default_currency='CZK', - verbose_name=_("amount"), - ) + amount = MoneyField( + max_digits=10, + decimal_places=2, + default_currency="CZK", + verbose_name=_("amount"), + ) event = models.ForeignKey( "events.Event", @@ -83,8 +85,8 @@ class PriceVariant(BaseModel): class Meta: unique_together = (("title", "event"),) - verbose_name = _('price variant') - verbose_name_plural = _('price variants') + verbose_name = _("price variant") + verbose_name_plural = _("price variants") __all__ = ["PriceVariant"] diff --git a/fiesta/apps/events/templates/events/index.html b/fiesta/apps/events/templates/events/index.html index e19a0fd6..6febda73 100644 --- a/fiesta/apps/events/templates/events/index.html +++ b/fiesta/apps/events/templates/events/index.html @@ -1,8 +1,8 @@ {% extends "fiesta/base.html" %} {% block main %} - - + + {% endblock %} diff --git a/fiesta/apps/events/urls.py b/fiesta/apps/events/urls.py index 1b05c9b2..257a5786 100644 --- a/fiesta/apps/events/urls.py +++ b/fiesta/apps/events/urls.py @@ -1,8 +1,7 @@ -from django.urls import path, include +from __future__ import annotations +from django.urls import path from .views import EventsIndexView # Define your urls here -urlpatterns = [ - path('', EventsIndexView.as_view()) -] +urlpatterns = [path("", EventsIndexView.as_view())] diff --git a/fiesta/apps/events/views/__init__.py b/fiesta/apps/events/views/__init__.py index c5a1ab12..e6e0c93f 100644 --- a/fiesta/apps/events/views/__init__.py +++ b/fiesta/apps/events/views/__init__.py @@ -1,5 +1,4 @@ +from __future__ import annotations from .index import EventsIndexView -__all__ = [ - "EventsIndexView" -] +__all__ = ["EventsIndexView"] diff --git a/fiesta/apps/events/views/index.py b/fiesta/apps/events/views/index.py index eb838b26..a6174489 100644 --- a/fiesta/apps/events/views/index.py +++ b/fiesta/apps/events/views/index.py @@ -1,5 +1,6 @@ +from __future__ import annotations from django.views.generic import TemplateView class EventsIndexView(TemplateView): - template_name = 'events/index.html' + template_name = "events/index.html"