From fc69b6851dcf61ebf35a66d16ca84475b378e0b8 Mon Sep 17 00:00:00 2001 From: "Langhammer, Jens" Date: Fri, 11 Oct 2019 12:47:06 +0200 Subject: [PATCH] core(minor): tags -> attributes, add attributes to user, add propertymappings to source --- passbook/admin/forms/users.py | 2 +- passbook/core/forms/groups.py | 2 +- .../migrations/0003_auto_20191011_0914.py | 29 +++++++++++++++++++ passbook/core/models.py | 5 +++- 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 passbook/core/migrations/0003_auto_20191011_0914.py diff --git a/passbook/admin/forms/users.py b/passbook/admin/forms/users.py index d6ef9a084..c150071a1 100644 --- a/passbook/admin/forms/users.py +++ b/passbook/admin/forms/users.py @@ -11,7 +11,7 @@ class UserForm(forms.ModelForm): class Meta: model = User - fields = ['username', 'name', 'email', 'is_staff', 'is_active'] + fields = ['username', 'name', 'email', 'is_staff', 'is_active', 'attributes'] widgets = { 'name': forms.TextInput } diff --git a/passbook/core/forms/groups.py b/passbook/core/forms/groups.py index 3a776cd17..e57240f09 100644 --- a/passbook/core/forms/groups.py +++ b/passbook/core/forms/groups.py @@ -26,7 +26,7 @@ class GroupForm(forms.ModelForm): class Meta: model = Group - fields = ['name', 'parent', 'members', 'tags'] + fields = ['name', 'parent', 'members', 'attributes'] widgets = { 'name': forms.TextInput(), } diff --git a/passbook/core/migrations/0003_auto_20191011_0914.py b/passbook/core/migrations/0003_auto_20191011_0914.py new file mode 100644 index 000000000..8321f1a0b --- /dev/null +++ b/passbook/core/migrations/0003_auto_20191011_0914.py @@ -0,0 +1,29 @@ +# Generated by Django 2.2.6 on 2019-10-11 09:14 + +import django.contrib.postgres.fields.jsonb +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('passbook_core', '0002_nonce_description'), + ] + + operations = [ + migrations.RenameField( + model_name='group', + old_name='tags', + new_name='attributes', + ), + migrations.AddField( + model_name='source', + name='property_mappings', + field=models.ManyToManyField(blank=True, default=None, to='passbook_core.PropertyMapping'), + ), + migrations.AddField( + model_name='user', + name='attributes', + field=django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict), + ), + ] diff --git a/passbook/core/models.py b/passbook/core/models.py index 4b413151e..294a18cd4 100644 --- a/passbook/core/models.py +++ b/passbook/core/models.py @@ -32,7 +32,7 @@ class Group(UUIDModel): name = models.CharField(_('name'), max_length=80) parent = models.ForeignKey('Group', blank=True, null=True, on_delete=models.SET_NULL, related_name='children') - tags = JSONField(default=dict, blank=True) + attributes = JSONField(default=dict, blank=True) def __str__(self): return f"Group {self.name}" @@ -51,6 +51,8 @@ class User(AbstractUser): groups = models.ManyToManyField('Group') password_change_date = models.DateTimeField(auto_now_add=True) + attributes = JSONField(default=dict, blank=True) + def set_password(self, password): if self.pk: password_changed.send(sender=self, user=self, password=password) @@ -143,6 +145,7 @@ class Source(PolicyModel): name = models.TextField() slug = models.SlugField() enabled = models.BooleanField(default=True) + property_mappings = models.ManyToManyField('PropertyMapping', default=None, blank=True) form = '' # ModelForm-based class ued to create/edit instance