diff --git a/ietf/dbtemplate/fixtures/nomcom_templates.xml b/ietf/dbtemplate/fixtures/nomcom_templates.xml index ee0f9564d..0776fe4e5 100644 --- a/ietf/dbtemplate/fixtures/nomcom_templates.xml +++ b/ietf/dbtemplate/fixtures/nomcom_templates.xml @@ -63,10 +63,9 @@ Position: $position /nomcom/defaults/position/questionnaire.txt Questionnaire sent to the nomine - $nominee: Full name of the nomine -$position: Position + $position: Position plain - Hi $nominee, this is the questionnaire for the position $position: + Enter here the questionnaire for the position $position: Questionnaire @@ -81,4 +80,15 @@ Questionnaire Requirements. - \ No newline at end of file + + /nomcom/defaults/position/header_questionnaire.txt + Header of the email that contains the questionnaire sent to the nomine + $nominee: Full name of the nomine +$position: Position + plain + Hi $nominee, this is the questionnaire for the position $position: + + + + + diff --git a/ietf/dbtemplate/templates/dbtemplate/template_edit.html b/ietf/dbtemplate/templates/dbtemplate/template_edit.html index aab750430..7422618d1 100644 --- a/ietf/dbtemplate/templates/dbtemplate/template_edit.html +++ b/ietf/dbtemplate/templates/dbtemplate/template_edit.html @@ -10,22 +10,22 @@
Group
{{ template.group }}
Template type
-
{{ template.get_template_type_display }} - {% ifequal template.template_type "rst" %} +
{{ template.type.name }} + {% ifequal template.type.slug "rst" %}

This template uses the syntax of reStructuredText. Get a quick reference at http://docutils.sourceforge.net/docs/user/rst/quickref.html.

You can do variable interpolation with $varialbe if the template allows any variable.

{% endifequal %} - {% ifequal template.template_type "django" %} + {% ifequal template.type.slug "django" %}

This template uses the syntax of the default django template framework. Get more info at https://docs.djangoproject.com/en/dev/topics/templates/.

You can do variable interpolation with the current django markup {{variable}} if the template allows any variable.

{% endifequal %} - {% ifequal template.template_type "plain" %} + {% ifequal template.type.slug "plain" %}

This template uses plain text, so no markup is used. You can do variable interpolation with $variable if the template allows any variable.

