Move Event and Registration model to own app

This commit is contained in:
Aarni Halinen
2018-06-05 19:33:35 +03:00
parent 0207bdf22b
commit 4e8adebb2d
14 changed files with 172 additions and 66 deletions
+2 -1
View File
@@ -2,7 +2,8 @@
from django.contrib import admin
from webapp.models import Official, Role, Committee
from webapp.models import Feed, Tag, BaseFeed, Event, Registration
from webapp.models import Feed, Tag, BaseFeed
from signup.models import Event, Registration
from modeltranslation.admin import TranslationAdmin
from django.contrib.auth.models import Permission
# this is needed so that the models get registered for translation
-50
View File
@@ -56,60 +56,11 @@ class Feed(BaseFeed):
verbose_name_plural = _('Feeds')
class Event(BaseFeed):
"""Model for event."""
start_time = models.DateTimeField(default=timezone.now)
end_time = models.DateTimeField(default=timezone.now)
registration = models.ForeignKey(
'Registration', on_delete=models.CASCADE, null=True)
def __str__(self):
return _('Event: {}').format(self.title)
class Meta:
verbose_name = _('Event')
verbose_name_plural = _('Events')
class Registration(models.Model):
"""Model for event registration."""
name = models.CharField(max_length=255)
email = models.EmailField()
options = JSONField()
def __str__(self):
return _('Registration: {}').format(self.name)
class Meta:
verbose_name = _('Registration')
verbose_name_plural = _('Registrations')
class BaseRole(models.Model):
"""Base model for occupations/roles."""
# CATEGORIES = (
# ('corporate', _('Corporate affairs')),
# ('freshman', _('Freshmen')),
# ('international', _('International')),
# ('external', _('External affairs')),
# ('media', _('Media')),
# ('tech', _('Technology')),
# ('wellbeing', _('Wellbeing')),
# ('elepaja', _('Elepaja')),
# ('ceremonies', _('Ceremonies')),
# ('culture', _('Culture')),
# ('studies', _('Studies')),
# ('sosso', _('Sössö magazine')),
# ('alumni', _('Alumni relations')),
# ('others', _('Others')),
# )
name = models.CharField(_('Name'), max_length=255)
is_board = models.BooleanField(_('Board member'))
# category = models.CharField(_('Category'), choices=CATEGORIES, default='others', max_length=255)
def __str__(self):
n = self.name.capitalize()
@@ -181,7 +132,6 @@ class Official(User):
auditlog.register(Tag)
auditlog.register(Feed)
auditlog.register(Event)
auditlog.register(PresetRole)
auditlog.register(Role)
auditlog.register(Official)
+1 -15
View File
@@ -1,7 +1,7 @@
"""Translation classes."""
from modeltranslation.translator import register, TranslationOptions
from webapp.models import BaseFeed, Feed, Tag, Event, Registration
from webapp.models import BaseFeed, Feed, Tag
from webapp.models import PresetRole, BaseRole
@@ -19,13 +19,6 @@ class FeedTranslationOptions(TranslationOptions):
fields = ()
@register(Event)
class EventTranslationOptions(TranslationOptions):
"""Class for event translation options."""
fields = ()
@register(Tag)
class TagTranslationOptions(TranslationOptions):
"""Class for tag translation options."""
@@ -33,13 +26,6 @@ class TagTranslationOptions(TranslationOptions):
fields = ('name',)
@register(Registration)
class RegistrationTranslationOptions(TranslationOptions):
"""Class for registration translation options."""
fields = ('name',)
@register(BaseRole)
class BaseRoleTranslationOptions(TranslationOptions):
"""Class for base role translation options"""