Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.

Commit 6da9c52

Browse files
committed
Add speaker edit views.
1 parent 50b3a03 commit 6da9c52

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

conference/cfp.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,44 @@ def update_proposal(request, talk_uuid):
164164
})
165165

166166

167+
@login_required
168+
def update_speakers(request, talk_uuid):
169+
"""
170+
Update/Edit proposal's speaker(s) view
171+
"""
172+
talk = get_object_or_404(Talk, uuid=talk_uuid)
173+
174+
if not talk.created_by == request.user:
175+
return HttpResponseForbidden()
176+
177+
conf = Conference.objects.current()
178+
if not conf.cfp():
179+
return HttpResponseForbidden()
180+
181+
speaker_form = AddSpeakerToTalkForm(
182+
initial=extract_initial_speaker_data_from_user(request.user)
183+
)
184+
185+
if request.method == 'POST':
186+
speaker_form = AddSpeakerToTalkForm(request.POST)
187+
if speaker_form.is_valid():
188+
with transaction.atomic():
189+
save_information_from_speaker_form(
190+
request.user, speaker_form.cleaned_data
191+
)
192+
193+
messages.success(
194+
request,
195+
"Speaker updated successfully.",
196+
)
197+
return redirect("cfp:preview", talk_slug=talk.slug)
198+
199+
return TemplateResponse(request, "ep19/bs/cfp/update_speakers.html", {
200+
"talk": talk,
201+
"speaker_edit_form": speaker_form,
202+
})
203+
204+
167205
@login_required
168206
def preview_proposal(request, talk_slug):
169207
"""
@@ -433,6 +471,11 @@ def validate_tags(tags):
433471
preview_proposal,
434472
name="preview",
435473
),
474+
url(
475+
r"^update/(?P<talk_uuid>[\w-]+)/speakers/$",
476+
update_speakers,
477+
name="update_speakers",
478+
),
436479
url(
437480
r"^update/(?P<talk_uuid>[\w-]+)/$",
438481
update_proposal,
@@ -444,3 +487,4 @@ def validate_tags(tags):
444487
name="program_wg_download_all_talks",
445488
),
446489
]
490+

templates/ep19/bs/cfp/preview.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ <h3>{{ talk_as_dict.subtitle }}</h3>
3737
<div style='margin-top:5em'>
3838
{% if cfp_is_open and talk.created_by == request.user %}
3939
<a href='{% url "cfp:update" talk.uuid %}' class='btn btn-outline-success'>Update proposal</a>
40+
<a href='{% url "cfp:update_speakers" talk.uuid %}' class='btn btn-outline-success'>Update bio</a>
4041
{% endif %}
4142

4243
{% if user.is_staff %}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{% extends "ep19/bs/base.html" %}
2+
3+
{% load crispy_forms_tags static %}
4+
5+
{% block morecss %}
6+
<link href="{% static "taggit_labels/css/taggit_labels.css" %}" type="text/css" media="all" rel="stylesheet" />
7+
{% endblock %}
8+
9+
{% block morejs %}
10+
<script src="{% static "/js/taggit_labels_customised_with_max_number_of_tags.js" %}"></script>
11+
{% endblock %}
12+
13+
14+
{% block content %}
15+
16+
<div class="container page" id="cfp_page">
17+
<div class="row">
18+
<div class="col-md-12">
19+
<h1>Update the presenter's profile</h1>
20+
</div>
21+
</div>
22+
23+
<div class='row'>
24+
<div class="col-md-6">
25+
<form method='POST' action='.' class='form'>
26+
{% csrf_token %}
27+
{{ speaker_edit_form|crispy }}
28+
29+
<button class="btn btn-success btn-lg btn-block">Update</button>
30+
</form>
31+
</div>
32+
</div>
33+
</div>
34+
{% endblock %}

0 commit comments

Comments
 (0)