Skip to content

Commit

Permalink
Mid November Update (#740)
Browse files Browse the repository at this point in the history
* refactored exception for order init error (#712)

* refactored exception for order init error

* added error when trying to update a paid event to a free event

* Refactor(paid event)/rename exception (#717)

* refactored exception for order init error

* added error when trying to update a paid event to a free event

* changed name of exception

* Trigger Build

* notification for waiting list and when coming from waiting list (#725)

* use env variable for celery broker url (#726)

* chore: use env variable for celery broker url

* chore: set default env varibale if not configured

* Give HS user permissions (#727)

* Give HS user permissions

* Fix

* Update CHANGELOG.md

* Feat(event)/waitlist (#724)

* Fix(registration)/waitlist limit (#729)

* users from wait list get bumped up if event limit is increased, and users from queue get bumped down if the limit is decreased. Priority is respected

* format

* altered test with bigger dicrease, and to test if priority is respected

* added endpotint for manually adding members to an event (#730)

* added endpotint for manually adding members to an event

* format

* made migrations

* test for registration on wait list if event is full

* Feat(qr)/qr generator (#719)

* added model for QR code, viewset and serializer

* finished create and destroy methods, and mades tests for these

* altered create viewset to take user from request

* fixed tests

* changed status code for deletion of qr code to 200 since frontend dosent accept 204 status code....

* format

* removed earlier unused method

* format

* Trigger Build

* changed exception to take all errors with making a blob

* format

* added azure key to settings file

* format

* changed name of exception for blbo not found

* altered ci.yaml file to add azure connecntion string as env

* fix ci file

* changed model to take content, and serializer not upload image to azure

* format

* added users and groups to fixture (#731)

* made it possible to add members before and after registration open time (#733)

* made it possible to add members before and after registration open time

* can add for paid event

* format

* format

* Update CHANGELOG.md

* Activity (#736)

* first version

* changed ordering for activities

* filled out categiory enum

* fixed test

* fixed test again

* Update CHANGELOG.md

---------

Co-authored-by: Martin Clementz <[email protected]>
Co-authored-by: Thomas H. Svendal <[email protected]>
Co-authored-by: Anders <[email protected]>
  • Loading branch information
4 people authored Nov 16, 2023
1 parent ca29e1a commit bbac43f
Show file tree
Hide file tree
Showing 7 changed files with 312 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-**Venteliste** Brukere på venteliste kan nå se sin egen plass på ventelisten.
-**QR Kode** Brukere kan nå generere sine egne QR koder.
-**Endring av arrangement plasser** Venteliste og liste vil nå bli automatisk oppdatert hvis man endrer på antall plasser på et arrangement.
-**Aktiviteter** Arrangementer kan nå filtreres på aktiviteter.

## Versjon 2023.10.23
-**Brukere** HS kan styre medlemmer
Expand Down
11 changes: 11 additions & 0 deletions app/content/enums.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
from django.db import models

from enumchoicefield import ChoiceEnum


class UserClass(models.IntegerChoices):
FIRST = 1
SECOND = 2
THIRD = 3
FORTH = 4
FIFTH = 5


class CategoryEnum(ChoiceEnum):
ACTIVITY = "Aktivitet"
SOSIALT = "Sosialt"
BEDPRES = "Bedpres"
KURS = "Kurs"
ANNET = "Annet"
FADDERUKA = "Fadderuka"
25 changes: 24 additions & 1 deletion app/content/views/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
)
from app.communication.notifier import Notify
from app.constants import MAIL_INDEX
from app.content.enums import CategoryEnum
from app.content.filters import EventFilter
from app.content.models import Event, User
from app.content.models import Category, Event, User
from app.content.serializers import (
EventCreateAndUpdateSerializer,
EventListSerializer,
Expand Down Expand Up @@ -60,11 +61,33 @@ def _list_queryset(self):
or "start_range" in self.request.query_params
):
return self.queryset

activity = self.request.query_params.get("activity", "false").lower() == "true"
category = Category.objects.filter(text=CategoryEnum.ACTIVITY).first()
expired = self.request.query_params.get("expired", "false").lower() == "true"

if activity and category:
return self._list_activity_queryset(category, expired, time)

if expired:
return self.queryset.filter(end_date__lt=time).order_by("-start_date")

if category:
return self.queryset.filter(end_date__gte=time).filter(
~Q(category=category)
)

return self.queryset.filter(end_date__gte=time)

def _list_activity_queryset(self, category, expired, time):
if expired:
return (
self.queryset.filter(end_date__lt=time)
.filter(category=category)
.order_by("-start_date")
)
return self.queryset.filter(end_date__gte=time).filter(category=category)

def get_serializer_class(self):
if hasattr(self, "action") and self.action == "list":
return EventListSerializer
Expand Down
273 changes: 239 additions & 34 deletions app/fixture.json

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions app/group/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ class MembershipAdmin(admin.ModelAdmin):
"user",
)

search_fields = [
"user__first_name",
"user__last_name"
]
search_fields = ["user__first_name", "user__last_name"]


@admin.register(models.MembershipHistory)
Expand Down
4 changes: 3 additions & 1 deletion app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@

DEFAULT_AUTO_FIELD = "django.db.models.AutoField"

CELERY_BROKER_URL = os.environ.get("CELERY_BROKER_URL") or "amqp://guest:guest@rabbitmq:5672"
CELERY_BROKER_URL = (
os.environ.get("CELERY_BROKER_URL") or "amqp://guest:guest@rabbitmq:5672"
)

if ENVIRONMENT == EnvironmentOptions.LOCAL:
CELERY_TASK_ALWAYS_EAGER = False
36 changes: 33 additions & 3 deletions app/tests/content/test_event_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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.content.models import Category, Event
from app.forms.enums import EventFormType
from app.forms.tests.form_factories import EventFormFactory
from app.group.factories import GroupFactory
Expand Down Expand Up @@ -170,10 +170,40 @@ def permission_test_util(


@pytest.mark.django_db
def test_list_as_anonymous_user(default_client):
"""An anonymous user should be able to list all events."""
def test_list_as_anonymous_user(default_client, event):
"""An anonymous user should be able to list all events that are not activities."""

category = Category.objects.create(text="Aktivitet")
activity = EventFactory(category=category)

activity.category = category
activity.save()

event.category = None
event.save()

response = default_client.get(API_EVENTS_BASE_URL)
assert response.status_code == 200
assert response.json().get("count") == 1


@pytest.mark.django_db
def test_list_activities_as_anonymous_user(default_client, event):
"""An anonymous user should be able to list all activities."""

category = Category.objects.create(text="Aktivitet")
activity = EventFactory(category=category)

activity.category = category
activity.save()

event.category = None
event.save()

response = default_client.get(f"{API_EVENTS_BASE_URL}?activity=true")

assert response.status_code == 200
assert response.json().get("count") == 1


@pytest.mark.django_db
Expand Down

0 comments on commit bbac43f

Please sign in to comment.