mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-10 00:56:19 +01:00
Merge remote-tracking branch 'upstream/master' into v2.9.x
This commit is contained in:
@@ -40,9 +40,6 @@ class AuthGroupInlineAdmin(admin.StackedInline):
|
||||
kwargs["queryset"] = Group.objects.order_by(Lower('name'))
|
||||
return super().formfield_for_manytomany(db_field, request, **kwargs)
|
||||
|
||||
def has_add_permission(self, request, obj=None):
|
||||
return False
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
return False
|
||||
|
||||
@@ -139,7 +136,7 @@ class GroupAdmin(admin.ModelAdmin):
|
||||
_member_count.admin_order_field = 'member_count'
|
||||
|
||||
def has_leader(self, obj):
|
||||
return obj.authgroup.group_leaders.exists()
|
||||
return obj.authgroup.group_leaders.exists() or obj.authgroup.group_leader_groups.exists()
|
||||
|
||||
has_leader.boolean = True
|
||||
|
||||
@@ -174,6 +171,13 @@ class GroupAdmin(admin.ModelAdmin):
|
||||
kwargs["queryset"] = Permission.objects.select_related("content_type").all()
|
||||
return super().formfield_for_manytomany(db_field, request, **kwargs)
|
||||
|
||||
def save_formset(self, request, form, formset, change):
|
||||
for inline_form in formset:
|
||||
ag_instance = inline_form.save(commit=False)
|
||||
ag_instance.group = form.instance
|
||||
ag_instance.save()
|
||||
formset.save()
|
||||
|
||||
|
||||
class Group(BaseGroup):
|
||||
class Meta:
|
||||
|
||||
@@ -55,7 +55,6 @@ class RequestLog(models.Model):
|
||||
return user.profile.main_character
|
||||
|
||||
|
||||
|
||||
class AuthGroup(models.Model):
|
||||
"""
|
||||
Extends Django Group model with a one-to-one field
|
||||
@@ -106,7 +105,8 @@ class AuthGroup(models.Model):
|
||||
help_text="States listed here will have the ability to join this group provided "
|
||||
"they have the proper permissions.")
|
||||
|
||||
description = models.TextField(max_length=512, blank=True, help_text="Short description <i>(max. 512 characters)</i> of the group shown to users.")
|
||||
description = models.TextField(max_length=512, blank=True, help_text="Short description <i>(max. 512 characters)"
|
||||
"</i> of the group shown to users.")
|
||||
|
||||
def __str__(self):
|
||||
return self.group.name
|
||||
|
||||
@@ -48,6 +48,7 @@ class TestGroupAdmin(TestCase):
|
||||
cls.group_2 = Group.objects.create(name='Group 2')
|
||||
cls.group_2.authgroup.description = 'Internal Group'
|
||||
cls.group_2.authgroup.internal = True
|
||||
cls.group_2.authgroup.group_leader_groups.add(cls.group_1)
|
||||
cls.group_2.authgroup.save()
|
||||
|
||||
# group 3 - has leader
|
||||
@@ -237,10 +238,14 @@ class TestGroupAdmin(TestCase):
|
||||
result = self.modeladmin._member_count(obj)
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
def test_has_leader(self):
|
||||
def test_has_leader_user(self):
|
||||
result = self.modeladmin.has_leader(self.group_1)
|
||||
self.assertTrue(result)
|
||||
|
||||
def test_has_leader_group(self):
|
||||
result = self.modeladmin.has_leader(self.group_2)
|
||||
self.assertTrue(result)
|
||||
|
||||
def test_properties_1(self):
|
||||
expected = ['Default']
|
||||
result = self.modeladmin._properties(self.group_1)
|
||||
|
||||
Reference in New Issue
Block a user