Skip to content

Commit

Permalink
Temp Jubileum Permissions (#681)
Browse files Browse the repository at this point in the history
* Fixed flake8 (#672)

* Added Event permissions to Jubkom temporarily (#680)
  • Loading branch information
thomsen85 authored Mar 6, 2023
1 parent 4087d1e commit 6ab8032
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/common/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def admin(cls):

class Groups(ChoiceEnum):
TIHLDE = "TIHLDE"

REDAKSJONEN = "redaksjonen"
JUBKOM = "JubKom"


class AppModel(ChoiceEnum):
Expand Down
4 changes: 2 additions & 2 deletions app/content/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.core.exceptions import ValidationError
from django.db import models

from app.common.enums import AdminGroup
from app.common.enums import AdminGroup, Groups
from app.common.permissions import (
BasePermissionModel,
check_has_access,
Expand All @@ -19,7 +19,7 @@

class Event(BaseModel, OptionalImage, BasePermissionModel):

write_access = (*AdminGroup.admin(), AdminGroup.PROMO)
write_access = (*AdminGroup.admin(), AdminGroup.PROMO, Groups.JUBKOM)

title = models.CharField(max_length=200)
start_date = models.DateTimeField()
Expand Down
6 changes: 6 additions & 0 deletions app/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def member():
return user


@pytest.fixture()
def jubkom_member(member):
add_user_to_group_with_name(member, Groups.JUBKOM)
return member


@pytest.fixture()
def member_client(member):
return get_api_client(user=member)
Expand Down
12 changes: 11 additions & 1 deletion app/tests/content/test_event_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from app.common.enums import AdminGroup, GroupType, MembershipType
from app.common.enums import AdminGroup, Groups, GroupType, MembershipType
from app.content.factories import EventFactory, RegistrationFactory, UserFactory
from app.content.models import Event
from app.forms.enums import EventFormType
Expand Down Expand Up @@ -634,3 +634,13 @@ def test_expired_filter_list(api_client, admin_user, expired, expected_count):
actual_count = response.json().get("count")

assert actual_count == expected_count


@pytest.mark.django_db
def test_jubkom_has_create_permission(api_client, jubkom_member):
client = api_client(user=jubkom_member)
organizer = Group.objects.get(name=Groups.JUBKOM).slug
data = get_event_data(organizer=organizer)
response = client.post(API_EVENTS_BASE_URL, data)

assert response.status_code == status.HTTP_201_CREATED
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ omit =
[flake8]
ignore =
# Ignore the flake8-warnings that are incompatible with Black-formatting
E203, E231, W503E203, E266, E501, W503
E203, E231, E266, E501, W503
max-line-length = 80
max-complexity = 10
inline-quotes = "double"
Expand All @@ -73,4 +73,4 @@ exclude =
*/migrations

# Settings are temporarily excluded.
settings.py
settings.py

0 comments on commit 6ab8032

Please sign in to comment.