Merge pull request #5172 from tsiegleauq/fix-group-creation
Fix group creation
This commit is contained in:
commit
b9e40717de
@ -159,7 +159,9 @@ class GroupSerializer(ModelSerializer):
|
|||||||
Serializer for django.contrib.auth.models.Group objects.
|
Serializer for django.contrib.auth.models.Group objects.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
permissions = PermissionRelatedField(many=True, queryset=Permission.objects.all())
|
permissions = PermissionRelatedField(
|
||||||
|
many=True, queryset=Permission.objects.all(), required=False
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Group
|
model = Group
|
||||||
|
@ -705,6 +705,18 @@ class GroupCreate(TestCase):
|
|||||||
Tests creation of groups via REST API.
|
Tests creation of groups via REST API.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def test_creation_simple(self):
|
||||||
|
self.client.login(username="admin", password="admin")
|
||||||
|
|
||||||
|
response = self.client.post(
|
||||||
|
reverse("group-list"), {"name": "Test name ldr59xq2mvt96rdayhju"},
|
||||||
|
)
|
||||||
|
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
|
||||||
|
self.assertTrue(
|
||||||
|
Group.objects.filter(name="Test name ldr59xq2mvt96rdayhju").exists()
|
||||||
|
)
|
||||||
|
|
||||||
def test_creation(self):
|
def test_creation(self):
|
||||||
self.client.login(username="admin", password="admin")
|
self.client.login(username="admin", password="admin")
|
||||||
# This contains two valid permissions of the users app.
|
# This contains two valid permissions of the users app.
|
||||||
|
Loading…
Reference in New Issue
Block a user