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

Early November update #924

Merged
merged 79 commits into from
Nov 4, 2024
Merged
Changes from 1 commit
Commits
Show all changes
79 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
527d0c2
Endpoint for sending email (#883)
EmilJohns1 Sep 26, 2024
d0a0c07
chore(deps): bump black from 24.3.0 to 24.8.0 (#869)
dependabot[bot] Sep 27, 2024
81f7c7e
chore(deps): Bump azure-storage-blob from 12.13.1 to 12.23.1 (#885)
dependabot[bot] Sep 30, 2024
019d273
Added admin.py to root in new app, and added app dir to tests (#892)
MadsNyl Oct 1, 2024
14edd06
Description to forms (#894)
MadsNyl Oct 1, 2024
1a49b08
Bug report system (#865)
josefinearntsen Oct 11, 2024
1393885
Renaming of index app to feedback (#901)
MadsNyl Oct 11, 2024
c44e910
chore(deps): bump django from 4.2.16 to 5.1.1 (#889)
dependabot[bot] Oct 11, 2024
17b2483
Event registration race condition (#902)
MadsNyl Oct 11, 2024
119bbdb
upadted CHANGELOG.md
MadsNyl Oct 11, 2024
0e053d4
Feat(registration)/filter participants (#895)
yazanzarka1 Oct 28, 2024
07a2ab5
Feat(registration)/filter participants (#915)
yazanzarka1 Oct 28, 2024
ef656d3
Fix issue where full error is exposed to external users (#914)
Tmpecho Oct 28, 2024
02bb209
chore(deps): Bump sentry-sdk from 2.8.0 to 2.14.0 (#893)
dependabot[bot] Oct 28, 2024
e690181
Refactor/minor code cleanup (#884)
Tmpecho Oct 28, 2024
2bff09a
Add default detail to custom exceptions (#916)
Tmpecho Oct 28, 2024
ca5eb3a
chore(deps): bump uvicorn from 0.30.6 to 0.32.0 (#908)
dependabot[bot] Oct 29, 2024
95965cb
chore(deps): Bump pre-commit from 3.8.0 to 4.0.1 (#899)
dependabot[bot] Oct 29, 2024
b5670f0
Feat(registration)/filter participants (#917)
yazanzarka1 Oct 29, 2024
a2185c6
merge
MadsNyl Nov 4, 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
Prev Previous commit
Next Next commit
Feat(kontres)/add approved by (#786)
* added approved by field

* endpoint will now set approved by

* serializer will return full user object in approved_by_detail

* created test for approved by

* migration

* remove unnecessary code

* removed write-only field in approved-by context
  • Loading branch information
eriskjel authored Apr 6, 2024
commit c9b597580c3b73e4b0e70f1f0bc30b602601be62
27 changes: 27 additions & 0 deletions app/kontres/migrations/0008_reservation_approved_by.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 4.2.5 on 2024-04-06 09:39

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("kontres", "0007_bookableitem_image_bookableitem_image_alt"),
]

operations = [
migrations.AddField(
model_name="reservation",
name="approved_by",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="approved_reservations",
to=settings.AUTH_USER_MODEL,
),
),
]
7 changes: 7 additions & 0 deletions app/kontres/models/reservation.py
Original file line number Diff line number Diff line change
@@ -53,6 +53,13 @@ class Reservation(BaseModel, BasePermissionModel):
null=True,
blank=True,
)
approved_by = models.ForeignKey(
User,
on_delete=models.SET_NULL,
related_name="approved_reservations",
null=True,
blank=True,
)

def __str__(self):
return f"{self.state} - Reservation request by {self.author.first_name} {self.author.last_name} to book {self.bookable_item.name}. Created at {self.created_at}"
2 changes: 2 additions & 0 deletions app/kontres/serializer/reservation_seralizer.py
Original file line number Diff line number Diff line change
@@ -36,6 +36,8 @@ class ReservationSerializer(serializers.ModelSerializer):
)
sober_watch_detail = UserSerializer(source="sober_watch", read_only=True)

approved_by_detail = UserSerializer(source="approved_by", read_only=True)

class Meta:
model = Reservation
fields = "__all__"
12 changes: 11 additions & 1 deletion app/kontres/views/reservation.py
Original file line number Diff line number Diff line change
@@ -58,7 +58,17 @@ def update(self, request, *args, **kwargs):
reservation = self.get_object()
serializer = self.get_serializer(reservation, data=request.data, partial=True)
serializer.is_valid(raise_exception=True)
serializer.save()

# Check if the state is being updated to CONFIRMED and set approved_by
if (
"state" in serializer.validated_data
and serializer.validated_data["state"] == ReservationStateEnum.CONFIRMED
and reservation.state != ReservationStateEnum.CONFIRMED
):
serializer.save(approved_by=request.user)
else:
serializer.save()

return Response(serializer.data, status=status.HTTP_200_OK)

def destroy(self, request, *args, **kwargs):
19 changes: 19 additions & 0 deletions app/tests/kontres/test_reservation_integration.py
Original file line number Diff line number Diff line change
@@ -237,6 +237,25 @@ def test_admin_can_edit_reservation_to_confirmed(reservation, admin_user):
assert response.data["state"] == ReservationStateEnum.CONFIRMED


@pytest.mark.django_db
def test_admin_can_approve_reservation_and_approved_by_is_set(reservation, admin_user):
client = get_api_client(user=admin_user)
assert reservation.state == ReservationStateEnum.PENDING
assert reservation.approved_by is None

response = client.put(
f"/kontres/reservations/{reservation.id}/",
{"state": "CONFIRMED"},
format="json",
)

reservation.refresh_from_db()

assert response.status_code == 200
assert reservation.state == ReservationStateEnum.CONFIRMED
assert response.data["approved_by_detail"]["user_id"] == str(admin_user.user_id)


@pytest.mark.django_db
def test_admin_can_edit_reservation_to_cancelled(reservation, admin_user):
client = get_api_client(user=admin_user)