From 181a0e43b0117ca05fad10600793a058f193b8de Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Sun, 12 Mar 2017 20:54:33 +0100 Subject: [PATCH] add some more speaker and event proposal submission stuff --- src/bornhack/urls.py | 10 ++++ src/program/mixins.py | 2 +- .../templates/eventproposal_submit.html | 14 ++++++ src/program/templates/proposal_list.html | 10 ++++ .../templates/speakerproposal_submit.html | 14 ++++++ src/program/views.py | 46 +++++++++++++++++-- 6 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 src/program/templates/eventproposal_submit.html create mode 100644 src/program/templates/speakerproposal_submit.html diff --git a/src/bornhack/urls.py b/src/bornhack/urls.py index 71bea179..e8fcedbd 100644 --- a/src/bornhack/urls.py +++ b/src/bornhack/urls.py @@ -157,6 +157,11 @@ urlpatterns = [ SpeakerProposalUpdateView.as_view(), name='speakerproposal_update' ), + url( + r'^(?P[a-f0-9-]+)/submit/$', + SpeakerProposalSubmitView.as_view(), + name='speakerproposal_submit' + ), url( r'^(?P[a-f0-9-]+)/pictures/(?P[-_\w+]+)/$', SpeakerProposalPictureView.as_view(), @@ -181,6 +186,11 @@ urlpatterns = [ EventProposalUpdateView.as_view(), name='eventproposal_update' ), + url( + r'^(?P[a-f0-9-]+)/submit/$', + EventProposalSubmitView.as_view(), + name='eventproposal_submit' + ), ]) ), ]) diff --git a/src/program/mixins.py b/src/program/mixins.py index 6bf9e8c1..6d7ac60f 100644 --- a/src/program/mixins.py +++ b/src/program/mixins.py @@ -14,7 +14,7 @@ class CreateProposalMixin(SingleObjectMixin): return redirect(reverse('proposal_list', kwargs={'camp_slug': self.camp.slug})) -class EnsureUnpprovedProposalMixin(SingleObjectMixin): +class EnsureUnapprovedProposalMixin(SingleObjectMixin): def dispatch(self, request, *args, **kwargs): # do not permit editing if the proposal is already approved if self.get_object().proposal_status == models.UserSubmittedModel.PROPOSAL_APPROVED: diff --git a/src/program/templates/eventproposal_submit.html b/src/program/templates/eventproposal_submit.html new file mode 100644 index 00000000..25d4d6ea --- /dev/null +++ b/src/program/templates/eventproposal_submit.html @@ -0,0 +1,14 @@ +{% extends 'program_base.html' %} +{% load bootstrap3 %} + +{% block program_content %} +

Confirm Submission

+
+ {% csrf_token %} + {% bootstrap_form form %} +

Really submit this event proposal for approval?

+ {% bootstrap_button "Submit" button_type="submit" button_class="btn-primary" %} +
+ +{% endblock program_content %} + diff --git a/src/program/templates/proposal_list.html b/src/program/templates/proposal_list.html index 947fe6fd..7aa1374f 100644 --- a/src/program/templates/proposal_list.html +++ b/src/program/templates/proposal_list.html @@ -25,6 +25,11 @@ Proposals | {{ block.super }} Details {% if not camp.read_only %} Modify + {% if speakerproposal.proposal_status == "pending" %} + Submit + {% else %} + Submit + {% endif %} Delete {% endif %} @@ -65,6 +70,11 @@ Proposals | {{ block.super }} Details {% if not camp.read_only %} Modify + {% if eventproposal.proposal_status == "pending" %} + Submit + {% else %} + Submit + {% endif %} Delete {% endif %} diff --git a/src/program/templates/speakerproposal_submit.html b/src/program/templates/speakerproposal_submit.html new file mode 100644 index 00000000..59680bf6 --- /dev/null +++ b/src/program/templates/speakerproposal_submit.html @@ -0,0 +1,14 @@ +{% extends 'program_base.html' %} +{% load bootstrap3 %} + +{% block program_content %} +

Confirm Submission

+
+ {% csrf_token %} + {% bootstrap_form form %} +

Really submit this speaker proposal for approval?

