misc: add role details to substitution variables (#10531)

This commit is contained in:
Frédéric Péters 2017-01-13 14:15:55 +01:00
parent 054f757e8b
commit 1123e28132
3 changed files with 7 additions and 0 deletions

View File

@ -242,6 +242,10 @@ champs, etc.
<td><p><code>form_role_receiver_emails</code></p></td>
<td><p>Les adresses électroniques associées au rôle en charge du traitement</p></td>
</tr>
<tr>
<td><p><code>form_role_receiver_details</code></p></td>
<td><p>La description (« détail du rôle ») associée au rôle en charge du traitement</p></td>
</tr>
</table>
</section>

View File

@ -1474,6 +1474,7 @@ def test_workflow_roles(pub):
Role.wipe()
role1 = Role(name='foo')
role1.emails = ['foo@localhost']
role1.details = 'Hello World'
role1.store()
role2 = Role(name='bar')
@ -1517,6 +1518,7 @@ def test_workflow_roles(pub):
substvars = formdata.get_substitution_variables()
assert substvars.get('form_role_other_name') == 'bar'
assert substvars.get('form_role_slug_with_dash_name') == 'foo'
assert substvars.get('form_role_slug_with_dash_details') == 'Hello World'
def test_criticality(pub):
FormDef.wipe()

View File

@ -74,6 +74,7 @@ class Role(StorableObject):
def get_substitution_variables(self, prefix=''):
data = {}
data[prefix + 'name'] = self.name
data[prefix + 'details'] = self.details or ''
if self.emails and not self.emails_to_members:
data[prefix + 'emails'] = ', '.join(self.emails)
return data