-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat-buddy-tweaks
- Loading branch information
Showing
23 changed files
with
761 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from __future__ import annotations | ||
|
||
from django.contrib import admin | ||
|
||
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", | ||
) | ||
show_in_index = True | ||
|
||
|
||
@admin.register(Event) | ||
class EventAdmin(admin.ModelAdmin): | ||
list_display = ("section", "title", "capacity", "state", "start", "end", "author", "place") | ||
show_in_index = True | ||
|
||
# @admin.display( | ||
# description=_("Filled"), | ||
# ) | ||
# def filled(self, obj: Section): | ||
# return obj.memberships.count() | ||
# TODO | ||
|
||
|
||
@admin.register(Organizer) | ||
class OrganizerAdmin(admin.ModelAdmin): | ||
list_display = ("user", "event", "state") | ||
show_in_index = True | ||
|
||
|
||
@admin.register(Participant) | ||
class ParticipantAdmin(admin.ModelAdmin): | ||
list_display = ("user", "event", "price", "created") | ||
show_in_index = True | ||
|
||
|
||
@admin.register(Place) | ||
class PlaceAdmin(admin.ModelAdmin): | ||
list_display = ("name", "description", "link", "map_link", "section") | ||
show_in_index = True | ||
|
||
|
||
@admin.register(PriceVariant) | ||
class PriceVariantAdmin(admin.ModelAdmin): | ||
list_display = ("title", "type", "amount", "event", "available_from", "available_to") | ||
show_in_index = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
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") | ||
emoji = "" | ||
description = _("Fiesta plugin to handle events management and registrations.") | ||
|
||
configuration_model = "events.EventsConfiguration" | ||
|
||
|
||
__all__ = ["EventsConfig"] |
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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", | ||
"Organizer", | ||
"Participant", | ||
"Place", | ||
"PriceVariant", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from __future__ import annotations | ||
|
||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from apps.plugins.models import BasePluginConfiguration | ||
|
||
|
||
class EventsConfiguration(BasePluginConfiguration): | ||
require_confirmation = models.BooleanField( | ||
default=True, | ||
verbose_name=_("require confirmation to publish"), | ||
) | ||
|
||
members_can_create = models.BooleanField( | ||
default=True, | ||
verbose_name=_("basic members can create an event"), | ||
) | ||
|
||
online_purchases = models.BooleanField( | ||
default=True, | ||
verbose_name=_("online purchases"), | ||
) | ||
|
||
class Meta: | ||
verbose_name = _("events configuration") | ||
verbose_name_plural = _("events configurations") | ||
|
||
|
||
__all__ = ["EventsConfiguration"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
from __future__ import annotations | ||
|
||
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 | ||
|
||
# TODO Maybe pre-registration, registration and paused registration for different field. | ||
|
||
|
||
class State(models.TextChoices): | ||
DRAFT = "draft", _("Draft") | ||
PUBLISHED = "published", _("Published") | ||
HIDDEN = "hidden", _("Hidden") # Visible only after invite | ||
|
||
|
||
def has_permission_for_cover_photo_view(request: HttpRequest, name: str) -> bool: # TODO | ||
if request.user.is_authenticated: | ||
return True | ||
|
||
return False | ||
|
||
|
||
class Event(BaseTimestampedModel): | ||
# storage used for cover photos | ||
event_portrait_cover_photo_storage = NamespacedFilesStorage( | ||
"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, | ||
) | ||
|
||
title = models.CharField( | ||
max_length=64, | ||
unique=True, | ||
verbose_name=_("title"), | ||
help_text=_("full name of the event"), | ||
) | ||
|
||
subtitle = models.TextField( | ||
verbose_name=_("subtitle"), | ||
help_text=_("short description of the event"), | ||
blank=True, | ||
) | ||
|
||
description = models.TextField( | ||
verbose_name=_("description"), | ||
help_text=_("full description of the event"), | ||
) | ||
|
||
capacity = models.SmallIntegerField( | ||
verbose_name=_("capacity"), | ||
help_text=_("capacity of the event"), | ||
) | ||
|
||
state = models.CharField( | ||
choices=State.choices, | ||
default=State.DRAFT, | ||
max_length=16, | ||
verbose_name=_("state"), | ||
help_text=_("current state of the event"), | ||
) | ||
|
||
start = models.DateTimeField( | ||
verbose_name=_("start"), | ||
help_text=_("when the event starts"), | ||
) | ||
|
||
end = models.DateTimeField( | ||
verbose_name=_("end"), | ||
help_text=_("when the event ends"), | ||
null=True, | ||
blank=True, | ||
) | ||
|
||
landscape_cover = models.ImageField( | ||
storage=event_landscape_cover_photo_storage, | ||
upload_to=event_landscape_cover_photo_storage.upload_to, | ||
verbose_name=_("landscape cover photo"), | ||
null=True, | ||
blank=True, | ||
) | ||
|
||
portrait_cover = models.ImageField( | ||
storage=event_portrait_cover_photo_storage, | ||
upload_to=event_portrait_cover_photo_storage.upload_to, | ||
verbose_name=_("portrait cover photo"), | ||
null=True, | ||
blank=True, | ||
) | ||
|
||
place = models.ForeignKey( | ||
"events.Place", | ||
on_delete=models.SET_NULL, | ||
verbose_name=_("place"), | ||
db_index=False, | ||
null=True, | ||
blank=True, | ||
) | ||
|
||
author = models.ForeignKey( | ||
to="accounts.User", | ||
on_delete=models.SET_NULL, | ||
related_name="events", | ||
verbose_name=_("author"), | ||
db_index=False, | ||
null=True, | ||
blank=True, | ||
) | ||
|
||
section = models.ForeignKey( | ||
to="sections.Section", | ||
on_delete=models.CASCADE, | ||
related_name="events", | ||
verbose_name=_("ESN section"), | ||
help_text=_("Users from this section can join this event."), | ||
db_index=True, | ||
) | ||
|
||
def __str__(self): | ||
# return self.title | ||
return f"{self.title} - {self.start}" | ||
|
||
class Meta: | ||
ordering = ["start"] | ||
verbose_name = _("event") | ||
verbose_name_plural = _("events") | ||
|
||
|
||
__all__ = ["Event"] | ||
|
||
# TODO hybrid registration, default user, only online (qr), offline registrations (counter, subtract from capacity) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from __future__ import annotations | ||
|
||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from apps.utils.models import BaseTimestampedModel | ||
|
||
|
||
class Role(models.TextChoices): | ||
EVENT_LEADER = "event_leader", _("Event_leader") | ||
OC = "oc", _("OC") | ||
|
||
|
||
class Organizer(BaseTimestampedModel): | ||
state = models.CharField( | ||
choices=Role.choices, | ||
default=Role.OC, | ||
verbose_name=_("state"), | ||
help_text=_("current state of the event"), | ||
) | ||
|
||
user = models.ForeignKey( | ||
"accounts.User", | ||
on_delete=models.CASCADE, | ||
related_name="event", | ||
verbose_name=_("user"), | ||
db_index=True, | ||
) | ||
|
||
event = models.ForeignKey( | ||
"events.Event", | ||
on_delete=models.CASCADE, | ||
related_name="organizer", | ||
verbose_name=_("event"), | ||
db_index=True, | ||
) | ||
|
||
class Meta: | ||
verbose_name = _("organizer") | ||
verbose_name_plural = _("organizers") | ||
unique_together = (("user", "event"),) | ||
|
||
def __str__(self): | ||
return self.user + self.event | ||
|
||
|
||
__all__ = ["Organizer"] |
Oops, something went wrong.