From 2148d1c5420c1aadd2510e180e3135d5e01dfad8 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Sun, 12 Mar 2017 16:16:24 +0100 Subject: [PATCH] a few more proposal submission fixes --- .../migrations/0032_auto_20170312_1556.py | 45 +++++++++++++++++++ src/program/models.py | 17 +++++-- src/program/views.py | 7 +++ 3 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 src/program/migrations/0032_auto_20170312_1556.py diff --git a/src/program/migrations/0032_auto_20170312_1556.py b/src/program/migrations/0032_auto_20170312_1556.py new file mode 100644 index 00000000..e0dbbf28 --- /dev/null +++ b/src/program/migrations/0032_auto_20170312_1556.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-03-12 14:56 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('program', '0031_auto_20170312_1529'), + ] + + operations = [ + migrations.AddField( + model_name='eventtype', + name='public', + field=models.BooleanField(default=False, help_text='Check to permit users to submit events of this type'), + ), + migrations.AlterField( + model_name='eventsubmission', + name='speakers', + field=models.ManyToManyField(blank=True, help_text='Pick the speaker(s) for this event', to='program.SpeakerSubmission'), + ), + migrations.AlterField( + model_name='eventtype', + name='color', + field=models.CharField(help_text='The background color of this event type', max_length=50), + ), + migrations.AlterField( + model_name='eventtype', + name='light_text', + field=models.BooleanField(default=False, help_text='Check if this event type should use white text color'), + ), + migrations.AlterField( + model_name='eventtype', + name='name', + field=models.CharField(help_text='The name of this event type', max_length=100, unique=True), + ), + migrations.AlterField( + model_name='eventtype', + name='notifications', + field=models.BooleanField(default=False, help_text='Check to send notifications for this event type'), + ), + ] diff --git a/src/program/models.py b/src/program/models.py index b85ebb91..289abfef 100644 --- a/src/program/models.py +++ b/src/program/models.py @@ -174,21 +174,30 @@ class EventType(CreatedUpdatedModel): """ Every event needs to have a type. """ name = models.CharField( max_length=100, - unique=True + unique=True, + help_text='The name of this event type', ) slug = models.SlugField() color = models.CharField( - max_length=50 + max_length=50, + help_text='The background color of this event type', ) light_text = models.BooleanField( - default=False + default=False, + help_text='Check if this event type should use white text color', ) notifications = models.BooleanField( - default=False + default=False, + help_text='Check to send notifications for this event type', + ) + + public = models.BooleanField( + default=False, + help_text='Check to permit users to submit events of this type', ) def __str__(self): diff --git a/src/program/views.py b/src/program/views.py index 8dc7f392..0ae4b352 100644 --- a/src/program/views.py +++ b/src/program/views.py @@ -94,6 +94,7 @@ class EventSubmissionCreateView(LoginRequiredMixin, CampViewMixin, CreateUserSub def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['form'].fields['speakers'].queryset = models.SpeakerSubmission.objects.filter(camp=self.camp, user=self.request.user) + context['form'].fields['event_type'].queryset = models.EventType.objects.filter(public=True) return context @@ -102,6 +103,12 @@ class EventSubmissionUpdateView(LoginRequiredMixin, CampViewMixin, EnsureUserOwn fields = ['title', 'abstract', 'event_type', 'speakers'] template_name = 'eventsubmission_form.html' + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context['form'].fields['speakers'].queryset = models.SpeakerSubmission.objects.filter(camp=self.camp, user=self.request.user) + context['form'].fields['event_type'].queryset = models.EventType.objects.filter(public=True) + return context + class EventSubmissionDetailView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsSubmissionMixin, DetailView): model = models.EventSubmission