a few more proposal submission fixes

This commit is contained in:
Thomas Steen Rasmussen 2017-03-12 16:16:24 +01:00
parent 18e50d5e85
commit 2148d1c542
3 changed files with 65 additions and 4 deletions

View file

@ -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'),
),
]

View file

@ -174,21 +174,30 @@ class EventType(CreatedUpdatedModel):
""" Every event needs to have a type. """ """ Every event needs to have a type. """
name = models.CharField( name = models.CharField(
max_length=100, max_length=100,
unique=True unique=True,
help_text='The name of this event type',
) )
slug = models.SlugField() slug = models.SlugField()
color = models.CharField( color = models.CharField(
max_length=50 max_length=50,
help_text='The background color of this event type',
) )
light_text = models.BooleanField( light_text = models.BooleanField(
default=False default=False,
help_text='Check if this event type should use white text color',
) )
notifications = models.BooleanField( 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): def __str__(self):

View file

@ -94,6 +94,7 @@ class EventSubmissionCreateView(LoginRequiredMixin, CampViewMixin, CreateUserSub
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**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['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 return context
@ -102,6 +103,12 @@ class EventSubmissionUpdateView(LoginRequiredMixin, CampViewMixin, EnsureUserOwn
fields = ['title', 'abstract', 'event_type', 'speakers'] fields = ['title', 'abstract', 'event_type', 'speakers']
template_name = 'eventsubmission_form.html' 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): class EventSubmissionDetailView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsSubmissionMixin, DetailView):
model = models.EventSubmission model = models.EventSubmission