Move Event and Registration model to own app
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
# Ilmotunkki
|
||||
|
||||
## Terms
|
||||
- Signup, Form with collection of questions
|
||||
- Response, One answer to some signup
|
||||
- Quota, Amount of people allowed to respond with some option selected.
|
||||
- In generic case there is no option and quota is just max number of people.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Officials may generate signups forms
|
||||
- Officials may see results from signups
|
||||
- Officials may see some stats from their signups
|
||||
- for example distributions of multiple choice answers
|
||||
- Officials should be able to edit signups wherever possible
|
||||
- Propably not possible to edit after first response
|
||||
- Officials should be able to delete responses
|
||||
- Officials should be able to embed payment information to the signup?
|
||||
- TODO: is there need for unique reference numbers for every response?
|
||||
- Officials should be able to save a signup to a reusable template.
|
||||
- Possibility to save templates?
|
||||
|
||||
- Signup may be attached to an event
|
||||
- Multiple signups to a single event should be possible (FTMK uses for museum visits? Erna asked if it was possible in old web)
|
||||
- Possibility for external service (Google Form, URL will suffice)
|
||||
|
||||
- Signup should support custom quotas
|
||||
- Atleast quotas from multiple choices and checkboxes
|
||||
- Text quotas are risky (typos everywhere!!)
|
||||
- Signup should have start and end times
|
||||
- Signup should support atleast following questiontypes
|
||||
- Text
|
||||
- multiple choice (select one)
|
||||
- checkbox (boolean yes/no)
|
||||
|
||||
- Signup should support reserve slots.
|
||||
- TODO: quota based reserves or generic? or both?
|
||||
|
||||
- Responding should send confirm email
|
||||
- Response should be editable by responder and only by the responder until the closing of the signup
|
||||
- TODO: is there need to custom edit period or disable?
|
||||
|
||||
- Responders should see amount of quotas left.
|
||||
- Responders should see some information about other responses
|
||||
- TODO: names? should this be editable by officials?
|
||||
- Or superadmin can edit and the one signing up within edit period
|
||||
- NOTE: Quota related info is exposed if any info is printed
|
||||
- When quotas need to be hidden? PoTa?
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class IlmotunkkiConfig(AppConfig):
|
||||
name = 'ilmotunkki'
|
||||
@@ -0,0 +1,63 @@
|
||||
"""Signup and Event models."""
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from webapp.models import Tag, BaseFeed
|
||||
from webapp.utils import month_from_now
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from auditlog.registry import auditlog
|
||||
from phonenumber_field.modelfields import PhoneNumberField
|
||||
from django.contrib.postgres.fields import JSONField
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
VERBOSE_NAME = _('Webapp')
|
||||
|
||||
|
||||
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 Signup(models.Model):
|
||||
start = models.DateTimeField()
|
||||
end = models.DateTimeField()
|
||||
|
||||
|
||||
class Question(models.Model):
|
||||
pass
|
||||
|
||||
|
||||
class Answer(models.Model):
|
||||
signup = models.ForeignKey(Signup, on_delete=models.CASCADE)
|
||||
question = models.ForeignKey(Question, on_delete=models.PROTECT)
|
||||
|
||||
|
||||
auditlog.register(Event)
|
||||
auditlog.register(Signup)
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,17 @@
|
||||
"""Translation classes."""
|
||||
|
||||
from modeltranslation.translator import register, TranslationOptions
|
||||
from signup.models import Event, Registration
|
||||
|
||||
@register(Event)
|
||||
class EventTranslationOptions(TranslationOptions):
|
||||
"""Class for event translation options."""
|
||||
|
||||
fields = ()
|
||||
|
||||
|
||||
@register(Registration)
|
||||
class RegistrationTranslationOptions(TranslationOptions):
|
||||
"""Class for registration translation options."""
|
||||
|
||||
fields = ('name',)
|
||||
@@ -0,0 +1,25 @@
|
||||
"""Signup urls."""
|
||||
|
||||
from django.conf.urls import url
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
# from kaehmy.views import view
|
||||
# from kaehmy.views import list_view
|
||||
# from kaehmy.views import submit
|
||||
# from kaehmy.views import comment
|
||||
# from kaehmy.views import statistics_view
|
||||
# from kaehmy.views import export_view
|
||||
|
||||
urlpatterns = [
|
||||
# kaehmy
|
||||
# url(r'^new', new_form),
|
||||
# url(r'^$', list_view),
|
||||
# url(r'^submit', submit),
|
||||
# url(r'^statistics', statistics_view),
|
||||
# url(r'^export', export_view),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
urlpatterns += staticfiles_urlpatterns()
|
||||
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
@@ -92,6 +92,7 @@ INSTALLED_APPS = [
|
||||
'webapp',
|
||||
'members',
|
||||
'infoscreen',
|
||||
'signup',
|
||||
'coffee_scale',
|
||||
'kaehmy',
|
||||
'ohlhafv',
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
@@ -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
@@ -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"""
|
||||
|
||||
Reference in New Issue
Block a user