+ {% bootstrap_button "Submit" button_type="submit" button_class="btn-primary" %} +
+ +{% endblock program_content %} + diff --git a/src/program/views.py b/src/program/views.py index a1554ac0..b76b63f2 100644 --- a/src/program/views.py +++ b/src/program/views.py @@ -9,7 +9,7 @@ from django.contrib import messages from django.shortcuts import redirect from django.urls import reverse from camps.mixins import CampViewMixin -from .mixins import CreateProposalMixin, EnsureUnpprovedProposalMixin, EnsureUserOwnsProposalMixin, EnsureWritableCampMixin +from .mixins import CreateProposalMixin, EnsureUnapprovedProposalMixin, EnsureUserOwnsProposalMixin, EnsureWritableCampMixin from . import models import datetime, os @@ -39,7 +39,7 @@ class SpeakerProposalCreateView(LoginRequiredMixin, CampViewMixin, CreateProposa template_name = 'speakerproposal_form.html' -class SpeakerProposalUpdateView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsProposalMixin, EnsureUnpprovedProposalMixin, EnsureWritableCampMixin, UpdateView): +class SpeakerProposalUpdateView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsProposalMixin, EnsureUnapprovedProposalMixin, EnsureWritableCampMixin, UpdateView): model = models.SpeakerProposal fields = ['name', 'biography', 'picture_small', 'picture_large'] template_name = 'speakerproposal_form.html' @@ -47,6 +47,26 @@ class SpeakerProposalUpdateView(LoginRequiredMixin, CampViewMixin, EnsureUserOwn def get_success_url(self): return reverse('proposal_list', kwargs={'camp_slug': self.camp.slug}) + def form_valid(self, form): + if form.instance.proposal_status == models.UserSubmittedModel.PROPOSAL_PENDING: + messages.info(self.request, "Your speaker proposal has been reverted to status draft. Please submit it again when you are ready.") + form.instance.proposal_status = models.UserSubmittedModel.PROPOSAL_DRAFT + return super().form_valid(form) + + +class SpeakerProposalSubmitView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsProposalMixin, EnsureUnapprovedProposalMixin, EnsureWritableCampMixin, UpdateView): + model = models.SpeakerProposal + fields = [] + template_name = 'speakerproposal_submit.html' + + def get_success_url(self): + return reverse('proposal_list', kwargs={'camp_slug': self.camp.slug}) + + def form_valid(self, form): + form.instance.proposal_status = models.UserSubmittedModel.PROPOSAL_PENDING + messages.info(self.request, "Your proposal has been submitted and is now pending approval") + return super().form_valid(form) + class SpeakerProposalDetailView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsProposalMixin, DetailView): model = models.SpeakerProposal @@ -101,7 +121,7 @@ class EventProposalCreateView(LoginRequiredMixin, CampViewMixin, CreateProposalM return context -class EventProposalUpdateView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsProposalMixin, EnsureUnpprovedProposalMixin, EnsureWritableCampMixin, UpdateView): +class EventProposalUpdateView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsProposalMixin, EnsureUnapprovedProposalMixin, EnsureWritableCampMixin, UpdateView): model = models.EventProposal fields = ['title', 'abstract', 'event_type', 'speakers'] template_name = 'eventproposal_form.html' @@ -109,6 +129,26 @@ class EventProposalUpdateView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsP def get_success_url(self): return reverse('proposal_list', kwargs={'camp_slug': self.camp.slug}) + def form_valid(self, form): + if form.instance.proposal_status == models.UserSubmittedModel.PROPOSAL_PENDING: + messages.info(self.request, "Your event proposal has been reverted to status draft. Please submit it again when you are ready.") + form.instance.proposal_status = models.UserSubmittedModel.PROPOSAL_DRAFT + return super().form_valid(form) + + +class EventProposalSubmitView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsProposalMixin, EnsureUnapprovedProposalMixin, EnsureWritableCampMixin, UpdateView): + model = models.EventProposal + fields = [] + template_name = 'eventproposal_submit.html' + + def get_success_url(self): + return reverse('proposal_list', kwargs={'camp_slug': self.camp.slug}) + + def form_valid(self, form): + form.instance.proposal_status = models.UserSubmittedModel.PROPOSAL_PENDING + messages.info(self.request, "Your proposal has been submitted and is now pending approval") + return super().form_valid(form) + class EventProposalDetailView(LoginRequiredMixin, CampViewMixin, EnsureUserOwnsProposalMixin, DetailView): model = models.EventProposal