Split questionnaire template into questionnaire and introductori mail header. See #908. See #906

- Legacy-Id: 5204
This commit is contained in:
Emilio A. Sánchez López 2013-01-16 13:01:37 +00:00
parent bf0747a8e9
commit 49ee366367
6 changed files with 45 additions and 25 deletions

View file

@ -63,10 +63,9 @@ Position: $position</field>
<object pk="5" model="dbtemplate.dbtemplate">
<field type="CharField" name="path">/nomcom/defaults/position/questionnaire.txt</field>
<field type="CharField" name="title">Questionnaire sent to the nomine</field>
<field type="TextField" name="variables">$nominee: Full name of the nomine
$position: Position</field>
<field type="TextField" name="variables">$position: Position</field>
<field to="name.dbtemplatetypename" name="type" rel="ManyToOneRel">plain</field>
<field type="TextField" name="content">Hi $nominee, this is the questionnaire for the position $position:
<field type="TextField" name="content">Enter here the questionnaire for the position $position:
Questionnaire</field>
<field to="group.group" name="group" rel="ManyToOneRel"><None></None></field>
@ -81,4 +80,15 @@ Questionnaire</field>
Requirements.</field>
<field to="group.group" name="group" rel="ManyToOneRel"><None></None></field>
</object>
</django-objects>
<object pk="7" model="dbtemplate.dbtemplate">
<field type="CharField" name="path">/nomcom/defaults/position/header_questionnaire.txt</field>
<field type="CharField" name="title">Header of the email that contains the questionnaire sent to the nomine</field>
<field type="TextField" name="variables">$nominee: Full name of the nomine
$position: Position</field>
<field to="name.dbtemplatetypename" name="type" rel="ManyToOneRel">plain</field>
<field type="TextField" name="content">Hi $nominee, this is the questionnaire for the position $position:
</field>
<field to="group.group" name="group" rel="ManyToOneRel"><None></None></field>
</object>
</django-objects>

View file

@ -10,22 +10,22 @@
<dt>Group</dt>
<dd>{{ template.group }}</dd>
<dt>Template type</dt>
<dd>{{ template.get_template_type_display }}
{% ifequal template.template_type "rst" %}
<dd>{{ template.type.name }}
{% ifequal template.type.slug "rst" %}
<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>
<p>You can do variable interpolation with $varialbe if the template allows any variable.</p>
{% endifequal %}
{% ifequal template.template_type "django" %}
{% ifequal template.type.slug "django" %}
<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>
<p>You can do variable interpolation with the current django markup &#123;&#123;variable&#125;&#125; if the template allows any variable.</p>
{% endifequal %}
{% ifequal template.template_type "plain" %}
{% ifequal template.type.slug "plain" %}
<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>
{% endifequal %}
</dd>
{% if template.help_text %}
<dt>Extra info about this template</dt>
<dd>{{ template.help_text }}</dd>
{% if template.variables %}
<dt>Variables allowed in this template</dt>
<dd>{{ template.variables|linebreaks }}</dd>
{% endif %}
</dl>

View file

@ -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)

View file

@ -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):

View file

@ -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)

View file

@ -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,