small visual fixes, add a button to remove speakerproposal from eventproposal

This commit is contained in:
Thomas Steen Rasmussen 2018-05-27 17:19:19 +02:00
parent 2ba8d153fe
commit b34fe62118
7 changed files with 21 additions and 27 deletions

View file

@ -4,12 +4,12 @@
{% block program_content %}
<h3>Add {{ eventproposal.event_type.host_title }} {{ speakerproposal.name }} to {{ eventproposal.title }}</h3>
<p class="lead">Really add {{ speakerproposal.name }} as {{ eventproposal.event_type.host_title }} for {{ eventproposal.title }}?
<p class="lead">Really add <b>{{ speakerproposal.name }}</b> as {{ eventproposal.event_type.host_title }} for <b>{{ eventproposal.title }}</b>?
<form method="POST">
{% csrf_token %}
{% bootstrap_form form %}
{% bootstrap_button "<i class='fas fa-check'></i> Yes" button_type="submit" button_class="btn-success" %}
<a href="{% url 'program:proposal_list' camp_slug=camp.slug %}" class="btn btn-primary"><i class="fas fa-undo"></i> Cancel</a>
<a href="{% url 'program:eventproposal_detail' camp_slug=camp.slug pk=eventproposal.uuid %}" class="btn btn-primary"><i class="fas fa-undo"></i> Cancel</a>
</form>
{% endblock program_content %}

View file

@ -8,7 +8,7 @@
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
{% bootstrap_button "<i class='fas fa-times'></i> Remove" button_type="submit" button_class="btn-danger" %}
<a href="{% url 'program:eventproposal_detail' camp_slug=camp.slug pk=eventproposal.uuid %}">{% bootstrap_button "<i class='fas fa-undo'></i> Cancel" button_type="link" button_class="btn-primary" %}</a>
<a href="{% url 'program:eventproposal_detail' camp_slug=camp.slug pk=eventproposal.uuid %}" class="btn btn-primary"><i class='fas fa-undo'></i> Cancel</a>
</form>
{% endblock program_content %}

View file

@ -19,7 +19,7 @@ Add {{ eventproposal.event_type.host_title }} to {{ eventproposal.title }} | {{
{% for speakerproposal in speakerproposal_list %}
<a href="{% url 'program:eventproposal_addperson' camp_slug=camp.slug event_uuid=eventproposal.uuid speaker_uuid=speakerproposal.uuid %}" class="list-group-item">
<h4 class="list-group-item-heading">
Add {{ speakerproposal.name }} to {{ eventproposal.title }}
Add <b>{{ speakerproposal.name }}</b> to <b>{{ eventproposal.title }}</b>
</h4>
</a>
{% endfor %}

View file

@ -9,7 +9,7 @@
</div>
{% endif %}
<h2>{{ eventproposal.title }} Details</h2>
<h2>Details for {{ eventproposal.title }}</h2>
<div class="panel panel-default">
<div class="panel-heading">{{ eventproposal.title }}</div>

View file

@ -33,6 +33,9 @@
<a href="{% url 'program:speakerproposal_detail' camp_slug=camp.slug pk=speakerproposal.uuid %}" class="btn btn-primary btn-sm">
<i class="fas fa-eye"></i><span class="h5"> Details</span>
</a>
{% if camp.call_for_participation_open and not camp.read_only and eventproposal and eventproposal.speakers.count > 1 %}
<a href="{% url 'program:eventproposal_removeperson' camp_slug=camp.slug event_uuid=eventproposal.uuid speaker_uuid=speakerproposal.uuid %}" class="btn btn-danger btn-sm"><i class="fas fa-times"></i><span class="h5"> Remove {{ eventproposal.event_type.host_title }}</span></a>
{% endif %}
</td>
</tr>
{% endfor %}

View file

@ -9,7 +9,7 @@
</div>
{% endif %}
<h2>{{ speakerproposal.name }} Details</h2>
<h2>Details for {{ speakerproposal.name }}</h2>
<div class="panel panel-default">
<div class="panel-heading">{{ speakerproposal.name }}</div>

View file

@ -303,11 +303,13 @@ class EventProposalAddPersonView(LoginRequiredMixin, CampViewMixin, EnsureWritab
def form_valid(self, form):
form.instance.speakers.add(self.speakerproposal)
messages.success(self.request, "%s has been added as %s for %s" % (
self.speakerproposal.name,
form.instance.event_type.host_title,
form.instance.title
))
return redirect(self.get_success_url())
def get_success_url(self):
return reverse('program:proposal_list', kwargs={'camp_slug': self.camp.slug})
class EventProposalRemovePersonView(LoginRequiredMixin, CampViewMixin, EnsureWritableCampMixin, EnsureCFPOpenMixin, UpdateView):
"""
@ -322,16 +324,8 @@ class EventProposalRemovePersonView(LoginRequiredMixin, CampViewMixin, EnsureWri
""" Get the speakerproposal object and check a few things """
# get the speakerproposal object from URL kwargs
self.speakerproposal = get_object_or_404(models.SpeakerProposal, pk=kwargs['speaker_uuid'], user=request.user)
# run the super() dispatch method so we have self.camp otherwise the .all() lookup below craps out
response = super().dispatch(request, *args, **kwargs)
return super().dispatch(request, *args, **kwargs)
# is this speakerproposal even in use on this eventproposal
if self.speakerproposal not in self.get_object().speakers.all():
# this speaker is not associated with this event
raise Http404
# all good
return response
def get_context_data(self, *args, **kwargs):
""" Make speakerproposal object available in template """
@ -347,20 +341,17 @@ class EventProposalRemovePersonView(LoginRequiredMixin, CampViewMixin, EnsureWri
if self.get_object().speakers.count() == 1:
messages.error(self.request, "Cannot delete the last person associalted with event!")
return redirect(reverse(
'program:eventproposal_detail', kwargs={
'camp_slug': self.camp.slug,
'pk': self.get_object().uuid
}))
return redirect(self.get_success_url())
# remove speakerproposal from eventproposal
form.instance.speakers.remove(self.speakerproposal)
return redirect(self.get_success_url())
def get_success_url(self):
messages.success(self.request, "Speaker %s has been removed from %s" % (
messages.success(self.request, "%s has been removed from %s" % (
self.speakerproposal.name,
self.get_object().title
))
return redirect(self.get_success_url())
def get_success_url(self):
return reverse(
'program:eventproposal_detail', kwargs={
'camp_slug': self.camp.slug,