Separate edition from viewing

This commit is contained in:
Thierry Carrez 2013-05-31 16:41:14 +02:00
parent 7fb28f40e6
commit f23100d2b2
4 changed files with 22 additions and 7 deletions

View File

@ -25,5 +25,8 @@ Scheduled
{{ proposal.get_status_display }}
{% endif %}
</b> state.</p>
{% if editable %}
<a class=roundedButton href="/cfp/edit/{{ proposal.id }}">Edit</A>
{% endif %}
<a class=roundedButton href="/{{ request.session.lastlist }}">Back</A>
{% endblock %}

View File

@ -9,7 +9,7 @@
<h4>Reviewer notes:</h4>
<p>{{ proposal.reviewer_notes }}</p>
{% endif %}
<form action="/cfp/details/{{ proposal.id }}" method="post">
<form action="/cfp/edit/{{ proposal.id }}" method="post">
{% endblock %}
{% block formfooter %}
<input id="toggleButton" class="roundedButton" type="submit" value="Modify" />

View File

@ -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'),

View File

@ -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():