Skip to content

Commit 50dd5ba

Browse files
committed
Add skel view to provide comments to nominees
See ietf-tools#970 - Legacy-Id: 5488
1 parent ea4b638 commit 50dd5ba

9 files changed

Lines changed: 166 additions & 12 deletions

File tree

ietf/nomcom/forms.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,46 @@ class Media:
414414
"/js/nomcom.js", )
415415

416416

417+
class FeedbackForm(BaseNomcomForm, forms.ModelForm):
418+
position = forms.CharField(label='position')
419+
nominee_name = forms.CharField(label='nominee name')
420+
nominee_email = forms.CharField(label='nominee email')
421+
nominator_name = forms.CharField(label='nominator name')
422+
nominator_email = forms.CharField(label='nominator email')
423+
424+
comments = forms.CharField(label='Comments on this candidate', widget=forms.Textarea())
425+
426+
fieldsets = [('Provide comments', ('position',
427+
'nominee_name',
428+
'nominee_email',
429+
'nominator_name',
430+
'nominator_email',
431+
'comments'))]
432+
433+
def __init__(self, *args, **kwargs):
434+
self.nomcom = kwargs.pop('nomcom', None)
435+
self.user = kwargs.pop('user', None)
436+
self.public = kwargs.pop('public', None)
437+
438+
super(FeedbackForm, self).__init__(*args, **kwargs)
439+
440+
def save(self, commit=True):
441+
pass
442+
443+
class Meta:
444+
model = Feedback
445+
fields = ('position',
446+
'nominee_name',
447+
'nominee_email',
448+
'nominator_name',
449+
'nominator_email',
450+
'comments')
451+
452+
class Media:
453+
js = ("/js/jquery-1.5.1.min.js",
454+
"/js/nomcom.js", )
455+
456+
417457
class NomComTemplateForm(BaseNomcomForm, DBTemplateForm):
418458

