From bc14bbf3f3034945e0213aee939d30a36a5ca364 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 | 29 ++++++++++++++++++++++++ hobo/agent/authentic2/migrations/__init__.py | 0 hobo/agent/authentic2/models.py | 0 hobo/agent/authentic2/role_forms.py | 2 ++ 4 files changed, 31 insertions(+) create mode 100644 hobo/agent/authentic2/migrations/0001_initial.py create mode 100644 hobo/agent/authentic2/migrations/__init__.py create mode 100644 hobo/agent/authentic2/models.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..3265509 --- /dev/null +++ b/hobo/agent/authentic2/migrations/0001_initial.py @@ -0,0 +1,29 @@ +# -*- 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 = [ + ('a2_rbac', '0009_partial_unique_index_on_permission'), + ] + + 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/models.py b/hobo/agent/authentic2/models.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..57df140 100644 --- a/hobo/agent/authentic2/role_forms.py +++ b/hobo/agent/authentic2/role_forms.py @@ -77,6 +77,8 @@ class CommaSeparatedCharField(forms.Field): class RoleForm(RoleEditForm): + details = forms.CharField(label=_('Role details'), widget=forms.Textarea, initial='', + required=False) emails = CommaSeparatedCharField(label=_('Emails'), item_validators=[EmailValidator()], required=False) -- 2.1.4