From cfcbf309330d23b1f07a68d3ee1be1bdd310e41b Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 5 Jan 2016 16:56:06 +0100 Subject: [PATCH 1/5] role_forms: add a details field (#9503) --- hobo/agent/authentic2/migrations/0001_initial.py | 28 ++++++++++++++++++++++++ hobo/agent/authentic2/migrations/__init__.py | 0 hobo/agent/authentic2/role_forms.py | 3 +++ 3 files changed, 31 insertions(+) create mode 100644 hobo/agent/authentic2/migrations/0001_initial.py create mode 100644 hobo/agent/authentic2/migrations/__init__.py diff --git a/hobo/agent/authentic2/migrations/0001_initial.py b/hobo/agent/authentic2/migrations/0001_initial.py new file mode 100644 index 0000000..ad1196b --- /dev/null +++ b/hobo/agent/authentic2/migrations/0001_initial.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals +import json + +from django.db import models, migrations + +def copy_description_to_details(apps, schema_editor): + Role = apps.get_model('a2_rbac', 'Role') + for role in Role.objects.all(): + value = json.dumps(role.description) + ra, created = role.attributes.get_or_create( + name='details', kind='json', defaults={ + 'value': value}) + if not created: + ra.value = value + ra.save() + +def noop(apps, schema_editor):¶ + pass¶ + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + migrations.RunPython(copy_description_to_details, noop), + ] diff --git a/hobo/agent/authentic2/migrations/__init__.py b/hobo/agent/authentic2/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hobo/agent/authentic2/role_forms.py b/hobo/agent/authentic2/role_forms.py index 4674923..17c4a6c 100644 --- a/hobo/agent/authentic2/role_forms.py +++ b/hobo/agent/authentic2/role_forms.py @@ -77,6 +77,9 @@ class CommaSeparatedCharField(forms.Field): class RoleForm(RoleEditForm): + details = forms.CharField(label=_('Role details'), widget=forms.Textarea, initial='', + required=False, help_text=_('This text will be shown to users when ' + 'they are concerned by this role.')) emails = CommaSeparatedCharField(label=_('Emails'), item_validators=[EmailValidator()], required=False) -- 2.1.4