Simplify the nomcom feedback comment form. Make that more obvious who receives mail when that form is used. Fixes #1849.

- Legacy-Id: 10501
This commit is contained in:
Robert Sparks 2015-11-16 21:46:29 +00:00
parent bb3424f0fa
commit 00e5762e20
4 changed files with 42 additions and 68 deletions

View file

@ -325,7 +325,7 @@ class MergeForm(BaseNomcomForm, forms.Form):
class NominateForm(BaseNomcomForm, forms.ModelForm):
comments = forms.CharField(label="Candidate's qualifications for the position",
widget=forms.Textarea())
confirmation = forms.BooleanField(label='Email comments back to me as confirmation',
confirmation = forms.BooleanField(label='Email comments back to me as confirmation.',
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'.",
required=False)
@ -430,18 +430,11 @@ class NominateForm(BaseNomcomForm, forms.ModelForm):
class FeedbackForm(BaseNomcomForm, forms.ModelForm):
position_name = forms.CharField(label='Position',
widget=forms.TextInput(attrs={'size': '40'}))
nominee_name = forms.CharField(label='Nominee name',
widget=forms.TextInput(attrs={'size': '40'}))
nominee_email = forms.CharField(label='Nominee email',
widget=forms.TextInput(attrs={'size': '40'}))
nominator_email = forms.CharField(label='Commenter email')
nominator_email = forms.CharField(label='Commenter email',required=False)
comments = forms.CharField(label='Comments on this nominee',
comments = forms.CharField(label='Comments',
widget=forms.Textarea())
confirmation = forms.BooleanField(label='Email comments back to me as confirmation',
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'.",
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).',
required=False)
def __init__(self, *args, **kwargs):
@ -453,66 +446,38 @@ class FeedbackForm(BaseNomcomForm, forms.ModelForm):
super(FeedbackForm, self).__init__(*args, **kwargs)
readonly_fields = ['position_name',
'nominee_name',
'nominee_email']
fieldset = ['position_name',
'nominee_name',
'nominee_email',
'nominator_email',
'comments']
author = get_user_email(self.user)
if self.public:
readonly_fields += ['nominator_email']
fieldset.append('confirmation')
self.fields.pop('nominator_email')
else:
help_text = """(Nomcom Chair/Member: please fill this in. Use your own email address if the person making the
comments wishes to be anonymous. The confirmation email will be sent to the address given here,
and the address will also be captured as part of the registered nomination.)"""
self.fields['nominator_email'].help_text = help_text
self.fields['nominator_email'].required = False
self.fields['confirmation'].label = 'Email these comments in cleartext to the provided commenter email address'
if author:
self.fields['nominator_email'].initial = author.address
author = get_user_email(self.user)
if author:
self.fields['nominator_email'].initial = author.address
if self.position and self.nominee:
self.fields['position_name'].initial = self.position.name
self.fields['nominee_name'].initial = self.nominee.email.person.name
self.fields['nominee_email'].initial = self.nominee.email.address
else:
help_text = "Please pick a name on the nominees list"
self.fields['position_name'].initial = help_text
self.fields['nominee_name'].initial = help_text
self.fields['nominee_email'].initial = help_text
self.fields['comments'].initial = help_text
readonly_fields += ['comments']
self.fields['confirmation'].widget.attrs['disabled'] = "disabled"
for field in readonly_fields:
self.fields[field].widget.attrs['readonly'] = True
self.fieldsets = [('Provide comments', fieldset)]
def clean(self):
if not NomineePosition.objects.accepted().filter(nominee=self.nominee,
position=self.position):
msg = "There isn't a accepted nomination for %s on the %s position" % (self.nominee, self.position)
self._errors["nominee_email"] = self.error_class([msg])
self._errors["comments"] = self.error_class([msg])
return self.cleaned_data
def save(self, commit=True):
feedback = super(FeedbackForm, self).save(commit=False)
confirmation = self.cleaned_data['confirmation']
comments = self.cleaned_data['comments']
nominator_email = self.cleaned_data['nominator_email']
nomcom_template_path = '/nomcom/%s/' % self.nomcom.group.acronym
author = None
if self.public:
author = get_user_email(self.user)
else:
nominator_email = self.cleaned_data['nominator_email']
if nominator_email:
emails = Email.objects.filter(address=nominator_email)
author = emails and emails[0] or None
@ -541,11 +506,11 @@ class FeedbackForm(BaseNomcomForm, forms.ModelForm):
class Meta:
model = Feedback
fields = ('nominee_name',
'nominee_email',
fields = (
'nominator_email',
'comments',
'confirmation',
'comments')
)
class FeedbackEmailForm(BaseNomcomForm, forms.Form):

View file

@ -657,7 +657,6 @@ class NomcomViewsTest(TestCase):
def test_private_feedback(self):
self.access_member_url(self.private_feedback_url)
return self.feedback_view(public=False)
self.client.logout()
def feedback_view(self, *args, **kwargs):
public = kwargs.pop('public', True)
@ -688,11 +687,16 @@ class NomcomViewsTest(TestCase):
response = self.client.get(feedback_url)
self.assertEqual(response.status_code, 200)
self.assertContains(response, "feedbackform")
self.assertNotContains(response, "feedbackform")
position = Position.objects.get(name=position_name)
nominee = Nominee.objects.get(email__address=nominee_email)
feedback_url += "?nominee=%d&position=%d" % (nominee.id, position.id)
response = self.client.get(feedback_url)
self.assertEqual(response.status_code, 200)
self.assertContains(response, "feedbackform")
comments = u'Test feedback view. Comments with accents äöåÄÖÅ éáíóú âêîôû ü àèìòù.'
test_data = {'comments': comments,
@ -705,8 +709,6 @@ class NomcomViewsTest(TestCase):
test_data['nominator_email'] = nominator_email
test_data['nominator_name'] = nominator_email
feedback_url += "?nominee=%d&position=%d" % (nominee.id, position.id)
nominee_position = NomineePosition.objects.get(nominee=nominee,
position=position)
state = nominee_position.state
@ -722,6 +724,7 @@ class NomcomViewsTest(TestCase):
response = self.client.post(feedback_url, test_data)
self.assertEqual(response.status_code, 200)
self.assertContains(response, "alert-success")
self.assertNotContains(response, "feedbackform")
## check objects
feedback = Feedback.objects.filter(positions__in=[position],

View file

@ -349,7 +349,6 @@ def private_feedback(request, year):
def feedback(request, year, public):
nomcom = get_nomcom_by_year(year)
has_publickey = nomcom.public_key and True or False
submit_disabled = True
nominee = None
position = None
selected_nominee = request.GET.get('nominee')
@ -357,7 +356,6 @@ def feedback(request, year, public):
if selected_nominee and selected_position:
nominee = get_object_or_404(Nominee, id=selected_nominee)
position = get_object_or_404(Position, id=selected_position)
submit_disabled = False
positions = Position.objects.get_by_nomcom(nomcom=nomcom).opened()
@ -384,11 +382,13 @@ def feedback(request, year, public):
if form.is_valid():
form.save()
message = ('success', 'Your feedback has been registered.')
form = None
else:
if nominee and position:
form = FeedbackForm(nomcom=nomcom, user=request.user, public=public,
position=position, nominee=nominee)
else:
form = FeedbackForm(nomcom=nomcom, user=request.user, public=public,
position=position, nominee=nominee)
else:
form = None
return render(request, 'nomcom/feedback.html', {
'form': form,
@ -396,7 +396,6 @@ def feedback(request, year, public):
'nomcom': nomcom,
'year': year,
'positions': positions,
'submit_disabled': submit_disabled,
'selected': 'feedback',
'base_template': base_template
})

View file

@ -10,8 +10,7 @@
{% block nomcom_content %}
{% origin %}
<p class="alert alert-info">
First select a nominee from the list of nominees to provide input about that nominee.
This will fill in the non-editable fields in the form.
Select a nominee from the list of nominees to the right to obtain a new feedback form.
</p>
{% if message %}
@ -49,15 +48,23 @@
</div>
<div class="col-sm-8 col-sm-pull-4">
<h3>Provide feedback</h3>
{% if form %}
<h3>Provide feedback
{% if form.position %}
about {{form.nominee.email.person.name}} ({{form.nominee.email.address}}) for the {{form.position.name}} position.</p>
{% endif %}
</h3>
<p>This feedback will only be available to <a href="{% url 'nomcom_year_index' year=year %}">NomCom {{year}}</a>.
You may have the feedback mailed back to you by selecting the option below.</p>
<form id="feedbackform" method="post">
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<input class="btn btn-primary" type="submit" value="Save" name="save" {% if submit_disabled %}disabled="disabled"{% endif %}>
{% endbuttons %}
<form id="feedbackform" method="post">
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<input class="btn btn-primary" type="submit" value="Save" name="save">
{% endbuttons %}
</form>
{% endif %}
</div>
</div>
{% endif %}