diff --git a/cfp/forms.py b/cfp/forms.py
index 0f913c2..0778295 100644
--- a/cfp/forms.py
+++ b/cfp/forms.py
@@ -362,3 +362,18 @@ class VolunteerForm(forms.ModelForm):
class Meta:
model = Volunteer
fields = ['name', 'email', 'phone_number', 'sms_prefered', 'notes']
+
+
+class ParticipantWidget(ModelSelect2MultipleWidget):
+ model = Participant
+ search_fields = [ '%s__icontains' % field for field in ['name', 'email', 'twitter', 'linkedin', 'github',
+ 'website', 'facebook', 'mastodon', 'phone_number' ]]
+
+
+class TalkSpeakerForm(forms.ModelForm):
+ class Meta:
+ model = Talk
+ fields = ['speakers']
+ widgets = {
+ 'speakers': ParticipantWidget(),
+ }
diff --git a/cfp/templates/cfp/staff/talk_details.html b/cfp/templates/cfp/staff/talk_details.html
index aeb8c92..2cffe71 100644
--- a/cfp/templates/cfp/staff/talk_details.html
+++ b/cfp/templates/cfp/staff/talk_details.html
@@ -78,6 +78,10 @@
{% trans "No speakers." %}
{% endfor %}
+{% block talk_actions %}
+
+{% trans "Add a speaker" %}
+
{% trans "Notes" %}
{% if talk.notes %}{{ talk.notes|linebreaksbr }}{% else %}{% trans "No notes." %}{% endif %}
@@ -128,3 +132,4 @@
{% include 'mailing/_message_form.html' %}
{% endblock %}
+{% endblock %}
diff --git a/cfp/templates/cfp/staff/talk_speaker_add.html b/cfp/templates/cfp/staff/talk_speaker_add.html
new file mode 100644
index 0000000..77b3e7a
--- /dev/null
+++ b/cfp/templates/cfp/staff/talk_speaker_add.html
@@ -0,0 +1,26 @@
+{% extends 'cfp/staff/talk_details.html' %}
+{% load i18n crispy_forms_tags %}
+
+{% block talk_actions %}
+
+{% trans "Add a speaker" %}
+
+
+
+
+{% endblock %}
+
+{% block js_end %}
+{{ block.super }}
+{{ form.media.js }}
+{% endblock %}
+
+{% block css %}
+{{ block.super }}
+{{ form.media.css }}
+{% endblock %}
diff --git a/cfp/urls.py b/cfp/urls.py
index b8e93e4..13dd32a 100644
--- a/cfp/urls.py
+++ b/cfp/urls.py
@@ -35,7 +35,7 @@ urlpatterns = [
url(r'^staff/talks/(?P[0-9]+)/confirm/$', views.talk_acknowledgment, {'confirm': True}, name='talk-confirm-by-staff'),
url(r'^staff/talks/(?P[0-9]+)/desist/$', views.talk_acknowledgment, {'confirm': False}, name='talk-desist-by-staff'),
url(r'^staff/talks/(?P[0-9]+)/edit/$', views.TalkUpdate.as_view(), name='talk-edit'),
- # url(r'^staff/talks/(?P[0-9]+)/speaker/add/$', views.talk_speaker_add, name='talk-speaker-add'), TODO WIP
+ url(r'^staff/talks/(?P[0-9]+)/speaker/add/$', views.talk_speaker_add, name='talk-speaker-add'),
url(r'^staff/talks/(?P[0-9]+)/speaker/remove/(?P[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'),
diff --git a/cfp/views.py b/cfp/views.py
index 365882b..0334429 100644
--- a/cfp/views.py
+++ b/cfp/views.py
@@ -26,7 +26,7 @@ from .decorators import speaker_required, volunteer_required, staff_required
from .mixins import StaffRequiredMixin, OnSiteMixin, OnSiteFormMixin
from .utils import is_staff
from .models import Participant, Talk, TalkCategory, Vote, Track, Tag, Room, Volunteer, Activity
-from .forms import TalkForm, TalkStaffForm, TalkFilterForm, TalkActionForm, \
+from .forms import TalkForm, TalkStaffForm, TalkFilterForm, TalkActionForm, TalkSpeakerForm, \
ParticipantForm, ParticipantFilterForm, NotifyForm, \
ConferenceForm, HomepageForm, CreateUserForm, TrackForm, RoomForm, \
VolunteerForm, VolunteerFilterForm, MailForm, \
@@ -705,9 +705,19 @@ def talk_decide(request, talk_id, accept):
})
-# @staff_required TODO WIP
-# def talk_speaker_add(request, talk_id, participant_id=None):
- # talk = get_object_or_404(Talk, token=talk_id, site=request.conference.site)
+@staff_required
+def talk_speaker_add(request, talk_id):
+ talk = get_object_or_404(Talk, pk=talk_id, site=request.conference.site)
+ form = TalkSpeakerForm(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