core(minor): tags -> attributes, add attributes to user, add propertymappings to source

This commit is contained in:
Langhammer, Jens 2019-10-11 12:47:06 +02:00
parent c782585287
commit fc69b6851d
4 changed files with 35 additions and 3 deletions

View File

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

View File

@ -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(),
}

View File

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

View File

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