Skip to content

Commit 00e5762

Browse files
committed
Simplify the nomcom feedback comment form. Make that more obvious who receives mail when that form is used. Fixes ietf-tools#1849.
- Legacy-Id: 10501
1 parent bb3424f commit 00e5762

4 files changed

Lines changed: 43 additions & 69 deletions

File tree

ietf/nomcom/forms.py

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def save(self):
325325
class NominateForm(BaseNomcomForm, forms.ModelForm):
326326
comments = forms.CharField(label="Candidate's qualifications for the position",
327327
widget=forms.Textarea())
328-
confirmation = forms.BooleanField(label='Email comments back to me as confirmation',
328+
confirmation = forms.BooleanField(label='Email comments back to me as confirmation.',
329329
help_text="If you want to get a confirmation mail containing your feedback in cleartext, please check the 'email comments back to me as confirmation'.",
330330
required=False)
331331

@@ -430,18 +430,11 @@ class Meta:
430430

431431

432432
class FeedbackForm(BaseNomcomForm, forms.ModelForm):
433-
position_name = forms.CharField(label='Position',
434-
widget=forms.TextInput(attrs={'size': '40'}))
435-
nominee_name = forms.CharField(label='Nominee name',
436-
widget=forms.TextInput(attrs={'size': '40'}))
437-
nominee_email = forms.CharField(label='Nominee email',
438-
widget=forms.TextInput(attrs={'size': '40'}))
439-
nominator_email = forms.CharField(label='Commenter email')
440-
441-
comments = forms.CharField(label='Comments on this nominee',
433+
nominator_email = forms.CharField(label='Commenter email',required=False)
434+
435+
comments = forms.CharField(label='Comments',
442436
widget=forms.Textarea())
443-
confirmation = forms.BooleanField(label='Email comments back to me as confirmation',
444-
help_text="If you want to get a confirmation mail containing your feedback in cleartext, please check the 'email comments back to me as confirmation'.",
437+
confirmation = forms.BooleanField(label='Email comments back to me as confirmation (if selected, your comments will be emailed to you in cleartext when you press Save).',
445438
required=False)
446439

447440
def __init__(self, *args, **kwargs):
@@ -453,66 +446,38 @@ def __init__(self, *args, **kwargs):
453446

454447
super(FeedbackForm, self).__init__(*args, **kwargs)
455448

456-
readonly_fields = ['position_name',
457-
'nominee_name',
458-
'nominee_email']
459-
460-
fieldset = ['position_name',
461-
'nominee_name',
462-
'nominee_email',
463-
'nominator_email',
464-
'comments']
449+
author = get_user_email(self.user)
465450

466451
if self.public:
467-
readonly_fields += ['nominator_email']
468-
fieldset.append('confirmation')
452+
self.fields.pop('nominator_email')
469453
else:
470454
help_text = """(Nomcom Chair/Member: please fill this in. Use your own email address if the person making the
471455
comments wishes to be anonymous. The confirmation email will be sent to the address given here,
472456
and the address will also be captured as part of the registered nomination.)"""
473457
self.fields['nominator_email'].help_text = help_text
474-
self.fields['nominator_email'].required = False
475-
476-
author = get_user_email(self.user)
477-
if author:
478-
self.fields['nominator_email'].initial = author.address
479-
480-
if self.position and self.nominee:
481-
self.fields['position_name'].initial = self.position.name
482-
self.fields['nominee_name'].initial = self.nominee.email.person.name
483-
self.fields['nominee_email'].initial = self.nominee.email.address
484-
else:
485-
help_text = "Please pick a name on the nominees list"
486-
self.fields['position_name'].initial = help_text
487-
self.fields['nominee_name'].initial = help_text
488-
self.fields['nominee_email'].initial = help_text
489-
self.fields['comments'].initial = help_text
490-
readonly_fields += ['comments']
491-
self.fields['confirmation'].widget.attrs['disabled'] = "disabled"
492-
493-
for field in readonly_fields:
494-
self.fields[field].widget.attrs['readonly'] = True
458+
self.fields['confirmation'].label = 'Email these comments in cleartext to the provided commenter email address'
459+
if author:
460+
self.fields['nominator_email'].initial = author.address
495461

496-
self.fieldsets = [('Provide comments', fieldset)]
497462

498463
def clean(self):
499464
if not NomineePosition.objects.accepted().filter(nominee=self.nominee,
500465
position=self.position):
501466
msg = "There isn't a accepted nomination for %s on the %s position" % (self.nominee, self.position)
502-
self._errors["nominee_email"] = self.error_class([msg])
467+
self._errors["comments"] = self.error_class([msg])
503468
return self.cleaned_data
504469

505470
def save(self, commit=True):
506471
feedback = super(FeedbackForm, self).save(commit=False)
507472
confirmation = self.cleaned_data['confirmation']
508473
comments = self.cleaned_data['comments']
509-
nominator_email = self.cleaned_data['nominator_email']
510474
nomcom_template_path = '/nomcom/%s/' % self.nomcom.group.acronym
511475

512476
author = None
513477
if self.public:
514478
author = get_user_email(self.user)
515479
else:
480+
nominator_email = self.cleaned_data['nominator_email']
516481
if nominator_email:
517482
emails = Email.objects.filter(address=nominator_email)
518483
author = emails and emails[0] or None
@@ -541,11 +506,11 @@ def save(self, commit=True):
541506

542507
class Meta:
543508
model = Feedback
544-
fields = ('nominee_name',
545-
'nominee_email',
509+
fields = (
546510
'nominator_email',
511+
'comments',
547512
'confirmation',
548-
'comments')
513+
)
549514

550515
class FeedbackEmailForm(BaseNomcomForm, forms.Form):
551516

ietf/nomcom/tests.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,6 @@ def test_public_feedback(self):
657657
def test_private_feedback(self):
658658
self.access_member_url(self.private_feedback_url)
659659
return self.feedback_view(public=False)
660-
self.client.logout()
661660

662661
def feedback_view(self, *args, **kwargs):
663662
public = kwargs.pop('public', True)
@@ -688,11 +687,16 @@ def feedback_view(self, *args, **kwargs):
688687

689688
response = self.client.get(feedback_url)
690689
self.assertEqual(response.status_code, 200)
691-
self.assertContains(response, "feedbackform")
690+
self.assertNotContains(response, "feedbackform")
692691

693692
position = Position.objects.get(name=position_name)
694693
nominee = Nominee.objects.get(email__address=nominee_email)
695694

695+
feedback_url += "?nominee=%d&position=%d" % (nominee.id, position.id)
696+
response = self.client.get(feedback_url)
697+
self.assertEqual(response.status_code, 200)
698+
self.assertContains(response, "feedbackform")
699+
696700
comments = u'Test feedback view. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.'
697701

698702
test_data = {'comments': comments,
@@ -705,8 +709,6 @@ def feedback_view(self, *args, **kwargs):
705709
test_data['nominator_email'] = nominator_email
706710
test_data['nominator_name'] = nominator_email
707711

708-
feedback_url += "?nominee=%d&position=%d" % (nominee.id, position.id)
709-
710712
nominee_position = NomineePosition.objects.get(nominee=nominee,
711713
position=position)
712714
state = nominee_position.state
@@ -722,6 +724,7 @@ def feedback_view(self, *args, **kwargs):
722724
response = self.client.post(feedback_url, test_data)
723725
self.assertEqual(response.status_code, 200)
724726
self.assertContains(response, "alert-success")
727+
self.assertNotContains(response, "feedbackform")
725728

726729
## check objects
727730
feedback = Feedback.objects.filter(positions__in=[position],

ietf/nomcom/views.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,15 +349,13 @@ def private_feedback(request, year):
349349
def feedback(request, year, public):
350350
nomcom = get_nomcom_by_year(year)
351351
has_publickey = nomcom.public_key and True or False
352-
submit_disabled = True
353352
nominee = None
354353
position = None
355354
selected_nominee = request.GET.get('nominee')
356355
selected_position = request.GET.get('position')
357356
if selected_nominee and selected_position:
358357
nominee = get_object_or_404(Nominee, id=selected_nominee)
359358
position = get_object_or_404(Position, id=selected_position)
360-
submit_disabled = False
361359

362360
positions = Position.objects.get_by_nomcom(nomcom=nomcom).opened()
363361

@@ -384,19 +382,20 @@ def feedback(request, year, public):
384382
if form.is_valid():
385383
form.save()
386384
message = ('success', 'Your feedback has been registered.')
385+
form = None
386+
else:
387+
if nominee and position:
387388
form = FeedbackForm(nomcom=nomcom, user=request.user, public=public,
388389
position=position, nominee=nominee)
389-
else:
390-
form = FeedbackForm(nomcom=nomcom, user=request.user, public=public,
391-
position=position, nominee=nominee)
390+
else:
391+
form = None
392392

393393
return render(request, 'nomcom/feedback.html', {
394394
'form': form,
395395
'message': message,
396396
'nomcom': nomcom,
397397
'year': year,
398398
'positions': positions,
399-
'submit_disabled': submit_disabled,
400399
'selected': 'feedback',
401400
'base_template': base_template
402401
})

ietf/templates/nomcom/feedback.html

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
{% block nomcom_content %}
1111
{% origin %}
1212
<p class="alert alert-info">
13-
First select a nominee from the list of nominees to provide input about that nominee.
14-
This will fill in the non-editable fields in the form.
13+
Select a nominee from the list of nominees to the right to obtain a new feedback form.
1514
</p>
1615

1716
{% if message %}
@@ -49,15 +48,23 @@ <h4>{{ p.name }}</h4>
4948
</div>
5049

5150
<div class="col-sm-8 col-sm-pull-4">
52-
<h3>Provide feedback</h3>
51+
{% if form %}
52+
<h3>Provide feedback
53+
{% if form.position %}
54+
about {{form.nominee.email.person.name}} ({{form.nominee.email.address}}) for the {{form.position.name}} position.</p>
55+
{% endif %}
56+
</h3>
57+
<p>This feedback will only be available to <a href="{% url 'nomcom_year_index' year=year %}">NomCom {{year}}</a>.
58+
You may have the feedback mailed back to you by selecting the option below.</p>
5359

54-
<form id="feedbackform" method="post">
55-
{% csrf_token %}
56-
{% bootstrap_form form %}
57-
{% buttons %}
58-
<input class="btn btn-primary" type="submit" value="Save" name="save" {% if submit_disabled %}disabled="disabled"{% endif %}>
59-
{% endbuttons %}
60+
<form id="feedbackform" method="post">
61+
{% csrf_token %}
62+
{% bootstrap_form form %}
63+
{% buttons %}
64+
<input class="btn btn-primary" type="submit" value="Save" name="save">
65+
{% endbuttons %}
6066
</form>
67+
{% endif %}
6168
</div>
6269
</div>
6370
{% endif %}

0 commit comments

Comments
 (0)