add review message form

This commit is contained in:
Luke Hatcher 2012-08-14 16:52:23 -04:00
parent e00b646f20
commit 7b4c5cd205
2 changed files with 41 additions and 1 deletions

View file

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

View file

@ -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
})