Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev into main #825

Merged
merged 37 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6aeef42
Feat(kontres)/add image to bookable item (#785)
eriskjel Mar 23, 2024
c9b5975
Feat(kontres)/add approved by (#786)
eriskjel Apr 6, 2024
28067fa
Create minutes for Codex (#787)
MadsNyl Apr 8, 2024
9e4ff76
Feat(minute)/viewset (#788)
MadsNyl Apr 8, 2024
0544b2f
Feat(kontres)/add notification (#790)
eriskjel Apr 10, 2024
ae483dd
Memberships with fines activated (#791)
MadsNyl Apr 12, 2024
95ef58c
fixed merge
MadsNyl Apr 13, 2024
bfa2299
Feat(user)/user bio (#758)
haruixu Apr 16, 2024
3f56496
Update CHANGELOG.md
MadsNyl Apr 16, 2024
064da8a
added filter for allowed photos for user (#794)
MadsNyl Apr 17, 2024
81a3c5e
Upped payment time when coming from waiting list (#796)
MadsNyl Apr 17, 2024
a583c45
fixed paymenttime saved to db (#798)
MadsNyl Apr 17, 2024
0f24085
fixed bug (#800)
MadsNyl Apr 17, 2024
8a3cfd4
fixed mergeconflict
MadsNyl Apr 17, 2024
e597268
Disallow users to unregister when payment is done (#802)
MadsNyl May 1, 2024
3b84765
update changelog
MadsNyl May 1, 2024
f21e0ab
Added serializer for category in event (#804)
MadsNyl May 2, 2024
e30f102
fixed merge
MadsNyl May 2, 2024
64d717c
Permission middelware (#806)
MadsNyl Jun 9, 2024
ed57afc
Permission refactor of QR Codes (#807)
MadsNyl Jun 9, 2024
ab3cf15
Permissions for payment orders (#808)
MadsNyl Jun 10, 2024
062193d
chore(iac): updated docs and force https (#810)
martcl Jul 26, 2024
23b310a
feat(iac): add terraform guardrails so index don't nuke our infra (#811)
martcl Jul 26, 2024
fa31096
Automatic registration for new users with Feide (#809)
MadsNyl Jul 30, 2024
bef294d
changelog update
MadsNyl Jul 30, 2024
4db63b5
Merge branch 'dev' of https://github.com/TIHLDE/Lepton into dev
MadsNyl Jul 30, 2024
fcce5e8
Feide env variables Terraform (#814)
MadsNyl Jul 31, 2024
514a26b
added delete endpoint for file (#815)
MadsNyl Aug 4, 2024
d3e8e9a
Update CHANGELOG.md
MadsNyl Aug 4, 2024
a02af01
merge conflict
MadsNyl Aug 4, 2024
c9bf357
format
MadsNyl Aug 4, 2024
1a7dff4
format
MadsNyl Aug 4, 2024
f086ac2
fixed permission for committee leaders for group forms
MadsNyl Aug 18, 2024
ec03558
updated csv for forms (#818)
MadsNyl Aug 18, 2024
0526f02
Permission for group forms and news (#820)
MadsNyl Aug 21, 2024
39f7cd0
merge and changelog
MadsNyl Aug 21, 2024
f40fba0
Update reservation_seralizer.py (#822)
MindChirp Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

## Neste versjon

## Versjon 2024.08.21
- ⚡**Nyheter**. Ledere av komiteer kan nå opprette nyheter.
- ⚡**Forms**. Alle ledere av grupper kan nå opprette gruppe spørreskjemaer.

## Versjon 2024.07.30
- ✨ **Feide**. Man kan nå registrere bruker automatisk med Feide.
- ✨ **Fillagring**. Man kan nå slette en fil fra Azure basert på container navn og fil navn.
Expand Down
10 changes: 9 additions & 1 deletion app/content/models/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.db import models

from app.common.enums import AdminGroup, Groups
from app.common.permissions import BasePermissionModel
from app.common.permissions import BasePermissionModel, check_has_access
from app.emoji.models.reaction import Reaction
from app.util.models import BaseModel, OptionalImage

Expand Down Expand Up @@ -33,3 +33,11 @@ def __str__(self):
@property
def website_url(self):
return f"/nyheter/{self.id}/"

@classmethod
def has_write_permission(cls, request):
if not request.user:
return False
return request.user.is_leader_of_committee or check_has_access(
cls.write_access, request
)
4 changes: 4 additions & 0 deletions app/content/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ def is_leader_of_committee(self):
group__type=GroupType.COMMITTEE, membership_type=MembershipType.LEADER
).exists()

@property
def is_leader(self):
return self.memberships.filter(membership_type=MembershipType.LEADER).exists()

def has_unanswered_evaluations(self):
return self.get_unanswered_evaluations().exists()

Expand Down
2 changes: 1 addition & 1 deletion app/forms/models/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def has_write_permission(cls, request):
return (
(group and group.has_object_group_form_permission(request))
or check_has_access(cls.write_access, request)
or request.user.is_leader_of_committee
or request.user.is_leader
)

@classmethod
Expand Down
4 changes: 2 additions & 2 deletions app/kontres/serializer/reservation_seralizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ def validate_state_change(self, data, user):
)

def validate_time_and_overlapping(self, data):

# Check if this is an update operation and if start_time is being modified.
is_update_operation = self.instance is not None
start_time_being_modified = "start_time" in data
state_being_modified = "state_change" in data

# Retrieve the start and end times from the data if provided, else from the instance.
start_time = data.get(
Expand All @@ -137,7 +137,7 @@ def validate_time_and_overlapping(self, data):
"bookable_item", self.instance.bookable_item if self.instance else None
)
# Check for overlapping reservations only if necessary fields are present
if bookable_item and start_time and end_time:
if bookable_item and start_time and end_time and not state_being_modified:
# Build the query for overlapping reservations
overlapping_reservations_query = Q(
bookable_item=bookable_item,
Expand Down
21 changes: 19 additions & 2 deletions app/tests/content/test_news_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import pytest

from app.common.enums import AdminGroup, Groups
from app.common.enums import AdminGroup, Groups, GroupType, MembershipType
from app.content.factories.news_factory import NewsFactory
from app.content.factories.user_factory import UserFactory
from app.util.test_utils import get_api_client
from app.util.test_utils import add_user_to_group_with_name, get_api_client

API_NEWS_BASE_URL = "/news/"

Expand Down Expand Up @@ -310,3 +310,20 @@ def test_destroy_returns_detail_in_response(news):
response = client.delete(url)

assert response.json().get("detail")


@pytest.mark.django_db
def test_create_news_as_leader_of_committee(member):
"""A leader of a committee should be able to create news."""
add_user_to_group_with_name(
member,
"Committee",
group_type=GroupType.COMMITTEE,
membership_type=MembershipType.LEADER,
)
client = get_api_client(user=member)
response = client.post(
_get_news_url(), {"title": "title", "header": "header", "body": "body"}
)

assert response.status_code == status.HTTP_201_CREATED
27 changes: 26 additions & 1 deletion app/tests/forms/test_group_form_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from app.common.enums import AdminGroup, GroupType, MembershipType
from app.forms.tests.form_factories import GroupFormFactory
from app.group.factories import GroupFactory, MembershipFactory
from app.util.test_utils import add_user_to_group_with_name
from app.group.models import Group
from app.util.test_utils import add_user_to_group_with_name, get_api_client

pytestmark = pytest.mark.django_db

Expand Down Expand Up @@ -234,3 +235,27 @@ def test_retrieve_specific_group_form(
response = client.get(url)

assert response.status_code == status_code


@pytest.mark.django_db
@pytest.mark.parametrize(
("group_name", "group_type"),
(
("Committee", GroupType.COMMITTEE),
("Subgroup", GroupType.SUBGROUP),
("Board", GroupType.BOARD),
("Interestgroup", GroupType.INTERESTGROUP),
),
)
def test_create_group_form_as_leader(member, group_name, group_type):
"""Test that leaders of a group can create a group form"""
add_user_to_group_with_name(
member, group_name, group_type=group_type, membership_type=MembershipType.LEADER
)
group = Group.objects.get(name=group_name)
client = get_api_client(user=member)
data = _get_form_post_data(group=group)

response = client.post(FORMS_URL, data)

assert response.status_code == status.HTTP_201_CREATED
Loading