diff --git a/cfp/templates/cfpdetails.html b/cfp/templates/cfpdetails.html index a1c00c7..822d130 100644 --- a/cfp/templates/cfpdetails.html +++ b/cfp/templates/cfpdetails.html @@ -25,5 +25,8 @@ Scheduled {{ proposal.get_status_display }} {% endif %} state.

+{% if editable %} +Edit +{% endif %} Back {% endblock %} diff --git a/cfp/templates/cfpedit.html b/cfp/templates/cfpedit.html index 8541b6c..7989e01 100644 --- a/cfp/templates/cfpedit.html +++ b/cfp/templates/cfpedit.html @@ -9,7 +9,7 @@

Reviewer notes:

{{ proposal.reviewer_notes }}

{% endif %} -
+ {% endblock %} {% block formfooter %} diff --git a/cfp/urls.py b/cfp/urls.py index 3f0d4ba..233af58 100644 --- a/cfp/urls.py +++ b/cfp/urls.py @@ -18,6 +18,7 @@ from django.conf.urls.defaults import * urlpatterns = patterns('odsreg.cfp.views', (r'^details/(\d+)$', 'details'), + (r'^edit/(\d+)$', 'edit'), (r'^create$', 'create'), (r'^review/(\d+)$', 'review'), (r'^switch/(\d+)$', 'switch'), diff --git a/cfp/views.py b/cfp/views.py index a91e97d..f55891f 100644 --- a/cfp/views.py +++ b/cfp/views.py @@ -89,15 +89,26 @@ def create(request): return render(request, 'cfpcreate.html', {'topics': topics, 'form': form}) +def is_editable(proposal, user): + return ((not proposal.scheduled) and + ((proposal.proposer == user and proposal.status != 'A') or + topiclead(user, proposal.topic))) + + @login_required def details(request, proposalid): proposal = Proposal.objects.get(id=proposalid) - if (proposal.scheduled or - (((proposal.proposer != request.user) or proposal.status == 'A') - and not topiclead(request.user, proposal.topic))): - return render(request, "cfpdetails.html", - {'proposal': proposal, - 'blueprints': linkify(proposal.blueprints)}) + return render(request, "cfpdetails.html", + {'proposal': proposal, + 'editable': is_editable(proposal, request.user), + 'blueprints': linkify(proposal.blueprints)}) + + +@login_required +def edit(request, proposalid): + proposal = Proposal.objects.get(id=proposalid) + if not is_editable(proposal, request.user): + return forbidden() if request.method == 'POST': form = ProposalEditForm(request.POST, instance=proposal) if form.is_valid():