Skip to content

Commit 49ee366

Browse files
committed
Split questionnaire template into questionnaire and introductori mail header. See ietf-tools#908. See ietf-tools#906
- Legacy-Id: 5204
1 parent bf0747a commit 49ee366

6 files changed

Lines changed: 45 additions & 25 deletions

File tree

ietf/dbtemplate/fixtures/nomcom_templates.xml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,9 @@ Position: $position</field>
6363
<object pk="5" model="dbtemplate.dbtemplate">
6464
<field type="CharField" name="path">/nomcom/defaults/position/questionnaire.txt</field>
6565
<field type="CharField" name="title">Questionnaire sent to the nomine</field>
66-
<field type="TextField" name="variables">$nominee: Full name of the nomine
67-
$position: Position</field>
66+
<field type="TextField" name="variables">$position: Position</field>
6867
<field to="name.dbtemplatetypename" name="type" rel="ManyToOneRel">plain</field>
69-
<field type="TextField" name="content">Hi $nominee, this is the questionnaire for the position $position:
68+
<field type="TextField" name="content">Enter here the questionnaire for the position $position:
7069

7170
Questionnaire</field>
7271
<field to="group.group" name="group" rel="ManyToOneRel"><None></None></field>
@@ -81,4 +80,15 @@ Questionnaire</field>
8180
Requirements.</field>
8281
<field to="group.group" name="group" rel="ManyToOneRel"><None></None></field>
8382
</object>
84-
</django-objects>
83+
<object pk="7" model="dbtemplate.dbtemplate">
84+
<field type="CharField" name="path">/nomcom/defaults/position/header_questionnaire.txt</field>
85+
<field type="CharField" name="title">Header of the email that contains the questionnaire sent to the nomine</field>
86+
<field type="TextField" name="variables">$nominee: Full name of the nomine
87+
$position: Position</field>
88+
<field to="name.dbtemplatetypename" name="type" rel="ManyToOneRel">plain</field>
89+
<field type="TextField" name="content">Hi $nominee, this is the questionnaire for the position $position:
90+
91+
</field>
92+
<field to="group.group" name="group" rel="ManyToOneRel"><None></None></field>
93+
</object>
94+
</django-objects>

ietf/dbtemplate/templates/dbtemplate/template_edit.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ <h2>Meta information</h2>
1010
<dt>Group</dt>
1111
<dd>{{ template.group }}</dd>
1212
<dt>Template type</dt>
13-
<dd>{{ template.get_template_type_display }}
14-
{% ifequal template.template_type "rst" %}
13+
<dd>{{ template.type.name }}
14+
{% ifequal template.type.slug "rst" %}
1515
<p>This template uses the syntax of reStructuredText. Get a quick reference at <a href="http://docutils.sourceforge.net/docs/user/rst/quickref.html">http://docutils.sourceforge.net/docs/user/rst/quickref.html</a>.</p>
1616
<p>You can do variable interpolation with $varialbe if the template allows any variable.</p>
1717
{% endifequal %}
18-
{% ifequal template.template_type "django" %}
18+
{% ifequal template.type.slug "django" %}
1919
<p>This template uses the syntax of the default django template framework. Get more info at <a href="https://docs.djangoproject.com/en/dev/topics/templates/">https://docs.djangoproject.com/en/dev/topics/templates/</a>.</p>
2020
<p>You can do variable interpolation with the current django markup &#123;&#123;variable&#125;&#125; if the template allows any variable.</p>
2121
{% endifequal %}
22-
{% ifequal template.template_type "plain" %}
22+
{% ifequal template.type.slug "plain" %}
2323
<p>This template uses plain text, so no markup is used. You can do variable interpolation with $variable if the template allows any variable.</p>
2424
{% endifequal %}
2525
</dd>
26-
{% if template.help_text %}
27-
<dt>Extra info about this template</dt>
28-
<dd>{{ template.help_text }}</dd>
26+
{% if template.variables %}
27+
<dt>Variables allowed in this template</dt>
28+
<dd>{{ template.variables|linebreaks }}</dd>
2929
{% endif %}
3030
</dl>
3131

ietf/dbtemplate/views.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
def template_list(request, acronym):
1212
group = get_object_or_404(Group, acronym=acronym)
1313
chairs = group.role_set.filter(name__slug='chair')
14-
15-
if not has_role(request.user, "Secretariat") or not chairs.filter(person__user=request.user).count():
14+
if not has_role(request.user, "Secretariat") and not chairs.filter(person__user=request.user).count():
1615
return HttpResponseForbidden("You are not authorized to access this view")
1716