419459
fieldsets = [('Template content', ('content', )),

ietf/nomcom/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
url(r'^(?P<year>\d{4})/private/$', 'private_index', name='nomcom_private_index'),
77
url(r'^(?P<year>\d{4})/private/key/$', 'private_key', name='nomcom_private_key'),
88
url(r'^(?P<year>\d{4})/private/nominate/$', 'private_nominate', name='nomcom_private_nominate'),
9+
url(r'^(?P<year>\d{4})/private/feedback/$', 'private_feedback', name='nomcom_private_feedback'),
910
url(r'^(?P<year>\d{4})/private/merge/$', 'private_merge', name='nomcom_private_merge'),
1011
url(r'^(?P<year>\d{4})/private/send-reminder-mail/$', 'send_reminder_mail', name='nomcom_send_reminder_mail'),
1112
url(r'^(?P<year>\d{4})/private/edit-members/$', EditMembersFormPreview(EditMembersForm), name='nomcom_edit_members'),
@@ -21,7 +22,7 @@
2122
url(r'^(?P<year>\d{4})/$', 'index', name='nomcom_index'),
2223
url(r'^(?P<year>\d{4})/requirements/$', 'requirements', name='nomcom_requirements'),
2324
url(r'^(?P<year>\d{4})/questionnaires/$', 'questionnaires', name='nomcom_questionnaires'),
24-
url(r'^(?P<year>\d{4})/comments/$', 'comments', name='nomcom_comments'),
25+
url(r'^(?P<year>\d{4})/feedback/$', 'public_feedback', name='nomcom_public_feedback'),
2526
url(r'^(?P<year>\d{4})/nominate/$', 'public_nominate', name='nomcom_public_nominate'),
2627
url(r'^ajax/position-text/(?P<position_id>\d+)/$', 'ajax_position_text', name='nomcom_ajax_position_text'),
2728

ietf/nomcom/views.py

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from ietf.dbtemplate.views import template_edit
1616
from ietf.name.models import NomineePositionState
1717
from ietf.nomcom.decorators import member_required, private_key_required
18-
from ietf.nomcom.forms import (EditPublicKeyForm, NominateForm, MergeForm,
18+
from ietf.nomcom.forms import (EditPublicKeyForm, NominateForm, FeedbackForm, MergeForm,
1919
NomComTemplateForm, PositionForm, PrivateKeyForm)
2020
from ietf.nomcom.models import Position, NomineePosition, Nominee
2121
from ietf.nomcom.utils import (get_nomcom_by_year, HOME_TEMPLATE,
@@ -241,13 +241,48 @@ def nominate(request, year, public):
241241

242242

243243
@login_required
244-
def comments(request, year):
245-
# TODO: complete to do comments
244+
def public_feedback(request, year):
245+
return feedback(request, year, True)
246+
247+
248+
@member_required(role='member')
249+
def private_feedback(request, year):
250+
return feedback(request, year, False)
251+
252+
253+
def feedback(request, year, public):
246254
nomcom = get_nomcom_by_year(year)
247-
return render_to_response('nomcom/comments.html',
248-
{'nomcom': nomcom,
255+
has_publickey = nomcom.public_key and True or False
256+
if public:
257+
template = 'nomcom/public_feedback.html'
258+
else:
259+
template = 'nomcom/private_feedback.html'
260+
261+
if not has_publickey:
262+
message = ('warning', "Nomcom don't have public key to ecrypt data, please contact with nomcom chair")
263+
return render_to_response(template,
264+
{'has_publickey': has_publickey,
265+
'message': message,
266+
'nomcom': nomcom,
267+
'year': year,
268+
'selected': 'feedback'}, RequestContext(request))
269+
270+
message = None
271+
if request.method == 'POST':
272+
form = FeedbackForm(data=request.POST, nomcom=nomcom, user=request.user, public=public)
273+
if form.is_valid():
274+
form.save()
275+
message = ('success', 'Your nomination has been registered. Thank you for the nomination.')
276+
else:
277+
form = FeedbackForm(nomcom=nomcom, user=request.user, public=public)
278+
279+
return render_to_response(template,
280+
{'has_publickey': has_publickey,
281+
'form': form,
282+
'message': message,
283+
'nomcom': nomcom,
249284
'year': year,
250-
'selected': 'comments'}, RequestContext(request))
285+
'selected': 'feedback'}, RequestContext(request))
251286

252287

253288
@member_required(role='chair')

ietf/templates/nomcom/comments.html

Lines changed: 0 additions & 3 deletions
This file was deleted.

ietf/templates/nomcom/nomcom_private_base.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ <h1>Nomcom {{ year }} Private Area</h1>
99
<div class="ietf-navset">
1010
{% if selected == "index" %}<span class="selected">List of nominees</span>{% else %}<a href="{% url nomcom_private_index year %}">List of nominees</a>{% endif %} |
1111
{% if selected == "nominate" %}<span class="selected">Nominate</span>{% else %}<a href="{% url nomcom_private_nominate year %}">Nominate</a>{% endif %} |
12+
{% if selected == "feedback" %}<span class="selected">Provide comments</span>{% else %}<a href="{% url nomcom_private_feedback year %}">Provide comments</a>{% endif %} |
1213
{% if selected == "private_key" %}<span class="selected">Private key</span>{% else %}<a href="{% url nomcom_private_key year %}">Private key</a>{% endif %}
1314
{% if user|is_chair:year %} |
1415
{% if selected == "merge" %}<span class="selected">Merge nominee email addr</span>{% else %}<a href="{% url nomcom_private_merge year %}">Merge nominee email addr</a>{% endif %} |

ietf/templates/nomcom/nomcom_public_base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ <h1>Nomcom {{ year }} Pages</h1>
77
<div class="ietf-navset">
88
{% if selected == "index" %}<span class="selected">Home</span>{% else %}<a href="{% url nomcom_index year %}">Home</a>{% endif %} |
99
{% if selected == "nominate" %}<span class="selected">Nominate</span>{% else %}<a href="{% url nomcom_public_nominate year %}">Nominate</a>{% endif %} |
10+
{% if selected == "feedback" %}<span class="selected">Provide Comments</span>{% else %}<a href="{% url nomcom_public_feedback year %}">Provide Comments</a>{% endif %} |
1011
{% if selected == "requirements" %}<span class="selected">Requirements</span>{% else %}<a href="{% url nomcom_requirements year %}">Requirements</a>{% endif %} |
1112
{% if selected == "questionnaires" %}<span class="selected">Questionnaires</span>{% else %}<a href="{% url nomcom_questionnaires year %}">Questionnaires</a>{% endif %} |
12-
{% if selected == "comments" %}<span class="selected">Provide Comments</span>{% else %}<a href="{% url nomcom_comments year %}">Provide Comments</a>{% endif %}
1313
</div>
1414

1515
{% block nomcom_content %}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{% extends "nomcom/nomcom_private_base.html" %}
2+
3+
{% block subtitle %} - Feedback{% endblock %}
4+
5+
{% block pagehead %}
6+
{{ form.media }}
7+
{% endblock %}
8+
9+
{% block nomcom_content %}
10+
11+
12+
{% if message %}
13+
<div class="info-message-{{ message.0 }}">{{ message.1 }}</div>
14+
{% endif %}
15+
16+
{% if has_publickey %}
17+
18+
<div class="js-info">
19+
Your browser has Javascript disabled. Please enable javascript and reload the page.
20+
<script type="text/javascript">
21+
(function ($) {
22+
$(".js-info").hide();
23+
})(jQuery);
24+
</script>
25+
</div>
26+
27+
28+
{% if form.errors %}<div class="info-message-error">Please correct the following errors</div>{% endif %}
29+
30+
<form id="privateform" action="" method="post">{% csrf_token %}
31+
{{ form }}
32+
33+
<div class="submitrow">
34+
<input type="submit" value="Save" name="save" />
35+
</div>
36+
37+
</form>
38+
{% endif %}
39+
40+
{% endblock %}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{% extends "nomcom/nomcom_public_base.html" %}
2+
3+
{% block subtitle %} - Feedback{% endblock %}
4+
5+
{% block pagehead %}
6+
{{ form.media }}
7+
{% endblock %}
8+
9+
{% block nomcom_content %}
10+
11+
12+
{% if message %}
13+
<div class="info-message-{{ message.0 }}">{{ message.1 }}</div>
14+
{% endif %}
15+
16+
{% if has_publickey %}
17+
18+
<div class="js-info">
19+
Your browser has Javascript disabled. Please enable javascript and reload the page.
20+
<script type="text/javascript">
21+
(function ($) {
22+
$(".js-info").hide();
23+
})(jQuery);
24+
</script>
25+
</div>
26+
27+
28+
{% if form.errors %}<div class="info-message-error">Please correct the following errors</div>{% endif %}
29+
30+
<form id="feedbackform" action="" method="post">{% csrf_token %}
31+
{{ form }}
32+
33+
<div class="submitrow">
34+
<input type="submit" value="Save" name="save" />
35+
</div>
36+
37+
</form>
38+
{% endif %}
39+
40+
{% endblock %}

ietf/templates/nomcom/public_nominate.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
{% if message %}
13-
<div class="info-message-{{ message.0 }}">{{ message.1 }}</div>
13+
<div class="info-message-{{ message.0 }}">{{ message.1 }}</div>
1414
{% endif %}
1515

1616
{% if has_publickey %}

0 commit comments

Comments
 (0)