2014-01-15 14:22:16 +00:00
|
|
|
import hashlib
|
2012-07-12 04:38:39 +00:00
|
|
|
import random
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from django.conf import settings
|
2017-03-26 00:50:10 +00:00
|
|
|
from django.contrib.auth.decorators import login_required
|
2017-03-26 01:29:36 +00:00
|
|
|
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
|
2014-02-26 02:36:32 +00:00
|
|
|
from django.core.urlresolvers import reverse
|
2012-07-12 04:38:39 +00:00
|
|
|
from django.db.models import Q
|
|
|
|
from django.http import Http404, HttpResponse, HttpResponseForbidden
|
|
|
|
from django.shortcuts import render, redirect, get_object_or_404
|
|
|
|
from django.views import static
|
|
|
|
|
|
|
|
from django.contrib import messages
|
2012-08-14 20:52:23 +00:00
|
|
|
from django.contrib.auth.models import User
|
2012-07-12 04:38:39 +00:00
|
|
|
|
2015-06-11 16:39:29 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
|
2014-07-05 13:21:49 +00:00
|
|
|
from symposion.proposals.models import (
|
|
|
|
ProposalBase, ProposalSection, ProposalKind
|
|
|
|
)
|
2012-07-12 04:38:39 +00:00
|
|
|
from symposion.proposals.models import SupportingDocument, AdditionalSpeaker
|
|
|
|
from symposion.speakers.models import Speaker
|
|
|
|
from symposion.utils.mail import send_email
|
|
|
|
|
2014-07-05 13:21:49 +00:00
|
|
|
from symposion.proposals.forms import (
|
|
|
|
AddSpeakerForm, SupportingDocumentCreateForm
|
|
|
|
)
|
2012-07-12 04:38:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_form(name):
|
2013-06-11 17:10:29 +00:00
|
|
|
dot = name.rindex(".")
|
2012-07-12 04:38:39 +00:00
|
|
|
mod_name, form_name = name[:dot], name[dot + 1:]
|
|
|
|
__import__(mod_name)
|
|
|
|
return getattr(sys.modules[mod_name], form_name)
|
|
|
|
|
|
|
|
|
|
|
|
def proposal_submit(request):
|
|
|
|
if not request.user.is_authenticated():
|
2015-06-11 16:39:29 +00:00
|
|
|
messages.info(request, _("To submit a proposal, please "
|
|
|
|
"<a href='{0}'>log in</a> and create a speaker profile "
|
|
|
|
"via the dashboard.".format(settings.LOGIN_URL)))
|
2017-09-22 12:28:27 +00:00
|
|
|
return redirect("dashboard") # @@@ unauth'd speaker info page?
|
2012-07-12 04:38:39 +00:00
|
|
|
else:
|
|
|
|
try:
|
|
|
|
request.user.speaker_profile
|
|
|
|
except ObjectDoesNotExist:
|
2014-02-26 02:36:32 +00:00
|
|
|
url = reverse("speaker_create")
|
2015-06-11 16:39:29 +00:00
|
|
|
messages.info(request, _("To submit a proposal, first "
|
|
|
|
"<a href='{0}'>create a speaker "
|
|
|
|
"profile</a>.".format(url)))
|
2012-07-12 04:38:39 +00:00
|
|
|
return redirect("dashboard")
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
kinds = []
|
|
|
|
for proposal_section in ProposalSection.available():
|
|
|
|
for kind in proposal_section.section.proposal_kinds.all():
|
|
|
|
kinds.append(kind)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-10-16 17:36:58 +00:00
|
|
|
return render(request, "symposion/proposals/proposal_submit.html", {
|
2012-07-12 04:38:39 +00:00
|
|
|
"kinds": kinds,
|
|
|
|
})
|
|
|
|
|
2017-10-16 04:07:36 +00:00
|
|
|
@login_required
|
2012-07-12 04:38:39 +00:00
|
|
|
def proposal_submit_kind(request, kind_slug):
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
kind = get_object_or_404(ProposalKind, slug=kind_slug)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2017-10-16 04:07:36 +00:00
|
|
|
try:
|
|
|
|
speaker_profile = request.user.speaker_profile
|
|
|
|
except ObjectDoesNotExist:
|
|
|
|
return redirect("speaker_create")
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-08-14 21:09:51 +00:00
|
|
|
if not kind.section.proposalsection.is_available():
|
|
|
|
return redirect("proposal_submit")
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
form_class = get_form(settings.PROPOSAL_FORMS[kind_slug])
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
if request.method == "POST":
|
|
|
|
form = form_class(request.POST)
|
|
|
|
if form.is_valid():
|
|
|
|
proposal = form.save(commit=False)
|
|
|
|
proposal.kind = kind
|
|
|
|
proposal.speaker = speaker_profile
|
|
|
|
proposal.save()
|
|
|
|
form.save_m2m()
|
2015-06-26 03:46:09 +00:00
|
|
|
messages.success(request, _("Proposal submitted."))
|
2012-07-12 04:38:39 +00:00
|
|
|
if "add-speakers" in request.POST:
|
|
|
|
return redirect("proposal_speaker_manage", proposal.pk)
|
|
|
|
return redirect("dashboard")
|
|
|
|
else:
|
|
|
|
form = form_class()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-10-16 17:36:58 +00:00
|
|
|
return render(request, "symposion/proposals/proposal_submit_kind.html", {
|
2012-07-12 04:38:39 +00:00
|
|
|
"kind": kind,
|
2015-10-16 17:36:58 +00:00
|
|
|
"proposal_form": form,
|
2012-07-12 04:38:39 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
def proposal_speaker_manage(request, pk):
|
|
|
|
queryset = ProposalBase.objects.select_related("speaker")
|
|
|
|
proposal = get_object_or_404(queryset, pk=pk)
|
|
|
|
proposal = ProposalBase.objects.get_subclass(pk=proposal.pk)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
if proposal.speaker != request.user.speaker_profile:
|
|
|
|
raise Http404()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
if request.method == "POST":
|
|
|
|
add_speaker_form = AddSpeakerForm(request.POST, proposal=proposal)
|
|
|
|
if add_speaker_form.is_valid():
|
|
|
|
message_ctx = {
|
|
|
|
"proposal": proposal,
|
|
|
|
}
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
def create_speaker_token(email_address):
|
|
|
|
# create token and look for an existing speaker to prevent
|
|
|
|
# duplicate tokens and confusing the pending speaker
|
|
|
|
try:
|
|
|
|
pending = Speaker.objects.get(
|
|
|
|
Q(user=None, invite_email=email_address)
|
|
|
|
)
|
|
|
|
except Speaker.DoesNotExist:
|
2017-05-07 06:17:06 +00:00
|
|
|
salt = hashlib.sha1(str(random.random()).encode('UTF-8')).hexdigest()[:5]
|
|
|
|
saltedemail = (salt + email_address).encode('UTF-8')
|
|
|
|
token = hashlib.sha1(saltedemail).hexdigest()
|
2012-07-12 04:38:39 +00:00
|
|
|
pending = Speaker.objects.create(
|
|
|
|
invite_email=email_address,
|
|
|
|
invite_token=token,
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
token = pending.invite_token
|
|
|
|
return pending, token
|
|
|
|
email_address = add_speaker_form.cleaned_data["email"]
|
|
|
|
# check if email is on the site now
|
2017-03-26 01:29:36 +00:00
|
|
|
try:
|
|
|
|
user = User.objects.get(email=email_address)
|
2017-04-02 01:49:12 +00:00
|
|
|
except ObjectDoesNotExist:
|
|
|
|
user = None
|
2017-03-26 01:29:36 +00:00
|
|
|
except MultipleObjectsReturned:
|
|
|
|
# FIXME: This is not handled in the previous code, so I'm not
|
|
|
|
# going to frett on this now, but should be handled as it is
|
|
|
|
# an occourance that really, really shouldn't occour.
|
|
|
|
# Previously, code took [0] from the list and continued.
|
|
|
|
raise NotImplementedError("Non unique email should not occour")
|
|
|
|
if user:
|
2012-07-12 04:38:39 +00:00
|
|
|
# should only be one since we enforce unique email
|
|
|
|
message_ctx["user"] = user
|
|
|
|
# look for speaker profile
|
|
|
|
try:
|
|
|
|
speaker = user.speaker_profile
|
|
|
|
except ObjectDoesNotExist:
|
|
|
|
speaker, token = create_speaker_token(email_address)
|
|
|
|
message_ctx["token"] = token
|
|
|
|
# fire off email to user to create profile
|
|
|
|
send_email(
|
|
|
|
[email_address], "speaker_no_profile",
|
2014-07-30 18:19:26 +00:00
|
|
|
context=message_ctx
|
2012-07-12 04:38:39 +00:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
# fire off email to user letting them they are loved.
|
|
|
|
send_email(
|
|
|
|
[email_address], "speaker_addition",
|
2014-07-30 18:19:26 +00:00
|
|
|
context=message_ctx
|
2012-07-12 04:38:39 +00:00
|
|
|
)
|
|
|
|
else:
|
|
|
|
speaker, token = create_speaker_token(email_address)
|
|
|
|
message_ctx["token"] = token
|
|
|
|
# fire off email letting user know about site and to create
|
|
|
|
# account and speaker profile
|
|
|
|
send_email(
|
|
|
|
[email_address], "speaker_invite",
|
2014-07-30 18:19:26 +00:00
|
|
|
context=message_ctx
|
2012-07-12 04:38:39 +00:00
|
|
|
)
|
2014-07-30 18:19:26 +00:00
|
|
|
invitation, created = AdditionalSpeaker.objects.get_or_create(
|
|
|
|
proposalbase=proposal.proposalbase_ptr, speaker=speaker)
|
2012-07-12 04:38:39 +00:00
|
|
|
messages.success(request, "Speaker invited to proposal.")
|
|
|
|
return redirect("proposal_speaker_manage", proposal.pk)
|
|
|
|
else:
|
|
|
|
add_speaker_form = AddSpeakerForm(proposal=proposal)
|
|
|
|
ctx = {
|
|
|
|
"proposal": proposal,
|
|
|
|
"speakers": proposal.speakers(),
|
|
|
|
"add_speaker_form": add_speaker_form,
|
|
|
|
}
|
2015-10-16 17:36:58 +00:00
|
|
|
return render(request, "symposion/proposals/proposal_speaker_manage.html", ctx)
|
2012-07-12 04:38:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
def proposal_edit(request, pk):
|
|
|
|
queryset = ProposalBase.objects.select_related("speaker")
|
|
|
|
proposal = get_object_or_404(queryset, pk=pk)
|
|
|
|
proposal = ProposalBase.objects.get_subclass(pk=proposal.pk)
|
|
|
|
|
|
|
|
if request.user != proposal.speaker.user:
|
|
|
|
raise Http404()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
if not proposal.can_edit():
|
|
|
|
ctx = {
|
|
|
|
"title": "Proposal editing closed",
|
|
|
|
"body": "Proposal editing is closed for this session type."
|
|
|
|
}
|
2015-10-16 17:36:58 +00:00
|
|
|
return render(request, "symposion/proposals/proposal_error.html", ctx)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
form_class = get_form(settings.PROPOSAL_FORMS[proposal.kind.slug])
|
|
|
|
|
|
|
|
if request.method == "POST":
|
|
|
|
form = form_class(request.POST, instance=proposal)
|
|
|
|
if form.is_valid():
|
|
|
|
form.save()
|
2012-08-27 18:12:19 +00:00
|
|
|
if hasattr(proposal, "reviews"):
|
2016-09-27 09:21:57 +00:00
|
|
|
# Miniconf updates should only email the admins
|
|
|
|
if proposal.kind.slug == 'miniconf':
|
|
|
|
users = User.objects.filter(username__in=settings.ADMIN_USERNAMES)
|
|
|
|
else:
|
|
|
|
users = User.objects.filter(
|
|
|
|
Q(review__proposal=proposal) |
|
|
|
|
Q(proposalmessage__proposal=proposal)
|
|
|
|
)
|
2012-08-30 18:10:32 +00:00
|
|
|
users = users.exclude(id=request.user.id).distinct()
|
|
|
|
for user in users:
|
2012-08-27 18:12:19 +00:00
|
|
|
ctx = {
|
|
|
|
"user": request.user,
|
|
|
|
"proposal": proposal,
|
|
|
|
}
|
|
|
|
send_email(
|
2012-08-30 18:10:32 +00:00
|
|
|
[user.email], "proposal_updated",
|
2012-08-27 18:12:19 +00:00
|
|
|
context=ctx
|
|
|
|
)
|
2012-07-12 04:38:39 +00:00
|
|
|
messages.success(request, "Proposal updated.")
|
|
|
|
return redirect("proposal_detail", proposal.pk)
|
|
|
|
else:
|
|
|
|
form = form_class(instance=proposal)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-10-16 17:36:58 +00:00
|
|
|
return render(request, "symposion/proposals/proposal_edit.html", {
|
2012-07-12 04:38:39 +00:00
|
|
|
"proposal": proposal,
|
|
|
|
"form": form,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
def proposal_detail(request, pk):
|
|
|
|
queryset = ProposalBase.objects.select_related("speaker", "speaker__user")
|
|
|
|
proposal = get_object_or_404(queryset, pk=pk)
|
|
|
|
proposal = ProposalBase.objects.get_subclass(pk=proposal.pk)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
if request.user not in [p.user for p in proposal.speakers()]:
|
|
|
|
raise Http404()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-08-14 20:52:23 +00:00
|
|
|
if "symposion.reviews" in settings.INSTALLED_APPS:
|
|
|
|
from symposion.reviews.forms import SpeakerCommentForm
|
|
|
|
message_form = SpeakerCommentForm()
|
|
|
|
if request.method == "POST":
|
|
|
|
message_form = SpeakerCommentForm(request.POST)
|
|
|
|
if message_form.is_valid():
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-08-14 20:52:23 +00:00
|
|
|
message = message_form.save(commit=False)
|
|
|
|
message.user = request.user
|
|
|
|
message.proposal = proposal
|
|
|
|
message.save()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-08-14 20:52:23 +00:00
|
|
|
ProposalMessage = SpeakerCommentForm.Meta.model
|
|
|
|
reviewers = User.objects.filter(
|
|
|
|
id__in=ProposalMessage.objects.filter(
|
|
|
|
proposal=proposal
|
|
|
|
).exclude(
|
|
|
|
user=request.user
|
|
|
|
).distinct().values_list("user", flat=True)
|
|
|
|
)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-08-14 20:52:23 +00:00
|
|
|
for reviewer in reviewers:
|
|
|
|
ctx = {
|
|
|
|
"proposal": proposal,
|
|
|
|
"message": message,
|
|
|
|
"reviewer": True,
|
|
|
|
}
|
|
|
|
send_email(
|
|
|
|
[reviewer.email], "proposal_new_message",
|
|
|
|
context=ctx
|
|
|
|
)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-08-14 20:52:23 +00:00
|
|
|
return redirect(request.path)
|
|
|
|
else:
|
|
|
|
message_form = SpeakerCommentForm()
|
|
|
|
else:
|
|
|
|
message_form = None
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-10-16 17:36:58 +00:00
|
|
|
return render(request, "symposion/proposals/proposal_detail.html", {
|
2012-07-12 04:38:39 +00:00
|
|
|
"proposal": proposal,
|
2012-08-14 20:52:23 +00:00
|
|
|
"message_form": message_form
|
2012-07-12 04:38:39 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
def proposal_cancel(request, pk):
|
|
|
|
queryset = ProposalBase.objects.select_related("speaker")
|
|
|
|
proposal = get_object_or_404(queryset, pk=pk)
|
|
|
|
proposal = ProposalBase.objects.get_subclass(pk=proposal.pk)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
if proposal.speaker.user != request.user:
|
|
|
|
return HttpResponseForbidden()
|
|
|
|
|
|
|
|
if request.method == "POST":
|
|
|
|
proposal.cancelled = True
|
|
|
|
proposal.save()
|
|
|
|
# @@@ fire off email to submitter and other speakers
|
|
|
|
messages.success(request, "%s has been cancelled" % proposal.title)
|
|
|
|
return redirect("dashboard")
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-10-16 17:36:58 +00:00
|
|
|
return render(request, "symposion/proposals/proposal_cancel.html", {
|
2012-07-12 04:38:39 +00:00
|
|
|
"proposal": proposal,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
def proposal_leave(request, pk):
|
|
|
|
queryset = ProposalBase.objects.select_related("speaker")
|
|
|
|
proposal = get_object_or_404(queryset, pk=pk)
|
|
|
|
proposal = ProposalBase.objects.get_subclass(pk=proposal.pk)
|
|
|
|
|
|
|
|
try:
|
|
|
|
speaker = proposal.additional_speakers.get(user=request.user)
|
|
|
|
except ObjectDoesNotExist:
|
|
|
|
return HttpResponseForbidden()
|
|
|
|
if request.method == "POST":
|
|
|
|
proposal.additional_speakers.remove(speaker)
|
|
|
|
# @@@ fire off email to submitter and other speakers
|
|
|
|
messages.success(request, "You are no longer speaking on %s" % proposal.title)
|
2012-08-14 20:52:32 +00:00
|
|
|
return redirect("dashboard")
|
2012-07-12 04:38:39 +00:00
|
|
|
ctx = {
|
|
|
|
"proposal": proposal,
|
|
|
|
}
|
2015-10-16 17:36:58 +00:00
|
|
|
return render(request, "symposion/proposals/proposal_leave.html", ctx)
|
2012-07-12 04:38:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
def proposal_pending_join(request, pk):
|
|
|
|
proposal = get_object_or_404(ProposalBase, pk=pk)
|
2014-07-30 18:19:26 +00:00
|
|
|
speaking = get_object_or_404(AdditionalSpeaker, speaker=request.user.speaker_profile,
|
|
|
|
proposalbase=proposal)
|
2012-07-12 04:38:39 +00:00
|
|
|
if speaking.status == AdditionalSpeaker.SPEAKING_STATUS_PENDING:
|
|
|
|
speaking.status = AdditionalSpeaker.SPEAKING_STATUS_ACCEPTED
|
|
|
|
speaking.save()
|
|
|
|
messages.success(request, "You have accepted the invitation to join %s" % proposal.title)
|
|
|
|
return redirect("dashboard")
|
|
|
|
else:
|
|
|
|
return redirect("dashboard")
|
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
def proposal_pending_decline(request, pk):
|
|
|
|
proposal = get_object_or_404(ProposalBase, pk=pk)
|
2014-07-30 18:19:26 +00:00
|
|
|
speaking = get_object_or_404(AdditionalSpeaker, speaker=request.user.speaker_profile,
|
|
|
|
proposalbase=proposal)
|
2012-07-12 04:38:39 +00:00
|
|
|
if speaking.status == AdditionalSpeaker.SPEAKING_STATUS_PENDING:
|
|
|
|
speaking.status = AdditionalSpeaker.SPEAKING_STATUS_DECLINED
|
|
|
|
speaking.save()
|
|
|
|
messages.success(request, "You have declined to speak on %s" % proposal.title)
|
|
|
|
return redirect("dashboard")
|
|
|
|
else:
|
|
|
|
return redirect("dashboard")
|
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
def document_create(request, proposal_pk):
|
|
|
|
queryset = ProposalBase.objects.select_related("speaker")
|
|
|
|
proposal = get_object_or_404(queryset, pk=proposal_pk)
|
|
|
|
proposal = ProposalBase.objects.get_subclass(pk=proposal.pk)
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-18 23:22:29 +00:00
|
|
|
if proposal.cancelled:
|
|
|
|
return HttpResponseForbidden()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
if request.method == "POST":
|
|
|
|
form = SupportingDocumentCreateForm(request.POST, request.FILES)
|
|
|
|
if form.is_valid():
|
|
|
|
document = form.save(commit=False)
|
|
|
|
document.proposal = proposal
|
|
|
|
document.uploaded_by = request.user
|
|
|
|
document.save()
|
|
|
|
return redirect("proposal_detail", proposal.pk)
|
|
|
|
else:
|
|
|
|
form = SupportingDocumentCreateForm()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2015-10-16 17:36:58 +00:00
|
|
|
return render(request, "symposion/proposals/document_create.html", {
|
2012-07-12 04:38:39 +00:00
|
|
|
"proposal": proposal,
|
|
|
|
"form": form,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
def document_download(request, pk, *args):
|
|
|
|
document = get_object_or_404(SupportingDocument, pk=pk)
|
2012-07-18 23:21:50 +00:00
|
|
|
if getattr(settings, "USE_X_ACCEL_REDIRECT", False):
|
2012-07-12 04:38:39 +00:00
|
|
|
response = HttpResponse()
|
|
|
|
response["X-Accel-Redirect"] = document.file.url
|
|
|
|
# delete content-type to allow Gondor to determine the filetype and
|
|
|
|
# we definitely don't want Django's crappy default :-)
|
|
|
|
del response["content-type"]
|
|
|
|
else:
|
|
|
|
response = static.serve(request, document.file.name, document_root=settings.MEDIA_ROOT)
|
|
|
|
return response
|
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
def document_delete(request, pk):
|
|
|
|
document = get_object_or_404(SupportingDocument, pk=pk, uploaded_by=request.user)
|
|
|
|
proposal_pk = document.proposal.pk
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
if request.method == "POST":
|
|
|
|
document.delete()
|
2014-07-30 18:19:26 +00:00
|
|
|
|
2012-07-12 04:38:39 +00:00
|
|
|
return redirect("proposal_detail", proposal_pk)
|