nk20/apps/activity/models.py

135 lines
3.2 KiB
Python
Raw Normal View History

2020-02-18 20:30:26 +00:00
# Copyright (C) 2018-2020 by BDE ENS Paris-Saclay
2019-07-16 10:43:23 +00:00
# SPDX-License-Identifier: GPL-3.0-or-later
from django.db import models
from django.utils.translation import gettext_lazy as _
2020-03-27 17:02:22 +00:00
from note.models import NoteUser
2019-07-16 10:43:23 +00:00
class ActivityType(models.Model):
2019-08-11 15:52:41 +00:00
"""
Type of Activity, (e.g "Pot", "Soirée Club") and associated properties.
Activity Type are used as a search field for Activity, and determine how
some rules about the activity:
- Can people be invited
- What is the entrance fee.
2019-08-11 15:52:41 +00:00
"""
2019-07-16 10:43:23 +00:00
name = models.CharField(
verbose_name=_('name'),
max_length=255,
)
can_invite = models.BooleanField(
verbose_name=_('can invite'),
)
guest_entry_fee = models.PositiveIntegerField(
verbose_name=_('guest entry fee'),
)
2019-07-16 11:50:05 +00:00
class Meta:
verbose_name = _("activity type")
verbose_name_plural = _("activity types")
2019-07-16 13:42:31 +00:00
def __str__(self):
return self.name
2019-07-16 10:43:23 +00:00
class Activity(models.Model):
2019-08-11 15:52:41 +00:00
"""
An IRL event organized by a club for other club.
By default the invited clubs should be the Club containing all the active accounts.
2019-08-11 15:52:41 +00:00
"""
2019-07-16 10:43:23 +00:00
name = models.CharField(
verbose_name=_('name'),
max_length=255,
)
description = models.TextField(
verbose_name=_('description'),
)
activity_type = models.ForeignKey(
ActivityType,
on_delete=models.PROTECT,
related_name='+',
verbose_name=_('type'),
)
organizer = models.ForeignKey(
'member.Club',
on_delete=models.PROTECT,
related_name='+',
verbose_name=_('organizer'),
)
attendees_club = models.ForeignKey(
'member.Club',
on_delete=models.PROTECT,
related_name='+',
verbose_name=_('attendees club'),
)
date_start = models.DateTimeField(
verbose_name=_('start date'),
)
date_end = models.DateTimeField(
verbose_name=_('end date'),
)
2019-07-16 11:50:05 +00:00
class Meta:
verbose_name = _("activity")
verbose_name_plural = _("activities")
2019-07-16 10:43:23 +00:00
2020-03-27 17:02:22 +00:00
class Entry(models.Model):
time = models.DateTimeField(
verbose_name=_("entry time"),
)
note = models.ForeignKey(
NoteUser,
on_delete=models.PROTECT,
verbose_name=_("note"),
)
2019-07-16 10:43:23 +00:00
class Guest(models.Model):
2019-08-11 15:52:41 +00:00
"""
People who are not current members of any clubs, and are invited by someone who is a current member.
2019-08-11 15:52:41 +00:00
"""
2019-07-16 10:43:23 +00:00
activity = models.ForeignKey(
Activity,
on_delete=models.PROTECT,
related_name='+',
)
2020-03-27 17:02:22 +00:00
last_name = models.CharField(
2019-07-16 10:43:23 +00:00
max_length=255,
2020-03-27 17:02:22 +00:00
verbose_name=_("last name"),
2019-07-16 10:43:23 +00:00
)
2020-03-27 17:02:22 +00:00
first_name = models.CharField(
max_length=255,
verbose_name=_("first name"),
)
2019-07-16 10:43:23 +00:00
inviter = models.ForeignKey(
2020-03-27 17:02:22 +00:00
NoteUser,
2019-07-16 10:43:23 +00:00
on_delete=models.PROTECT,
related_name='+',
2020-03-27 17:02:22 +00:00
verbose_name=_("inviter"),
2019-07-16 10:43:23 +00:00
)
2020-03-27 17:02:22 +00:00
entry = models.OneToOneField(
Entry,
on_delete=models.PROTECT,
2019-07-16 10:43:23 +00:00
null=True,
)
2020-03-27 17:02:22 +00:00
2019-07-16 10:43:23 +00:00
entry_transaction = models.ForeignKey(
'note.Transaction',
on_delete=models.PROTECT,
blank=True,
null=True,
2019-07-16 10:43:23 +00:00
)
2019-07-16 11:50:05 +00:00
class Meta:
verbose_name = _("guest")
verbose_name_plural = _("guests")