Introduce generic comments system

Replace reviewers and proposer notes by a set of comments
that can be posted on a proposal.
This commit is contained in:
Thierry Carrez 2013-05-31 17:35:21 +02:00
parent f23100d2b2
commit 80f33dde89
5 changed files with 52 additions and 22 deletions

View File

@ -77,11 +77,6 @@ class Proposal(models.Model):
"blueprint called 'accounting'. You can specify multiple " "blueprint called 'accounting'. You can specify multiple "
"links, separated by spaces. This field is optional.") "links, separated by spaces. This field is optional.")
status = models.CharField(max_length=1, choices=STATUSES) status = models.CharField(max_length=1, choices=STATUSES)
proposer_notes = models.TextField(blank=True,
help_text="Notes from the proposer to the evaluation committee. "
"Those notes will not appear in the public description. "
"This field is optional.")
reviewer_notes = models.TextField(blank=True)
scheduled = models.BooleanField(default=False) scheduled = models.BooleanField(default=False)
last_modified = models.DateTimeField(auto_now=True) last_modified = models.DateTimeField(auto_now=True)
@ -92,23 +87,38 @@ class Proposal(models.Model):
return self.title return self.title
class Comment(models.Model):
proposal = models.ForeignKey(Proposal)
posted_date = models.DateTimeField(auto_now=True)
author = models.ForeignKey(User)
content = models.TextField(verbose_name="Add your comment")
class Meta:
ordering = ['posted_date']
class CommentForm(ModelForm):
class Meta:
model = Comment
exclude = ('proposal', 'posted_date', 'author')
class ProposalForm(ModelForm): class ProposalForm(ModelForm):
class Meta: class Meta:
model = Proposal model = Proposal
exclude = ('proposer', 'reviewer_notes', 'status', 'scheduled') exclude = ('proposer', 'status', 'scheduled')
class ProposalEditForm(ModelForm): class ProposalEditForm(ModelForm):
class Meta: class Meta:
model = Proposal model = Proposal
exclude = ('topic', 'proposer', 'reviewer_notes', 'status', exclude = ('topic', 'proposer', 'status', 'scheduled')
'scheduled')
class ProposalReviewForm(ModelForm): class ProposalReviewForm(ModelForm):
class Meta: class Meta:
model = Proposal model = Proposal
fields = ('status', 'reviewer_notes') fields = ('status',)
class ProposalSwitchForm(ModelForm): class ProposalSwitchForm(ModelForm):

View File

@ -1,9 +1,9 @@
{% extends "base.html" %} {% extends "regform.html" %}
{% block helppage %} {% block helppage %}
<p>This screen lets you see the details of a proposed session.</p> <p>This screen lets you see the details of a proposed session.</p>
<p>Note that you can only edit sessions that you suggested yourself (or if you're the topic lead). Sessions in <i>Preapproved</i> state cannot be changed.</p> <p>Note that you can only edit sessions that you suggested yourself (or if you're the topic lead). Sessions in <i>Preapproved</i> state cannot be changed.</p>
{% endblock %} {% endblock %}
{% block content %} {% block formtitle %}
<h2>{{ proposal.title }}</h2> <h2>{{ proposal.title }}</h2>
<p>Proposed by <b>{{ proposal.proposer }}</b> <p>Proposed by <b>{{ proposal.proposer }}</b>
in topic <b>{{ proposal.topic }}</b></p> in topic <b>{{ proposal.topic }}</b></p>
@ -29,4 +29,17 @@ Scheduled
<a class=roundedButton href="/cfp/edit/{{ proposal.id }}">Edit</A> <a class=roundedButton href="/cfp/edit/{{ proposal.id }}">Edit</A>
{% endif %} {% endif %}
<a class=roundedButton href="/{{ request.session.lastlist }}">Back</A> <a class=roundedButton href="/{{ request.session.lastlist }}">Back</A>
<h4>Comments</h4>
<hr>
{% for comment in comments %}
<p>Comment by {{ comment.author }}
on {{ comment.posted_date|date:"Y-m-d G:i O" }}:<br>
{{ comment.content|linebreaks|urlize }}</p>
<br><hr>
{% endfor %}
<form action="/cfp/details/{{ proposal.id }}" method="post">
{% endblock %}
{% block formfooter %}
<input id="toggleButton" class="roundedButton" type="submit"
value="Add comment" />
{% endblock %} {% endblock %}

