Browse Source

HUE-8530 [organization] Add OrganizationGroups to OrganizationUser

Romain 6 năm trước cách đây
mục cha
commit
3c46e00cd6

+ 20 - 0
apps/useradmin/src/useradmin/migrations/0002_auto_20190714_0932.py

@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.20 on 2019-07-14 09:32
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('useradmin', '0001_initial'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='organizationuser',
+            name='groups',
+            field=models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='useradmin.OrganizationGroup', verbose_name='groups'),
+        ),
+    ]

+ 12 - 0
apps/useradmin/src/useradmin/models.py

@@ -155,6 +155,18 @@ if ENABLE_ORGANIZATIONS.get():
       customer_id = models.CharField(_t('Customer id'), max_length=128, default=None, null=True)
       organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
 
+      groups = models.ManyToManyField(
+          OrganizationGroup,
+          verbose_name=_t('groups'),
+          blank=True,
+          help_text=_t(
+              'The groups this user belongs to. A user will get all permissions '
+              'granted to each of their groups.'
+          ),
+          related_name="user_set",
+          related_query_name="user",
+      )
+
       USERNAME_FIELD = 'email'
       REQUIRED_FIELDS = []