add some more speaker and event proposal submission stuff

This commit is contained in:
Thomas Steen Rasmussen 2017-03-12 20:54:33 +01:00
parent a8e81dbc6f
commit 181a0e43b0
6 changed files with 92 additions and 4 deletions

View file

@ -157,6 +157,11 @@ urlpatterns = [
SpeakerProposalUpdateView.as_view(),
name='speakerproposal_update'
),
url(
r'^(?P<pk>[a-f0-9-]+)/submit/$',
SpeakerProposalSubmitView.as_view(),
name='speakerproposal_submit'
),
url(
r'^(?P<pk>[a-f0-9-]+)/pictures/(?P<picture>[-_\w+]+)/$',
SpeakerProposalPictureView.as_view(),
@ -181,6 +186,11 @@ urlpatterns = [
EventProposalUpdateView.as_view(),
name='eventproposal_update'
),
url(
r'^(?P<pk>[a-f0-9-]+)/submit/$',
EventProposalSubmitView.as_view(),
name='eventproposal_submit'
),
])
),
])

View file

@ -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:

View file

@ -0,0 +1,14 @@
{% extends 'program_base.html' %}
{% load bootstrap3 %}
{% block program_content %}
<h3>Confirm Submission</h3>
<form method="POST">
{% csrf_token %}
{% bootstrap_form form %}
<p class="lead">Really submit this event proposal for approval?</p>
{% bootstrap_button "Submit" button_type="submit" button_class="btn-primary" %}
</form>
{% endblock program_content %}

View file

@ -25,6 +25,11 @@ Proposals | {{ block.super }}
<a href="{% url 'speakerproposal_detail' camp_slug=camp.slug pk=speakerproposal.uuid %}" class="btn btn-primary btn-xs">Details</a>
{% if not camp.read_only %}
<a href="{% url 'speakerproposal_update' camp_slug=camp.slug pk=speakerproposal.uuid %}" class="btn btn-primary btn-xs">Modify</a>
{% if speakerproposal.proposal_status == "pending" %}
<a href="{% url 'speakerproposal_submit' camp_slug=camp.slug pk=speakerproposal.uuid %}" class="btn btn-primary btn-xs btn-disabled" disabled>Submit</a>
{% else %}
<a href="{% url 'speakerproposal_submit' camp_slug=camp.slug pk=speakerproposal.uuid %}" class="btn btn-primary btn-xs">Submit</a>
{% endif %}
<a href="#" class="btn btn-danger btn-xs btn-disabled" disabled>Delete</a>
{% endif %}
</td>
@ -65,6 +70,11 @@ Proposals | {{ block.super }}
<a href="{% url 'eventproposal_detail' camp_slug=camp.slug pk=eventproposal.uuid %}" class="btn btn-primary btn-xs">Details</a>
{% if not camp.read_only %}
<a href="{% url 'eventproposal_update' camp_slug=camp.slug pk=eventproposal.uuid %}" class="btn btn-primary btn-xs">Modify</a>
{% if eventproposal.proposal_status == "pending" %}
<a href="{% url 'eventproposal_submit' camp_slug=camp.slug pk=eventproposal.uuid %}" class="btn btn-primary btn-xs btn-disabled" disabled>Submit</a>
{% else %}
<a href="{% url 'eventproposal_submit' camp_slug=camp.slug pk=eventproposal.uuid %}" class="btn btn-primary btn-xs">Submit</a>
{% endif %}
<a href="#" class="btn btn-danger btn-xs btn-disabled" disabled>Delete</a>
{% endif %}
</td>

View file

@ -0,0 +1,14 @@
{% extends 'program_base.html' %}
{% load bootstrap3 %}
{% block program_content %}
<h3>Confirm Submission</h3>
<form method="POST">
{% csrf_token %}
{% bootstrap_form form %}
<p class="lead">Really submit this speaker proposal for approval?</p>
{% bootstrap_button "Submit" button_type="submit" button_class="btn-primary" %}
</form>
{% endblock program_content %}

View file

@ -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