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

Add speaker edit view (fix #932) #934

Merged
merged 3 commits into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions conference/cfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,44 @@ def update_proposal(request, talk_uuid):
})


@login_required
def update_speakers(request, talk_uuid):
"""
Update/Edit proposal's speaker(s) view
"""
talk = get_object_or_404(Talk, uuid=talk_uuid)

if not talk.created_by == request.user:
return HttpResponseForbidden()

conf = Conference.objects.current()
if not conf.cfp():
return HttpResponseForbidden()

speaker_form = UpdateAttendeeProfile(
initial=extract_initial_speaker_data_from_user(request.user)
)

if request.method == 'POST':
speaker_form = UpdateAttendeeProfile(request.POST)
if speaker_form.is_valid():
with transaction.atomic():
save_information_from_speaker_form(
request.user, speaker_form.cleaned_data
)

messages.success(
request,
"Speaker updated successfully.",
)
return redirect("cfp:preview", talk_slug=talk.slug)

return TemplateResponse(request, "ep19/bs/cfp/update_speakers.html", {
"talk": talk,
"speaker_edit_form": speaker_form,
})


@login_required
def preview_proposal(request, talk_slug):
"""
Expand Down Expand Up @@ -333,6 +371,10 @@ class Meta:
]


class UpdateAttendeeProfile(AddSpeakerToTalkForm):
pass


class ProposalForm(forms.ModelForm):

type = forms.ChoiceField(
Expand Down Expand Up @@ -433,6 +475,11 @@ def validate_tags(tags):
preview_proposal,
name="preview",
),
url(
r"^update/(?P<talk_uuid>[\w-]+)/speakers/$",
update_speakers,
name="update_speakers",
),
url(
r"^update/(?P<talk_uuid>[\w-]+)/$",
update_proposal,
Expand All @@ -444,3 +491,4 @@ def validate_tags(tags):
name="program_wg_download_all_talks",
),
]

1 change: 1 addition & 0 deletions templates/ep19/bs/cfp/preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ <h3>{{ talk_as_dict.subtitle }}</h3>
<div style='margin-top:5em'>
{% if cfp_is_open and talk.created_by == request.user %}
<a href='{% url "cfp:update" talk.uuid %}' class='btn btn-outline-success'>Update proposal</a>
<a href='{% url "cfp:update_speakers" talk.uuid %}' class='btn btn-outline-success'>Update bio</a>
{% endif %}

{% if user.is_staff %}
Expand Down
25 changes: 25 additions & 0 deletions templates/ep19/bs/cfp/update_speakers.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% extends "ep19/bs/base.html" %}

{% load crispy_forms_tags static %}


{% block content %}
<div class="container page" id="cfp_page">
<div class="row">
<div class="col-md-12">
<h1>Update the presenter's profile</h1>
</div>
</div>

<div class='row'>
<div class="col-md-6">
<form method='POST' action='.' class='form'>
{% csrf_token %}
{{ speaker_edit_form|crispy }}

<button class="btn btn-success btn-lg btn-block">Update</button>
</form>
</div>
</div>
</div>
{% endblock %}
Loading