View File

@ -5,10 +5,6 @@
{% endblock %} {% endblock %}
{% block formtitle %} {% block formtitle %}
<h2>Edit proposed {{proposal.topic.name}} session</h2> <h2>Edit proposed {{proposal.topic.name}} session</h2>
{% if proposal.reviewer_notes %}
<h4>Reviewer notes:</h4>
<p>{{ proposal.reviewer_notes }}</p>
{% endif %}
<form action="/cfp/edit/{{ proposal.id }}" method="post"> <form action="/cfp/edit/{{ proposal.id }}" method="post">
{% endblock %} {% endblock %}
{% block formfooter %} {% block formfooter %}

View File

@ -28,8 +28,4 @@ in topic <b>{{ proposal.topic }}</b></p>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
{% if proposal.proposer_notes %}
<h4>Proposer notes:</h4>
<p>{{ proposal.proposer_notes }}</p>
{% endif %}
{% endblock %} {% endblock %}

View File

@ -21,8 +21,8 @@ from django.contrib.auth import logout
from django.core.mail import EmailMessage from django.core.mail import EmailMessage
from django.http import HttpResponseRedirect, HttpResponseForbidden from django.http import HttpResponseRedirect, HttpResponseForbidden
from django.utils.encoding import smart_str from django.utils.encoding import smart_str
from odsreg.cfp.models import Proposal, Topic from odsreg.cfp.models import Proposal, Topic, Comment
from odsreg.cfp.models import ProposalForm, ProposalEditForm from odsreg.cfp.models import ProposalForm, ProposalEditForm, CommentForm
from odsreg.cfp.models import ProposalReviewForm, ProposalSwitchForm from odsreg.cfp.models import ProposalReviewForm, ProposalSwitchForm
@ -98,8 +98,21 @@ def is_editable(proposal, user):
@login_required @login_required
def details(request, proposalid): def details(request, proposalid):
proposal = Proposal.objects.get(id=proposalid) proposal = Proposal.objects.get(id=proposalid)
comments = Comment.objects.filter(proposal=proposal)
if request.method == 'POST':
form = CommentForm(request.POST)
if form.is_valid():
comment = form.save(commit=False)
comment.proposal = proposal
comment.author = request.user
comment.save()
return HttpResponseRedirect('/%s' % request.session['lastlist'])
else:
form = CommentForm()
return render(request, "cfpdetails.html", return render(request, "cfpdetails.html",
{'proposal': proposal, {'proposal': proposal,
'form': form,
'comments': comments,
'editable': is_editable(proposal, request.user), 'editable': is_editable(proposal, request.user),
'blueprints': linkify(proposal.blueprints)}) 'blueprints': linkify(proposal.blueprints)})
@ -154,6 +167,8 @@ def switch(request, proposalid):
@login_required @login_required
def review(request, proposalid): def review(request, proposalid):
proposal = Proposal.objects.get(id=proposalid) proposal = Proposal.objects.get(id=proposalid)
#TODO Allow comment while reviewing to be included in email
reviewer_notes = ""
if not topiclead(request.user, proposal.topic): if not topiclead(request.user, proposal.topic):
return forbidden() return forbidden()
current_status = proposal.status current_status = proposal.status
@ -180,7 +195,7 @@ You can edit your proposal at: %s/cfp/edit/%s""" \
smart_str(proposal.title), smart_str(proposal.title),
proposal.topic.lead_username, proposal.topic.lead_username,
status_long, proposal.get_status_display(), status_long, proposal.get_status_display(),
smart_str(proposal.reviewer_notes), smart_str(reviewer_notes),
settings.SITE_ROOT, proposalid) settings.SITE_ROOT, proposalid)
email = EmailMessage(settings.EMAIL_PREFIX + email = EmailMessage(settings.EMAIL_PREFIX +
"Status change on your session proposal", "Status change on your session proposal",