nk20/activity/models.py

90 lines
2.2 KiB
Python
Raw Normal View History

2019-07-16 10:43:23 +00:00
# -*- mode: python; coding: utf-8 -*-
# Copyright (C) 2018-2019 by BDE ENS Paris-Saclay
# SPDX-License-Identifier: GPL-3.0-or-later
2019-07-16 10:59:11 +00:00
from django.conf import settings
2019-07-16 10:43:23 +00:00
from django.db import models
from django.utils.translation import gettext_lazy as _
class ActivityType(models.Model):
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 10:43:23 +00:00
class Activity(models.Model):
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
class Guest(models.Model):
activity = models.ForeignKey(
Activity,
on_delete=models.PROTECT,
related_name='+',
)
name = models.CharField(
max_length=255,
)
inviter = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.PROTECT,
related_name='+',
)
entry = models.DateTimeField(
null=True,
)
entry_transaction = models.ForeignKey(
'note.Transaction',
on_delete=models.PROTECT,
)
2019-07-16 11:50:05 +00:00
class Meta:
verbose_name = _("guest")
verbose_name_plural = _("guests")