vafling/waffles/models.py

97 lines
3.0 KiB
Python
Raw Normal View History

2015-08-16 14:11:07 +02:00
from django.db import models
2015-08-16 21:35:29 +02:00
from django.contrib.auth.models import AbstractUser
from django.utils.translation import ugettext_lazy as _
2015-08-16 14:11:07 +02:00
class UserProfile(AbstractUser):
2015-08-16 21:35:29 +02:00
"""
User profile
"""
2015-08-16 14:11:07 +02:00
pass
2015-08-16 21:35:29 +02:00
class Meta:
verbose_name = _('User profile')
verbose_name_plural = _('User profiles')
2015-08-16 14:11:07 +02:00
class Community(models.Model):
2015-08-16 21:35:29 +02:00
"""
Community
It works kind of like a django group, but is intended to
grow more complex over time.
"""
name = models.CharField(max_length=64, verbose_name=_("Community name"))
members = models.ManyToManyField(UserProfile, _("Community members"))
class Meta:
verbose_name = _('Community')
verbose_name_plural = _('Communities')
2015-08-16 14:11:07 +02:00
class Listing(models.Model):
2015-08-16 21:35:29 +02:00
"""
Listing requesting interest in creating an event.
Supposed to be removed and replaced with an event when someone answers it.
"""
community = models.ForeignKey(Community, verbose_name=_("Community"))
timeFrom = models.DateTimeField(verbose_name=_("Start time"))
timeTo = models.DateTimeField(verbose_name=_("End time"))
user = models.ForeignKey(UserProfile, verbose_name=_("Requesting user"))
description = models.TextField(verbose_name=_("Description/text"))
class Meta:
verbose_name = _('Listing')
verbose_name_plural = _('Listing')
2015-08-16 14:11:07 +02:00
class Event(models.Model):
2015-08-16 21:35:29 +02:00
"""
Event
2015-08-16 21:35:29 +02:00
A loose collection of participants at a location at a given time
"""
name = models.CharField(max_length=64, verbose_name=_("Event name"))
description = models.TextField(verbose_name=_("Description/text"))
open = models.BooleanField(verbose_name=_("Open for new participants"))
status = models.BooleanField(verbose_name=_("Finalized"))
participants = models.ManyToManyField(UserProfile, verbose_name=_("Participants"))
timeFrom = models.DateTimeField(verbose_name=_("Start time"))
timeTo = models.DateTimeField(verbose_name=_("End time"))
2015-08-16 21:35:29 +02:00
class Meta:
verbose_name = _('Event')
verbose_name_plural = _('Events')
2015-08-16 21:35:29 +02:00
class SubEvent(models.Model):
"""
Used to group parts of an event into smaller groups.
2015-08-16 21:35:29 +02:00
Used when not everyone is participating in the entire event.
"""
name = models.CharField(max_length=64, verbose_name=_("Name"))
participants = models.ManyToManyField(UserProfile, _("Participants"))
event = models.ForeignKey(Event, _("Parent event"))
2015-08-16 21:35:29 +02:00
class Meta:
verbose_name = _('Sub Event')
verbose_name_plural = _('Sub Events')
class ShoppingList(models.Model):
"""
Item to be bought or bought to the sub-event
The reason for using sub-events. Any responsibilities and duties here are isolated within the sub-event.
"""
name = models.CharField(max_length=64, verbose_name=_("Name"))
price = models.IntegerField(verbose_name=_("Price"))
payers = models.ManyToManyField(UserProfile, _("Payers"))
subevent = models.ForeignKey(SubEvent, _("Connected sub-event"))
class Meta:
verbose_name = _('Shopping list')
verbose_name_plural = _('Shopping lists')