From 50dd5ba30b71e9bd5cadfe4b0822f124029d0edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Jim=C3=A9nez?= Date: Wed, 6 Mar 2013 17:45:30 +0000 Subject: [PATCH] Add skel view to provide comments to nominees See #970 - Legacy-Id: 5488 --- ietf/nomcom/forms.py | 40 ++++++++++++++++ ietf/nomcom/urls.py | 3 +- ietf/nomcom/views.py | 47 ++++++++++++++++--- ietf/templates/nomcom/comments.html | 3 -- .../templates/nomcom/nomcom_private_base.html | 1 + ietf/templates/nomcom/nomcom_public_base.html | 2 +- ietf/templates/nomcom/private_feedback.html | 40 ++++++++++++++++ ietf/templates/nomcom/public_feedback.html | 40 ++++++++++++++++ ietf/templates/nomcom/public_nominate.html | 2 +- 9 files changed, 166 insertions(+), 12 deletions(-) delete mode 100644 ietf/templates/nomcom/comments.html create mode 100644 ietf/templates/nomcom/private_feedback.html create mode 100644 ietf/templates/nomcom/public_feedback.html diff --git a/ietf/nomcom/forms.py b/ietf/nomcom/forms.py index 274165f5d..57e3847ac 100644 --- a/ietf/nomcom/forms.py +++ b/ietf/nomcom/forms.py @@ -414,6 +414,46 @@ class NominateForm(BaseNomcomForm, forms.ModelForm): "/js/nomcom.js", ) +class FeedbackForm(BaseNomcomForm, forms.ModelForm): + position = forms.CharField(label='position') + nominee_name = forms.CharField(label='nominee name') + nominee_email = forms.CharField(label='nominee email') + nominator_name = forms.CharField(label='nominator name') + nominator_email = forms.CharField(label='nominator email') + + comments = forms.CharField(label='Comments on this candidate', widget=forms.Textarea()) + + fieldsets = [('Provide comments', ('position', + 'nominee_name', + 'nominee_email', + 'nominator_name', + 'nominator_email', + 'comments'))] + + def __init__(self, *args, **kwargs): + self.nomcom = kwargs.pop('nomcom', None) + self.user = kwargs.pop('user', None) + self.public = kwargs.pop('public', None) + + super(FeedbackForm, self).__init__(*args, **kwargs) + + def save(self, commit=True): + pass + + class Meta: + model = Feedback + fields = ('position', + 'nominee_name', + 'nominee_email', + 'nominator_name', + 'nominator_email', + 'comments') + + class Media: + js = ("/js/jquery-1.5.1.min.js", + "/js/nomcom.js", ) + + class NomComTemplateForm(BaseNomcomForm, DBTemplateForm): fieldsets = [('Template content', ('content', )), diff --git a/ietf/nomcom/urls.py b/ietf/nomcom/urls.py index e6b33c566..2505bfdac 100644 --- a/ietf/nomcom/urls.py +++ b/ietf/nomcom/urls.py @@ -6,6 +6,7 @@ urlpatterns = patterns('ietf.nomcom.views', url(r'^(?P\d{4})/private/$', 'private_index', name='nomcom_private_index'), url(r'^(?P\d{4})/private/key/$', 'private_key', name='nomcom_private_key'), url(r'^(?P\d{4})/private/nominate/$', 'private_nominate', name='nomcom_private_nominate'), + url(r'^(?P\d{4})/private/feedback/$', 'private_feedback', name='nomcom_private_feedback'), url(r'^(?P\d{4})/private/merge/$', 'private_merge', name='nomcom_private_merge'), url(r'^(?P\d{4})/private/send-reminder-mail/$', 'send_reminder_mail', name='nomcom_send_reminder_mail'), url(r'^(?P\d{4})/private/edit-members/$', EditMembersFormPreview(EditMembersForm), name='nomcom_edit_members'), @@ -21,7 +22,7 @@ urlpatterns = patterns('ietf.nomcom.views', url(r'^(?P\d{4})/$', 'index', name='nomcom_index'), url(r'^(?P\d{4})/requirements/$', 'requirements', name='nomcom_requirements'), url(r'^(?P\d{4})/questionnaires/$', 'questionnaires', name='nomcom_questionnaires'), - url(r'^(?P\d{4})/comments/$', 'comments', name='nomcom_comments'), + url(r'^(?P\d{4})/feedback/$', 'public_feedback', name='nomcom_public_feedback'), url(r'^(?P\d{4})/nominate/$', 'public_nominate', name='nomcom_public_nominate'), url(r'^ajax/position-text/(?P\d+)/$', 'ajax_position_text', name='nomcom_ajax_position_text'), diff --git a/ietf/nomcom/views.py b/ietf/nomcom/views.py index bf33eb81b..1728d2381 100644 --- a/ietf/nomcom/views.py +++ b/ietf/nomcom/views.py @@ -15,7 +15,7 @@ from ietf.dbtemplate.models import DBTemplate from ietf.dbtemplate.views import template_edit from ietf.name.models import NomineePositionState from ietf.nomcom.decorators import member_required, private_key_required -from ietf.nomcom.forms import (EditPublicKeyForm, NominateForm, MergeForm, +from ietf.nomcom.forms import (EditPublicKeyForm, NominateForm, FeedbackForm, MergeForm, NomComTemplateForm, PositionForm, PrivateKeyForm) from ietf.nomcom.models import Position, NomineePosition, Nominee from ietf.nomcom.utils import (get_nomcom_by_year, HOME_TEMPLATE, @@ -241,13 +241,48 @@ def nominate(request, year, public): @login_required -def comments(request, year): - # TODO: complete to do comments +def public_feedback(request, year): + return feedback(request, year, True) + + +@member_required(role='member') +def private_feedback(request, year): + return feedback(request, year, False) + + +def feedback(request, year, public): nomcom = get_nomcom_by_year(year) - return render_to_response('nomcom/comments.html', - {'nomcom': nomcom, + has_publickey = nomcom.public_key and True or False + if public: + template = 'nomcom/public_feedback.html' + else: + template = 'nomcom/private_feedback.html' + + if not has_publickey: + message = ('warning', "Nomcom don't have public key to ecrypt data, please contact with nomcom chair") + return render_to_response(template, + {'has_publickey': has_publickey, + 'message': message, + 'nomcom': nomcom, 'year': year, - 'selected': 'comments'}, RequestContext(request)) + 'selected': 'feedback'}, RequestContext(request)) + + message = None + if request.method == 'POST': + form = FeedbackForm(data=request.POST, nomcom=nomcom, user=request.user, public=public) + if form.is_valid(): + form.save() + message = ('success', 'Your nomination has been registered. Thank you for the nomination.') + else: + form = FeedbackForm(nomcom=nomcom, user=request.user, public=public) + + return render_to_response(template, + {'has_publickey': has_publickey, + 'form': form, + 'message': message, + 'nomcom': nomcom, + 'year': year, + 'selected': 'feedback'}, RequestContext(request)) @member_required(role='chair') diff --git a/ietf/templates/nomcom/comments.html b/ietf/templates/nomcom/comments.html deleted file mode 100644 index ffd976e4e..000000000 --- a/ietf/templates/nomcom/comments.html +++ /dev/null @@ -1,3 +0,0 @@ -{% extends "nomcom/nomcom_public_base.html" %} - -{% block subtitle %} - Provide comments {% endblock %} diff --git a/ietf/templates/nomcom/nomcom_private_base.html b/ietf/templates/nomcom/nomcom_private_base.html index 1cbf0eee8..8d4249bdf 100644 --- a/ietf/templates/nomcom/nomcom_private_base.html +++ b/ietf/templates/nomcom/nomcom_private_base.html @@ -9,6 +9,7 @@
{% if selected == "index" %}List of nominees{% else %}List of nominees{% endif %} | {% if selected == "nominate" %}Nominate{% else %}Nominate{% endif %} | + {% if selected == "feedback" %}Provide comments{% else %}Provide comments{% endif %} | {% if selected == "private_key" %}Private key{% else %}Private key{% endif %} {% if user|is_chair:year %} | {% if selected == "merge" %}Merge nominee email addr{% else %}Merge nominee email addr{% endif %} | diff --git a/ietf/templates/nomcom/nomcom_public_base.html b/ietf/templates/nomcom/nomcom_public_base.html index 2ba448ebc..a18cc0d96 100644 --- a/ietf/templates/nomcom/nomcom_public_base.html +++ b/ietf/templates/nomcom/nomcom_public_base.html @@ -7,9 +7,9 @@
{% if selected == "index" %}Home{% else %}Home{% endif %} | {% if selected == "nominate" %}Nominate{% else %}Nominate{% endif %} | + {% if selected == "feedback" %}Provide Comments{% else %}Provide Comments{% endif %} | {% if selected == "requirements" %}Requirements{% else %}Requirements{% endif %} | {% if selected == "questionnaires" %}Questionnaires{% else %}Questionnaires{% endif %} | - {% if selected == "comments" %}Provide Comments{% else %}Provide Comments{% endif %}
{% block nomcom_content %} diff --git a/ietf/templates/nomcom/private_feedback.html b/ietf/templates/nomcom/private_feedback.html new file mode 100644 index 000000000..83b3f9a22 --- /dev/null +++ b/ietf/templates/nomcom/private_feedback.html @@ -0,0 +1,40 @@ +{% extends "nomcom/nomcom_private_base.html" %} + +{% block subtitle %} - Feedback{% endblock %} + +{% block pagehead %} +{{ form.media }} +{% endblock %} + +{% block nomcom_content %} + + +{% if message %} +
{{ message.1 }}
+{% endif %} + +{% if has_publickey %} + +
+ Your browser has Javascript disabled. Please enable javascript and reload the page. + +
+ + + {% if form.errors %}
Please correct the following errors
{% endif %} + +
{% csrf_token %} + {{ form }} + +
+ +
+ +
+{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/ietf/templates/nomcom/public_feedback.html b/ietf/templates/nomcom/public_feedback.html new file mode 100644 index 000000000..9512a9125 --- /dev/null +++ b/ietf/templates/nomcom/public_feedback.html @@ -0,0 +1,40 @@ +{% extends "nomcom/nomcom_public_base.html" %} + +{% block subtitle %} - Feedback{% endblock %} + +{% block pagehead %} +{{ form.media }} +{% endblock %} + +{% block nomcom_content %} + + +{% if message %} +
{{ message.1 }}
+{% endif %} + +{% if has_publickey %} + +
+ Your browser has Javascript disabled. Please enable javascript and reload the page. + +
+ + + {% if form.errors %}
Please correct the following errors
{% endif %} + +
{% csrf_token %} + {{ form }} + +
+ +
+ +
+{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/ietf/templates/nomcom/public_nominate.html b/ietf/templates/nomcom/public_nominate.html index f8b45518b..0cf7bfc49 100644 --- a/ietf/templates/nomcom/public_nominate.html +++ b/ietf/templates/nomcom/public_nominate.html @@ -10,7 +10,7 @@ {% if message %} -
{{ message.1 }}
+
{{ message.1 }}
{% endif %} {% if has_publickey %}