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

Cheatsheet List Fix #881

Merged
merged 59 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 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
1f03c30
Group ownership of Minutes (#847)
MadsNyl Sep 14, 2024
d7e9b91
Changed endpoint response (#846)
MindChirp Sep 14, 2024
b574fdc
updated changelog.md
MadsNyl Sep 14, 2024
8b83718
Merge branch 'dev' of https://github.com/TIHLDE/Lepton into dev
MadsNyl Sep 14, 2024
bf42e7a
merge
MadsNyl Sep 14, 2024
99ba049
finished events now appear in the correct order (newest first) (#849)
EmilJohns1 Sep 17, 2024
a17c46d
Implement Swagger (#858)
MadsNyl Sep 20, 2024
496d536
Swagger GitHub Action (#860)
MadsNyl Sep 21, 2024
0c1de71
Add new app (#862)
MadsNyl Sep 23, 2024
9a19163
Upgrade all dependencies to latest (#857)
Tmpecho Sep 23, 2024
f991cec
Allow HS members to create a new group (#864)
Tmpecho Sep 23, 2024
1166728
App Script Fix (#875)
MadsNyl Sep 24, 2024
0771f2d
Event registration payment orders (#876)
MadsNyl Sep 24, 2024
5b06e4e
chore(deps): update python-dotenv requirement from ~=0.21.1 to ~=1.0.…
dependabot[bot] Sep 24, 2024
01fdcc3
Chore(deps): Bump sentry-sdk from 1.14.0 to 2.8.0 (#866)
dependabot[bot] Sep 24, 2024
192e7ee
Codex Course (#852)
MadsNyl Sep 24, 2024
26fb8d1
merge conflict and update CHANGELOG.md
MadsNyl Sep 25, 2024
7d5c0f1
fixed filtering of groups and made tests
MadsNyl Sep 25, 2024
20aabb4
merge conflict
MadsNyl Sep 25, 2024
edb007f
fixed list endpoint for cheatsheets
MadsNyl Sep 25, 2024
9236863
trigger
MadsNyl Sep 25, 2024
3b9004e
format
MadsNyl Sep 25, 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
15 changes: 15 additions & 0 deletions app/common/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ def get_user_class_number(user_class: NativeUserClass) -> int:
return int(_class.split(".")[0])


def get_user_class_name(user_class: int):
if user_class == 1:
return NativeUserClass.FIRST
elif user_class == 2:
return NativeUserClass.SECOND
elif user_class == 3:
return NativeUserClass.THIRD
elif user_class == 4:
return NativeUserClass.FOURTH
elif user_class == 5:
return NativeUserClass.FIFTH
else:
return NativeUserClass.ALUMNI


# This can't be removed because it is used in the migrations. It is not used in the code
class UserStudy(ChoiceEnum):
DATAING = "Dataingeniør"
Expand Down
6 changes: 4 additions & 2 deletions app/content/views/cheatsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

from sentry_sdk import capture_exception

from app.common.enums import UserClass, UserStudy
from app.common.enums import NativeUserStudy as UserStudy
from app.common.enums import get_user_class_name
from app.common.pagination import BasePagination
from app.common.permissions import BasicViewPermission, is_admin_user
from app.common.viewsets import BaseViewSet
Expand All @@ -24,8 +25,9 @@ class CheatsheetViewSet(BaseViewSet):

def get_object(self):
if "pk" not in self.kwargs:
grade = get_user_class_name(int(self.kwargs["grade"]))
return self.filter_queryset(self.queryset).filter(
grade=UserClass(int(self.kwargs["grade"])),
grade=grade,
study=UserStudy[self.kwargs["study"]],
)

Expand Down
6 changes: 2 additions & 4 deletions app/group/filters/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ class Meta:
fields = ["type", "overview"]

def filter_type(self, queryset, _, value):
"""Django Rest does not know hot to convert incoming string values into EnumChoiceField values and we must do this manually."""
mapped = list(GroupType[v] for v in value)
return queryset.filter(type__in=mapped)
return queryset.filter(type__in=value)

def filter_overview(self, queryset, _):
def filter_overview(self, queryset, *_):
if is_admin_user(self.request):
return queryset
return queryset.filter(type__in=GroupType.public_groups())
5 changes: 3 additions & 2 deletions app/tests/content/test_cheatsheet_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ def test_list_as_anonymous_user(default_client, cheatsheet):


@pytest.mark.django_db
def test_list_as_member(cheatsheet, member):
def test_list_cheatsheets_as_member(cheatsheet, member):
"""
A member of TIHLDE should be able to list all cheatsheets.
"""
client = get_api_client(user=member)
url = _get_cheatsheet_url(cheatsheet)
response = client.get(url)
data = response.data

assert response.status_code == status.HTTP_200_OK
assert len(response.json())
assert len(data.get("results"))


@pytest.mark.django_db
Expand Down
35 changes: 35 additions & 0 deletions app/tests/groups/test_group_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from app.common.enums import AdminGroup
from app.common.enums import NativeGroupType as GroupType
from app.group.factories import GroupFactory
from app.util.test_utils import get_api_client

GROUP_URL = "/groups/"
Expand All @@ -13,6 +14,14 @@ def _get_group_url(group=None):
return f"{GROUP_URL}{group.slug}/" if (group) else f"{GROUP_URL}"


def _get_overview_group_url():
return f"{GROUP_URL}?overview=true"


def _get_group_type_filtered_list(slug: str):
return f"{GROUP_URL}?type={slug}"


def _get_group_post_data(group):
return {
"name": group.name,
Expand All @@ -38,6 +47,32 @@ def test_list_as_anonymous_user(default_client):
assert response.status_code == status.HTTP_200_OK


@pytest.mark.django_db
def test_list_overview_of_groups_as_member(member):
"""Tests if a member can list an overview of groups"""

client = get_api_client(user=member)
url = _get_overview_group_url()
response = client.get(url)

assert response.status_code == status.HTTP_200_OK


@pytest.mark.django_db
def test_list_type_of_groups_as_member(member):
"""Tests if a member can list a type of groups"""

GroupFactory(type=GroupType.BOARD)
GroupFactory(type=GroupType.COMMITTEE)

client = get_api_client(user=member)
url = _get_group_type_filtered_list(GroupType.BOARD.value)
response = client.get(url)

assert response.status_code == status.HTTP_200_OK
assert len(response.data) == 1


@pytest.mark.django_db
def test_retrieve_as_anonymous_user(default_client, group):
"""Tests if an anonymous user can retrieve a group"""
Expand Down
Loading