diff --git a/symposion/proposals/models.py b/symposion/proposals/models.py index 6d1603c3..7695f341 100644 --- a/symposion/proposals/models.py +++ b/symposion/proposals/models.py @@ -33,7 +33,7 @@ class ProposalSection(models.Model): start = models.DateTimeField(null=True, blank=True) end = models.DateTimeField(null=True, blank=True) closed = models.NullBooleanField() - published = models.NullBooleanField() # @@@ what is this used for? + published = models.NullBooleanField() @classmethod def available(cls): diff --git a/symposion/proposals/views.py b/symposion/proposals/views.py index 8cfdfa04..7fd62dcc 100644 --- a/symposion/proposals/views.py +++ b/symposion/proposals/views.py @@ -10,6 +10,7 @@ from django.utils.hashcompat import sha_constructor from django.views import static from django.contrib import messages +from django.contrib.auth.models import User from django.contrib.auth.decorators import login_required from account.models import EmailAddress @@ -206,8 +207,47 @@ def proposal_detail(request, pk): if request.user not in [p.user for p in proposal.speakers()]: raise Http404() + 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(): + + message = message_form.save(commit=False) + message.user = request.user + message.proposal = proposal + message.save() + + 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) + ) + + for reviewer in reviewers: + ctx = { + "proposal": proposal, + "message": message, + "reviewer": True, + } + send_email( + [reviewer.email], "proposal_new_message", + context=ctx + ) + + return redirect(request.path) + else: + message_form = SpeakerCommentForm() + else: + message_form = None + return render(request, "proposals/proposal_detail.html", { "proposal": proposal, + "message_form": message_form })