Allow nominees to add a comment when accepting or declining. Fixes #1845.

- Legacy-Id: 10589
This commit is contained in:
Robert Sparks 2015-12-14 03:26:43 +00:00
parent 7d120da9ef
commit 9ddcd62c44
4 changed files with 63 additions and 10 deletions

View file

@ -103,7 +103,6 @@ class BaseNomcomForm(object):
continue
yield fieldset_dict
class EditMembersForm(BaseNomcomForm, forms.Form):
members = MultiEmailField(label="Members email", required=False, widget=forms.Textarea)
@ -767,3 +766,7 @@ class EditNomineeForm(forms.ModelForm):
if nominees:
raise forms.ValidationError('This emails already does exists in another nominee, please go to merge form')
return nominee_email
class NominationResponseCommentForm(forms.Form):
comments = forms.CharField(widget=forms.Textarea,required=False,help_text="Any comments provided will be encrytped and will only be visible to the NomCom.")

View file

@ -1198,3 +1198,30 @@ class NewActiveNomComTests(TestCase):
login_testing_unauthorized(self, self.chair.user.username, url)
response = self.client.get(url)
self.assertEqual(response.status_code,200)
def test_accept_reject_nomination_comment(self):
np = self.nc.nominee_set.first().nomineeposition_set.first()
hash = get_hash_nominee_position(np.time.strftime("%Y%m%d"),np.id)
url = reverse('nomcom_process_nomination_status',
kwargs={'year':self.nc.year(),
'nominee_position_id':np.id,
'state':'accepted',
'date':np.time.strftime("%Y%m%d"),
'hash':hash,
}
)
np.state_id='pending'
np.save()
response = self.client.get(url)
self.assertEqual(response.status_code,200)
feedback_count_before = Feedback.objects.count()
response = self.client.post(url,{})
# This view uses Yaco-style POST handling
self.assertEqual(response.status_code,200)
self.assertEqual(Feedback.objects.count(),feedback_count_before)
np.state_id='pending'
np.save()
response = self.client.post(url,{'comments':'A nonempty comment'})
self.assertEqual(response.status_code,200)
self.assertEqual(Feedback.objects.count(),feedback_count_before+1)

View file

@ -4,6 +4,7 @@ from collections import OrderedDict, Counter
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import AnonymousUser
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.http import Http404, HttpResponseRedirect, HttpResponseForbidden
@ -25,7 +26,7 @@ from ietf.nomcom.forms import (NominateForm, FeedbackForm, QuestionnaireForm,
MergeForm, NomComTemplateForm, PositionForm,
PrivateKeyForm, EditNomcomForm, EditNomineeForm,
PendingFeedbackForm, ReminderDatesForm, FullFeedbackFormSet,
FeedbackEmailForm)
FeedbackEmailForm, NominationResponseCommentForm)
from ietf.nomcom.models import Position, NomineePosition, Nominee, Feedback, NomCom, ReminderDates, FeedbackLastSeen
from ietf.nomcom.utils import (get_nomcom_by_year, store_nomcom_private_key,
get_hash_nominee_position, send_reminder_to_nominees,
@ -546,15 +547,34 @@ def process_nomination_status(request, year, nominee_position_id, state, date, h
state = get_object_or_404(NomineePositionStateName, slug=state)
message = ('warning',
("Click on 'Save' to set the state of your nomination to %s to %s (this"+
"is not a final commitment - you can notify us later if you need to change this)") %
" is not a final commitment - you can notify us later if you need to change this).") %
(nominee_position.position.name, state.name))
if request.method == 'POST':
nominee_position.state = state
nominee_position.save()
need_confirmation = False
message = message = ('success', 'Your nomination on %s has been set as %s' % (nominee_position.position.name,
state.name))
form = NominationResponseCommentForm(request.POST)
if form.is_valid():
nominee_position.state = state
nominee_position.save()
need_confirmation = False
if form.cleaned_data['comments']:
# This Feedback object is of type comment instead of nomina in order to not
# make answering "who nominated themselves" harder.
who = request.user
if isinstance(who,AnonymousUser):
who = None
f = Feedback.objects.create(nomcom = nomcom,
author = nominee_position.nominee.email,
subject = '%s nomination %s'%(nominee_position.nominee.name(),state),
comments = form.cleaned_data['comments'],
type_id = 'comment',
user = who,
)
f.positions.add(nominee_position.position)
f.nominees.add(nominee_position.nominee)
message = ('success', 'Your nomination on %s has been set as %s' % (nominee_position.position.name,
state.name))
else:
form = NominationResponseCommentForm()
return render_to_response('nomcom/process_nomination_status.html',
{'message': message,
'nomcom': nomcom,
@ -562,7 +582,8 @@ def process_nomination_status(request, year, nominee_position_id, state, date, h
'nominee_position': nominee_position,
'state': state,
'need_confirmation': need_confirmation,
'selected': 'feedback'}, RequestContext(request))
'selected': 'feedback',
'form': form }, RequestContext(request))
@role_required("Nomcom")

View file

@ -16,6 +16,8 @@
<form method="post">
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button class="btn btn-primary" type="submit">Save</button>
{% endbuttons %}