#229 Shared users mandatory on admin
* changes mandatory state of users and teams on admin backend to optional (as expected by the model) * adds team selection to admin backend
This commit is contained in:
parent
deb97fbbf3
commit
14fee4474f
@ -81,13 +81,15 @@ class EcoAccountAdmin(AbstractCompensationAdmin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
filter_horizontal = [
|
filter_horizontal = [
|
||||||
"users"
|
"users",
|
||||||
|
"teams",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_fields(self, request, obj=None):
|
def get_fields(self, request, obj=None):
|
||||||
return super().get_fields(request, obj) + [
|
return super().get_fields(request, obj) + [
|
||||||
"deductable_surface",
|
"deductable_surface",
|
||||||
"users"
|
"users",
|
||||||
|
"teams",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
26
compensation/migrations/0012_auto_20221116_1322.py
Normal file
26
compensation/migrations/0012_auto_20221116_1322.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Generated by Django 3.1.3 on 2022-11-16 12:22
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('user', '0006_auto_20220815_0759'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('compensation', '0011_ecoaccount_deductable_rest'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='ecoaccount',
|
||||||
|
name='teams',
|
||||||
|
field=models.ManyToManyField(blank=True, help_text='Teams having access (data shared with)', to='user.Team'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='ecoaccount',
|
||||||
|
name='users',
|
||||||
|
field=models.ManyToManyField(blank=True, help_text='Users having access (data shared with)', to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
]
|
@ -6,12 +6,14 @@ from ema.models import Ema
|
|||||||
|
|
||||||
class EmaAdmin(AbstractCompensationAdmin):
|
class EmaAdmin(AbstractCompensationAdmin):
|
||||||
filter_horizontal = [
|
filter_horizontal = [
|
||||||
"users"
|
"users",
|
||||||
|
"teams",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_fields(self, request, obj=None):
|
def get_fields(self, request, obj=None):
|
||||||
return super().get_fields(request, obj) + [
|
return super().get_fields(request, obj) + [
|
||||||
"users"
|
"users",
|
||||||
|
"teams",
|
||||||
]
|
]
|
||||||
|
|
||||||
admin.site.register(Ema, EmaAdmin)
|
admin.site.register(Ema, EmaAdmin)
|
||||||
|
26
ema/migrations/0008_auto_20221116_1322.py
Normal file
26
ema/migrations/0008_auto_20221116_1322.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Generated by Django 3.1.3 on 2022-11-16 12:22
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('user', '0006_auto_20220815_0759'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('ema', '0007_auto_20220815_1030'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='ema',
|
||||||
|
name='teams',
|
||||||
|
field=models.ManyToManyField(blank=True, help_text='Teams having access (data shared with)', to='user.Team'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='ema',
|
||||||
|
name='users',
|
||||||
|
field=models.ManyToManyField(blank=True, help_text='Users having access (data shared with)', to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
]
|
@ -14,7 +14,8 @@ class InterventionAdmin(BaseObjectAdmin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
filter_horizontal = [
|
filter_horizontal = [
|
||||||
"users"
|
"users",
|
||||||
|
"teams",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_fields(self, request, obj=None):
|
def get_fields(self, request, obj=None):
|
||||||
@ -25,6 +26,7 @@ class InterventionAdmin(BaseObjectAdmin):
|
|||||||
"checked",
|
"checked",
|
||||||
"recorded",
|
"recorded",
|
||||||
"users",
|
"users",
|
||||||
|
"teams",
|
||||||
"geometry",
|
"geometry",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
26
intervention/migrations/0008_auto_20221116_1322.py
Normal file
26
intervention/migrations/0008_auto_20221116_1322.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Generated by Django 3.1.3 on 2022-11-16 12:22
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('user', '0006_auto_20220815_0759'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('intervention', '0007_auto_20220815_1030'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='intervention',
|
||||||
|
name='teams',
|
||||||
|
field=models.ManyToManyField(blank=True, help_text='Teams having access (data shared with)', to='user.Team'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='intervention',
|
||||||
|
name='users',
|
||||||
|
field=models.ManyToManyField(blank=True, help_text='Users having access (data shared with)', to=settings.AUTH_USER_MODEL),
|
||||||
|
),
|
||||||
|
]
|
@ -434,8 +434,16 @@ class CheckableObjectMixin(models.Model):
|
|||||||
|
|
||||||
class ShareableObjectMixin(models.Model):
|
class ShareableObjectMixin(models.Model):
|
||||||
# Users having access on this object
|
# Users having access on this object
|
||||||
users = models.ManyToManyField("user.User", help_text="Users having access (data shared with)")
|
users = models.ManyToManyField(
|
||||||
teams = models.ManyToManyField("user.Team", help_text="Teams having access (data shared with)")
|
"user.User",
|
||||||
|
help_text="Users having access (data shared with)",
|
||||||
|
blank=True
|
||||||
|
)
|
||||||
|
teams = models.ManyToManyField(
|
||||||
|
"user.Team",
|
||||||
|
help_text="Teams having access (data shared with)",
|
||||||
|
blank=True
|
||||||
|
)
|
||||||
access_token = models.CharField(
|
access_token = models.CharField(
|
||||||
max_length=255,
|
max_length=255,
|
||||||
null=True,
|
null=True,
|
||||||
|
Loading…
Reference in New Issue
Block a user