{% endifequal %}
- {% if template.help_text %} -
Extra info about this template
-
{{ template.help_text }}
+ {% if template.variables %} +
Variables allowed in this template
+
{{ template.variables|linebreaks }}
{% endif %} diff --git a/ietf/dbtemplate/views.py b/ietf/dbtemplate/views.py index f0a185655..f1ac1cf27 100644 --- a/ietf/dbtemplate/views.py +++ b/ietf/dbtemplate/views.py @@ -11,8 +11,7 @@ from ietf.ietfauth.decorators import has_role def template_list(request, acronym): group = get_object_or_404(Group, acronym=acronym) chairs = group.role_set.filter(name__slug='chair') - - if not has_role(request.user, "Secretariat") or not chairs.filter(person__user=request.user).count(): + if not has_role(request.user, "Secretariat") and not chairs.filter(person__user=request.user).count(): return HttpResponseForbidden("You are not authorized to access this view") template_list = DBTemplate.objects.filter(group=group) @@ -26,7 +25,7 @@ def template_edit(request, acronym, template_id): group = get_object_or_404(Group, acronym=acronym) chairs = group.role_set.filter(name__slug='chair') - if not has_role(request.user, "Secretariat") or not chairs.filter(person__user=request.user).count(): + if not has_role(request.user, "Secretariat") and not chairs.filter(person__user=request.user).count(): return HttpResponseForbidden("You are not authorized to access this view") template = get_object_or_404(DBTemplate, id=template_id, group=group) diff --git a/ietf/nomcom/admin.py b/ietf/nomcom/admin.py index 083961d0d..f192d1e9a 100644 --- a/ietf/nomcom/admin.py +++ b/ietf/nomcom/admin.py @@ -5,7 +5,7 @@ from ietf.nomcom.models import NomCom, Nomination, Nominee, NomineePosition, \ class NomComAdmin(admin.ModelAdmin): - pass + raw_id_fields = ('group', ) class NominationAdmin(admin.ModelAdmin): diff --git a/ietf/nomcom/models.py b/ietf/nomcom/models.py index 5de305562..3e9617ba5 100644 --- a/ietf/nomcom/models.py +++ b/ietf/nomcom/models.py @@ -103,8 +103,8 @@ class Position(models.Model): description = models.TextField(verbose_name='Despcription') initial_text = models.TextField(verbose_name='Initial text for nominations', blank=True) - requirement = models.ForeignKey(DBTemplate, related_name='requirement', null=True) - questionnaire = models.ForeignKey(DBTemplate, related_name='questionnaire', null=True) + requirement = models.ForeignKey(DBTemplate, related_name='requirement', null=True, editable=False) + questionnaire = models.ForeignKey(DBTemplate, related_name='questionnaire', null=True, editable=False) is_open = models.BooleanField(verbose_name='Is open') incumbent = models.ForeignKey(Email) diff --git a/ietf/nomcom/utils.py b/ietf/nomcom/utils.py index 5f523c258..bd1522ced 100644 --- a/ietf/nomcom/utils.py +++ b/ietf/nomcom/utils.py @@ -6,6 +6,7 @@ from ietf.dbtemplate.models import DBTemplate MAIN_NOMCOM_TEMPLATE_PATH = '/nomcom/defaults/' QUESTIONNAIRE_TEMPLATE = 'position/questionnaire.txt' +HEADER_QUESTIONNAIRE_TEMPLATE = 'position/header_questionnaire.txt' REQUIREMENTS_TEMPLATE = 'position/requirements.txt' HOME_TEMPLATE = 'home.rst' INEXISTENT_PERSON_TEMPLATE = 'email/inexistent_person.txt' @@ -54,14 +55,24 @@ def initialize_templates_for_group(group): def initialize_questionnaire_for_position(position): questionnaire_path = MAIN_NOMCOM_TEMPLATE_PATH + QUESTIONNAIRE_TEMPLATE + header_questionnaire_path = MAIN_NOMCOM_TEMPLATE_PATH + HEADER_QUESTIONNAIRE_TEMPLATE template = DBTemplate.objects.get(path=questionnaire_path) - return DBTemplate.objects.create( - group=position.nomcom.group, - title=template.title + '[%s]' % position.name, - path='/nomcom/' + position.nomcom.group.acronym + '/' + str(position.id) + '/' + QUESTIONNAIRE_TEMPLATE, - variables=template.variables, - type_id=template.type_id, - content=template.content) + header_template = DBTemplate.objects.get(path=header_questionnaire_path) + DBTemplate.objects.create( + group=position.nomcom.group, + title=header_template.title + ' [%s]' % position.name, + path='/nomcom/' + position.nomcom.group.acronym + '/' + str(position.id) + '/' + HEADER_QUESTIONNAIRE_TEMPLATE, + variables=header_template.variables, + type_id=header_template.type_id, + content=header_template.content) + questionnaire = DBTemplate.objects.create( + group=position.nomcom.group, + title=template.title + '[%s]' % position.name, + path='/nomcom/' + position.nomcom.group.acronym + '/' + str(position.id) + '/' + QUESTIONNAIRE_TEMPLATE, + variables=template.variables, + type_id=template.type_id, + content=template.content) + return questionnaire def initialize_requirements_for_position(position): @@ -69,7 +80,7 @@ def initialize_requirements_for_position(position): template = DBTemplate.objects.get(path=requirements_path) return DBTemplate.objects.create( group=position.nomcom.group, - title=template.title + '[%s]' % position.name, + title=template.title + ' [%s]' % position.name, path='/nomcom/' + position.nomcom.group.acronym + '/' + str(position.id) + '/' + REQUIREMENTS_TEMPLATE, variables=template.variables, type_id=template.type_id,