1817
template_list = DBTemplate.objects.filter(group=group)
@@ -26,7 +25,7 @@ def template_edit(request, acronym, template_id):
2625
group = get_object_or_404(Group, acronym=acronym)
2726
chairs = group.role_set.filter(name__slug='chair')
2827

29-
if not has_role(request.user, "Secretariat") or not chairs.filter(person__user=request.user).count():
28+
if not has_role(request.user, "Secretariat") and not chairs.filter(person__user=request.user).count():
3029
return HttpResponseForbidden("You are not authorized to access this view")
3130

3231
template = get_object_or_404(DBTemplate, id=template_id, group=group)

ietf/nomcom/admin.py

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

66

77
class NomComAdmin(admin.ModelAdmin):
8-
pass
8+
raw_id_fields = ('group', )
99

1010

1111
class NominationAdmin(admin.ModelAdmin):

ietf/nomcom/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ class Position(models.Model):
103103
description = models.TextField(verbose_name='Despcription')
104104
initial_text = models.TextField(verbose_name='Initial text for nominations',
105105
blank=True)
106-
requirement = models.ForeignKey(DBTemplate, related_name='requirement', null=True)
107-
questionnaire = models.ForeignKey(DBTemplate, related_name='questionnaire', null=True)
106+
requirement = models.ForeignKey(DBTemplate, related_name='requirement', null=True, editable=False)
107+
questionnaire = models.ForeignKey(DBTemplate, related_name='questionnaire', null=True, editable=False)
108108
is_open = models.BooleanField(verbose_name='Is open')
109109
incumbent = models.ForeignKey(Email)
110110

ietf/nomcom/utils.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
MAIN_NOMCOM_TEMPLATE_PATH = '/nomcom/defaults/'
88
QUESTIONNAIRE_TEMPLATE = 'position/questionnaire.txt'
9+
HEADER_QUESTIONNAIRE_TEMPLATE = 'position/header_questionnaire.txt'
910
REQUIREMENTS_TEMPLATE = 'position/requirements.txt'
1011
HOME_TEMPLATE = 'home.rst'
1112
INEXISTENT_PERSON_TEMPLATE = 'email/inexistent_person.txt'
@@ -54,22 +55,32 @@ def initialize_templates_for_group(group):
5455

5556
def initialize_questionnaire_for_position(position):
5657
questionnaire_path = MAIN_NOMCOM_TEMPLATE_PATH + QUESTIONNAIRE_TEMPLATE
58+
header_questionnaire_path = MAIN_NOMCOM_TEMPLATE_PATH + HEADER_QUESTIONNAIRE_TEMPLATE
5759
template = DBTemplate.objects.get(path=questionnaire_path)
58-
return DBTemplate.objects.create(
59-
group=position.nomcom.group,
60-
title=template.title + '[%s]' % position.name,
61-
path='/nomcom/' + position.nomcom.group.acronym + '/' + str(position.id) + '/' + QUESTIONNAIRE_TEMPLATE,
62-
variables=template.variables,
63-
type_id=template.type_id,
64-
content=template.content)
60+
header_template = DBTemplate.objects.get(path=header_questionnaire_path)
61+
DBTemplate.objects.create(
62+
group=position.nomcom.group,
63+
title=header_template.title + ' [%s]' % position.name,
64+
path='/nomcom/' + position.nomcom.group.acronym + '/' + str(position.id) + '/' + HEADER_QUESTIONNAIRE_TEMPLATE,
65+
variables=header_template.variables,
66+
type_id=header_template.type_id,
67+
content=header_template.content)
68+
questionnaire = DBTemplate.objects.create(
69+
group=position.nomcom.group,
70+
title=template.title + '[%s]' % position.name,
71+
path='/nomcom/' + position.nomcom.group.acronym + '/' + str(position.id) + '/' + QUESTIONNAIRE_TEMPLATE,
72+
variables=template.variables,
73+
type_id=template.type_id,
74+
content=template.content)
75+
return questionnaire
6576

6677

6778
def initialize_requirements_for_position(position):
6879
requirements_path = MAIN_NOMCOM_TEMPLATE_PATH + REQUIREMENTS_TEMPLATE
6980
template = DBTemplate.objects.get(path=requirements_path)
7081
return DBTemplate.objects.create(
7182
group=position.nomcom.group,
72-
title=template.title + '[%s]' % position.name,
83+
title=template.title + ' [%s]' % position.name,
7384
path='/nomcom/' + position.nomcom.group.acronym + '/' + str(position.id) + '/' + REQUIREMENTS_TEMPLATE,
7485
variables=template.variables,
7586
type_id=template.type_id,

0 commit comments

Comments
 (0)