Skip to content

Commit 9ddcd62

Browse files
committed
Allow nominees to add a comment when accepting or declining. Fixes ietf-tools#1845.
- Legacy-Id: 10589
1 parent 7d120da commit 9ddcd62

4 files changed

Lines changed: 63 additions & 10 deletions

File tree

ietf/nomcom/forms.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def get_fieldsets(self):
103103
continue
104104
yield fieldset_dict
105105

106-
107106
class EditMembersForm(BaseNomcomForm, forms.Form):
108107

109108
members = MultiEmailField(label="Members email", required=False, widget=forms.Textarea)
@@ -767,3 +766,7 @@ def clean_nominee_email(self):
767766
if nominees:
768767
raise forms.ValidationError('This emails already does exists in another nominee, please go to merge form')
769768
return nominee_email
769+
770+
class NominationResponseCommentForm(forms.Form):
771+
comments = forms.CharField(widget=forms.Textarea,required=False,help_text="Any comments provided will be encrytped and will only be visible to the NomCom.")
772+

ietf/nomcom/tests.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,3 +1198,30 @@ def test_help(self):
11981198
login_testing_unauthorized(self, self.chair.user.username, url)
11991199
response = self.client.get(url)
12001200
self.assertEqual(response.status_code,200)
1201+
1202+
def test_accept_reject_nomination_comment(self):
1203+
np = self.nc.nominee_set.first().nomineeposition_set.first()
1204+
hash = get_hash_nominee_position(np.time.strftime("%Y%m%d"),np.id)
1205+
url = reverse('nomcom_process_nomination_status',
1206+
kwargs={'year':self.nc.year(),
1207+
'nominee_position_id':np.id,
1208+
'state':'accepted',
1209+
'date':np.time.strftime("%Y%m%d"),
1210+
'hash':hash,
1211+
}
1212+
)
1213+
np.state_id='pending'
1214+
np.save()
1215+
response = self.client.get(url)
1216+
self.assertEqual(response.status_code,200)
1217+
feedback_count_before = Feedback.objects.count()
1218+
response = self.client.post(url,{})
1219+
# This view uses Yaco-style POST handling
1220+
self.assertEqual(response.status_code,200)
1221+
self.assertEqual(Feedback.objects.count(),feedback_count_before)
1222+
np.state_id='pending'
1223+
np.save()
1224+
response = self.client.post(url,{'comments':'A nonempty comment'})
1225+
self.assertEqual(response.status_code,200)
1226+
self.assertEqual(Feedback.objects.count(),feedback_count_before+1)
1227+

ietf/nomcom/views.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from django.conf import settings
66
from django.contrib.auth.decorators import login_required
7+
from django.contrib.auth.models import AnonymousUser
78
from django.contrib import messages
89
from django.core.urlresolvers import reverse
910
from django.http import Http404, HttpResponseRedirect, HttpResponseForbidden
@@ -25,7 +26,7 @@
2526
MergeForm, NomComTemplateForm, PositionForm,
2627
PrivateKeyForm, EditNomcomForm, EditNomineeForm,
2728
PendingFeedbackForm, ReminderDatesForm, FullFeedbackFormSet,
28-
FeedbackEmailForm)
29+
FeedbackEmailForm, NominationResponseCommentForm)
2930
from ietf.nomcom.models import Position, NomineePosition, Nominee, Feedback, NomCom, ReminderDates, FeedbackLastSeen
3031
from ietf.nomcom.utils import (get_nomcom_by_year, store_nomcom_private_key,
3132
get_hash_nominee_position, send_reminder_to_nominees,
@@ -546,23 +547,43 @@ def process_nomination_status(request, year, nominee_position_id, state, date, h
546547
state = get_object_or_404(NomineePositionStateName, slug=state)
547548
message = ('warning',
548549
("Click on 'Save' to set the state of your nomination to %s to %s (this"+
549-
"is not a final commitment - you can notify us later if you need to change this)") %
550+
" is not a final commitment - you can notify us later if you need to change this).") %
550551
(nominee_position.position.name, state.name))
551552
if request.method == 'POST':
552-
nominee_position.state = state
553-
nominee_position.save()
554-
need_confirmation = False
555-
message = message = ('success', 'Your nomination on %s has been set as %s' % (nominee_position.position.name,
556-
state.name))
557-
553+
form = NominationResponseCommentForm(request.POST)
554+
if form.is_valid():
555+
nominee_position.state = state
556+
nominee_position.save()
557+
need_confirmation = False
558+
if form.cleaned_data['comments']:
559+
# This Feedback object is of type comment instead of nomina in order to not
560+
# make answering "who nominated themselves" harder.
561+
who = request.user
562+
if isinstance(who,AnonymousUser):
563+
who = None
564+
f = Feedback.objects.create(nomcom = nomcom,
565+
author = nominee_position.nominee.email,
566+
subject = '%s nomination %s'%(nominee_position.nominee.name(),state),
567+
comments = form.cleaned_data['comments'],
568+
type_id = 'comment',
569+
user = who,
570+
)
571+
f.positions.add(nominee_position.position)
572+
f.nominees.add(nominee_position.nominee)
573+
574+
message = ('success', 'Your nomination on %s has been set as %s' % (nominee_position.position.name,
575+
state.name))
576+
else:
577+
form = NominationResponseCommentForm()
558578
return render_to_response('nomcom/process_nomination_status.html',
559579
{'message': message,
560580
'nomcom': nomcom,
561581
'year': year,
562582
'nominee_position': nominee_position,
563583
'state': state,
564584
'need_confirmation': need_confirmation,
565-
'selected': 'feedback'}, RequestContext(request))
585+
'selected': 'feedback',
586+
'form': form }, RequestContext(request))
566587

567588

568589
@role_required("Nomcom")

ietf/templates/nomcom/process_nomination_status.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
<form method="post">
1717
{% csrf_token %}
1818

19+
{% bootstrap_form form %}
20+
1921
{% buttons %}
2022
<button class="btn btn-primary" type="submit">Save</button>
2123
{% endbuttons %}

0 commit comments

Comments
 (0)