handling end of CFP
This commit is contained in:
parent
29fd4a89e0
commit
04848c5067
11
cfp/forms.py
11
cfp/forms.py
|
@ -1,18 +1,17 @@
|
|||
from django import forms
|
||||
from django.forms.models import modelform_factory
|
||||
|
||||
from .models import Participant, Talk, TalkCategory
|
||||
from .models import Participant, Talk
|
||||
|
||||
|
||||
class TalkForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
conference = kwargs.pop('conference')
|
||||
staff = kwargs.pop('staff')
|
||||
categories = kwargs.pop('categories')
|
||||
super().__init__(*args, **kwargs)
|
||||
if staff:
|
||||
self.fields['category'].queryset = TalkCategory.objects.filter(site=conference.site)
|
||||
if categories.exists():
|
||||
self.fields['category'].queryset = categories
|
||||
else:
|
||||
self.fields['category'].queryset = conference.opened_categories
|
||||
del self.fields['category']
|
||||
|
||||
class Meta:
|
||||
model = Talk
|
||||
|
|
15
cfp/templates/cfp/closed.html
Normal file
15
cfp/templates/cfp/closed.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block proposetab %} class="active"{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h1>
|
||||
{% trans "Participate" %}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<h2>{% trans "Sorry, the Call for Participation is closed!" %}</h2>
|
||||
|
||||
{% endblock %}
|
10
cfp/views.py
10
cfp/views.py
|
@ -8,7 +8,7 @@ from django.contrib import messages
|
|||
|
||||
from cfp.decorators import staff_required
|
||||
from .utils import is_staff
|
||||
from .models import Participant, Talk, Vote
|
||||
from .models import Participant, Talk, TalkCategory, Vote
|
||||
from .forms import TalkForm, ParticipantForm
|
||||
|
||||
|
||||
|
@ -22,15 +22,21 @@ def home(request, conference):
|
|||
def talk_proposal(request, conference, talk_id=None, participant_id=None):
|
||||
|
||||
site = conference.site
|
||||
if is_staff(request, request.user):
|
||||
categories = TalkCategory.objects.filter(site=site)
|
||||
else:
|
||||
categories = conference.opened_categories
|
||||
talk = None
|
||||
participant = None
|
||||
|
||||
if talk_id and participant_id:
|
||||
talk = get_object_or_404(Talk, token=talk_id, site=site)
|
||||
participant = get_object_or_404(Participant, token=participant_id, site=site)
|
||||
elif not categories.exists():
|
||||
return render(request, 'cfp/closed.html')
|
||||
|
||||
participant_form = ParticipantForm(request.POST or None, instance=participant)
|
||||
talk_form = TalkForm(request.POST or None, conference=conference, staff=is_staff(request, request.user), instance=talk)
|
||||
talk_form = TalkForm(request.POST or None, categories=categories, instance=talk)
|
||||
|
||||
if request.method == 'POST' and talk_form.is_valid() and participant_form.is_valid():
|
||||
talk = talk_form.save(commit=False)
|
||||
|
|
Loading…
Reference in New Issue
Block a user