Fix group creation

Fixes an error that was preventing groups from being created.
Groups did require a list of permissions which is now optional
This commit is contained in:
Sean Engelhardt 2020-01-08 10:46:11 +01:00
parent a2d561f667
commit 5f8e64140a
2 changed files with 15 additions and 1 deletions

View File

@ -159,7 +159,9 @@ class GroupSerializer(ModelSerializer):
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:
model = Group

View File

@ -705,6 +705,18 @@ class GroupCreate(TestCase):
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):
self.client.login(username="admin", password="admin")
# This contains two valid permissions of the users app.