merge talk-speaker-{add,remove} in talk-edit
This commit is contained in:
parent
5e7143d239
commit
b1e5d0b481
|
@ -99,7 +99,7 @@ class TalkStaffForm(forms.ModelForm):
|
|||
self.fields['duration'].help_text = _('Default duration: %(duration)d min') % {'duration': self.instance.duration}
|
||||
|
||||
class Meta(TalkForm.Meta):
|
||||
fields = ('category', 'track', 'title', 'description', 'notes', 'tags', 'start_date', 'duration', 'room', 'materials', 'video',)
|
||||
fields = ('category', 'track', 'title', 'description', 'notes', 'tags', 'start_date', 'duration', 'room', 'materials', 'video', 'speakers')
|
||||
widgets = {
|
||||
'tags': forms.CheckboxSelectMultiple,
|
||||
}
|
||||
|
@ -368,4 +368,4 @@ def get_talk_speaker_form_class(site):
|
|||
fields = ['name', 'email', 'twitter', 'linkedin', 'github', 'website', 'facebook', 'mastodon', 'phone_number']
|
||||
widget = ModelSelect2MultipleWidget(model=Participant, queryset=Participant.objects.filter(site=site),
|
||||
search_fields=['%s__icontains' % field for field in fields])
|
||||
return modelform_factory(Talk, fields=['speakers'], widgets={'speakers': widget})
|
||||
return modelform_factory(Talk, form=TalkStaffForm, widgets={'speakers': widget})
|
||||
|
|
|
@ -71,16 +71,13 @@
|
|||
<li>
|
||||
<a href="{% url 'participant-details' participant.pk %}">{{ participant }}</a>
|
||||
{% if participant.vip %} <span class="badge">VIP</span>{% endif %}
|
||||
<a href="{% url 'talk-speaker-remove' participant_id=participant.pk talk_id=talk.pk %}" class="btn btn-xs btn-danger"><span class=" glyphicon glyphicon-remove"></span> {% trans "remove" %}</a>
|
||||
</li>
|
||||
{% if forloop.last %}</ul>{% endif %}
|
||||
{% empty %}
|
||||
<i>{% trans "No speakers." %}</i>
|
||||
{% endfor %}
|
||||
|
||||
{% block talk_actions %}
|
||||
<br />
|
||||
<a href="{% url 'talk-speaker-add' talk_id=talk.pk %}" class="btn btn-xs btn-success">{% trans "Add a speaker" %}</a>
|
||||
|
||||
<h3>{% trans "Notes" %}</h3>
|
||||
|
||||
|
@ -132,4 +129,3 @@
|
|||
{% include 'mailing/_message_form.html' %}
|
||||
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -18,3 +18,13 @@
|
|||
{% include '_form.html' with multipart=True %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_end %}
|
||||
{{ block.super }}
|
||||
{{ form.media.js }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{{ block.super }}
|
||||
{{ form.media.css }}
|
||||
{% endblock %}
|
||||
|
|
14
cfp/tests.py
14
cfp/tests.py
|
@ -518,20 +518,6 @@ class StaffTest(TestCase):
|
|||
self.assertEquals(response.status_code, 200)
|
||||
self.assertContains(response, talk.title)
|
||||
|
||||
def test_talk_speaker_remove(self):
|
||||
talk = Talk.objects.get(title='Talk 1')
|
||||
count = talk.speakers.count()
|
||||
to_remove = talk.speakers.first()
|
||||
self.assertTrue(to_remove in talk.speakers.all())
|
||||
url = reverse('talk-speaker-remove', kwargs={'talk_id': talk.pk, 'participant_id': to_remove.pk})
|
||||
self.assertRedirects(self.client.get(url), reverse('login') + '?next=' + url)
|
||||
self.client.login(username='admin', password='admin')
|
||||
response = self.client.get(url)
|
||||
self.assertRedirects(response, reverse('talk-details', kwargs={'talk_id': talk.pk}))
|
||||
talk = Talk.objects.get(title='Talk 1')
|
||||
self.assertEquals(talk.speakers.count() + 1, count)
|
||||
self.assertFalse(to_remove in talk.speakers.all())
|
||||
|
||||
def test_conference(self):
|
||||
conf = Conference.objects.get(name='PonyConf')
|
||||
url = reverse('conference-edit')
|
||||
|
|
|
@ -35,8 +35,6 @@ urlpatterns = [
|
|||
url(r'^staff/talks/(?P<talk_id>[0-9]+)/confirm/$', views.talk_acknowledgment, {'confirm': True}, name='talk-confirm-by-staff'),
|
||||
url(r'^staff/talks/(?P<talk_id>[0-9]+)/desist/$', views.talk_acknowledgment, {'confirm': False}, name='talk-desist-by-staff'),
|
||||
url(r'^staff/talks/(?P<talk_id>[0-9]+)/edit/$', views.TalkUpdate.as_view(), name='talk-edit'),
|
||||
url(r'^staff/talks/(?P<talk_id>[0-9]+)/speaker/add/$', views.talk_speaker_add, name='talk-speaker-add'),
|
||||
url(r'^staff/talks/(?P<talk_id>[0-9]+)/speaker/remove/(?P<participant_id>[0-9]+)/$', views.talk_speaker_remove, name='talk-speaker-remove'),
|
||||
url(r'^staff/speakers/$', views.participant_list, name='participant-list'),
|
||||
url(r'^staff/speakers/add/$', views.ParticipantCreate.as_view(), name='participant-add'),
|
||||
url(r'^staff/speakers/(?P<participant_id>[0-9]+)/$', views.participant_details, name='participant-details'),
|
||||
|
|
31
cfp/views.py
31
cfp/views.py
|
@ -705,30 +705,6 @@ def talk_decide(request, talk_id, accept):
|
|||
})
|
||||
|
||||
|
||||
@staff_required
|
||||
def talk_speaker_add(request, talk_id):
|
||||
talk = get_object_or_404(Talk, pk=talk_id, site=request.conference.site)
|
||||
form = get_talk_speaker_form_class(site=talk.site)(request.POST or None, instance=talk)
|
||||
if request.method == 'POST' and form.is_valid():
|
||||
form.save()
|
||||
messages.success(request, _('Decision taken in account'))
|
||||
return redirect(talk.get_absolute_url())
|
||||
return render(request, 'cfp/staff/talk_speaker_add.html', {
|
||||
'talk': talk,
|
||||
'form': form,
|
||||
})
|
||||
|
||||
|
||||
|
||||
@staff_required
|
||||
def talk_speaker_remove(request, talk_id, participant_id):
|
||||
talk = get_object_or_404(Talk, pk=talk_id, site=request.conference.site)
|
||||
participant = get_object_or_404(Participant, pk=participant_id, site=request.conference.site)
|
||||
talk.speakers.remove(participant)
|
||||
messages.success(request, _('Speaker removed from this talk'))
|
||||
return redirect(talk.get_absolute_url())
|
||||
|
||||
|
||||
@staff_required
|
||||
def participant_list(request):
|
||||
participants = Participant.objects.filter(site=request.conference.site) \
|
||||
|
@ -904,10 +880,11 @@ def homepage_edit(request):
|
|||
|
||||
class TalkUpdate(StaffRequiredMixin, OnSiteMixin, OnSiteFormMixin, UpdateView):
|
||||
model = Talk
|
||||
form_class = TalkStaffForm
|
||||
template_name = 'cfp/staff/talk_form.html'
|
||||
slug_field = 'pk'
|
||||
slug_url_kwarg = 'talk_id'
|
||||
pk_url_kwarg = 'talk_id'
|
||||
|
||||
def get_form_class(self):
|
||||
return get_talk_speaker_form_class(self.object.site)
|
||||
|
||||
|
||||
class TrackMixin(OnSiteMixin):
|
||||
|
|
Loading…
Reference in New Issue