Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/events_models' into events_models
Browse files Browse the repository at this point in the history
  • Loading branch information
petrceska committed Sep 28, 2023
2 parents f4ba0b6 + 38474e9 commit 61a37c7
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 55 deletions.
18 changes: 13 additions & 5 deletions fiesta/apps/events/admin.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions fiesta/apps/events/apps.py
Original file line number Diff line number Diff line change
@@ -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"]
3 changes: 1 addition & 2 deletions fiesta/apps/events/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from __future__ import annotations
from .configuration import EventsConfiguration
from .event import Event
from .organizer import Organizer
from .participant import Participant
from .place import Place
from .price_variant import PriceVariant



__all__ = [
"EventsConfiguration",
"Event",
Expand Down
7 changes: 4 additions & 3 deletions fiesta/apps/events/models/configuration.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from django.db import models
from django.utils.translation import gettext_lazy as _

Expand All @@ -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"]
9 changes: 5 additions & 4 deletions fiesta/apps/events/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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,
Expand Down Expand Up @@ -93,7 +94,7 @@ class Event(BaseTimestampedModel):
null=True,
blank=True,
)

place = models.ForeignKey(
"events.Place",
on_delete=models.SET_NULL,
Expand Down Expand Up @@ -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)
# TODO hybrid registration, default user, only online (qr), offline registrations (counter, subtract from capacity)
7 changes: 2 additions & 5 deletions fiesta/apps/events/models/organizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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

Expand Down
6 changes: 2 additions & 4 deletions fiesta/apps/events/models/participant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)"),
Expand Down Expand Up @@ -56,7 +55,6 @@ class Meta:
ordering = ["created"]



__all__ = ["Participant"]

# TODO problematika ověřování lidí (QR check-in)
# TODO problematika ověřování lidí (QR check-in)
5 changes: 2 additions & 3 deletions fiesta/apps/events/models/place.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.db import models
from django.utils.translation import gettext_lazy as _

from apps.utils.models import BaseModel


Expand Down Expand Up @@ -49,15 +50,13 @@ 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):
return self.name


__all__ = ["Place"]

28 changes: 15 additions & 13 deletions fiesta/apps/events/models/price_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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",
Expand Down Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions fiesta/apps/events/templates/events/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% extends "fiesta/base.html" %}

{% block main %}
<!-- <h1>Upcoming Events of {{ request.in_space_of_section }}</h1>-->
<!-- {{ request.in_space_of_section.events }}-->
<!-- <h1>Upcoming Events of {{ request.in_space_of_section }}</h1>-->
<!-- {{ request.in_space_of_section.events }}-->


{% endblock %}
7 changes: 3 additions & 4 deletions fiesta/apps/events/urls.py
Original file line number Diff line number Diff line change
@@ -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())]
5 changes: 2 additions & 3 deletions fiesta/apps/events/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from __future__ import annotations
from .index import EventsIndexView

__all__ = [
"EventsIndexView"
]
__all__ = ["EventsIndexView"]
3 changes: 2 additions & 1 deletion fiesta/apps/events/views/index.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 61a37c7

Please sign in to comment.