Skip to content

Commit

Permalink
Late September Update (#879)
Browse files Browse the repository at this point in the history
* Feat(kontres)/add image to bookable item (#785)

* added optional image to bookable item model

* added update method in serializer to handle new images

* linting

* remove update method for images

* 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

* Create minutes for Codex (#787)

* init

* format

* Feat(minute)/viewset (#788)

* added richer reponse on post and put

* added to admin panel

* added filter for minute

* Feat(kontres)/add notification (#790)

* created methods for sending notification to admin and user

* endpoint will now send notification if needed

* add migrations for new notification types

* Memberships with fines activated (#791)

init

* Feat(user)/user bio (#758)

* Created model, serializer and view for user-bio

* Created user bio model and made migrations

* Created user bio serializer + viewsets + added new endpoint

* Tested create method + added bio serializer to user serializer

* Format

* Created update method and started testing

* Debugging test failures in user retrieve

* fixed model error

* Created user_bio_factory + started testing put method

* Created fixture for UserBio

* Created custom excpetion for duplicate user bio

* Added permissions and inherited from BaseModel

* Modularized serializer for bio

* Use correct serializers in viewset + added destroy method

* Finished testing bio viewset integration + format

* Changed environent file to .env to avoid pushing up keys

* Fix: Flipped assertion statement in test, since user bio should not be deleted

* skiped buggy test from kontres

* added mark to pytest.skip

* Moved keys to .env file and reverted docker variables

* Skip buggy kontres test

* format

* Added str method to user_bio

* Removed unused imports

* format

* Changed user relation to a OneToOne-field (same affect as ForeignKey(unique=True) + removed check for duplicate bio in serializer

* Migrations + changed assertion status code in duplicate bio test (could try catch in serializer to produce 400 status code)

* format

* format

* Changed limit for description 50 -> 500 + migrations

* Migrate

* added id to serializer

* merged leaf nodes in migrations

* format

---------

Co-authored-by: Ester2109 <[email protected]>
Co-authored-by: Mads Nylund <[email protected]>
Co-authored-by: Mads Nylund <[email protected]>
Co-authored-by: Tam Le <[email protected]>

* Update CHANGELOG.md

* added filter for allowed photos for user (#794)

added filter for allowed photos

* Upped payment time when coming from waiting list (#796)

* fixed paymenttime saved to db (#798)

* fixed bug (#800)

* Disallow users to unregister when payment is done (#802)

added 400 status code for deleting paid registration

* update changelog

* Added serializer for category in  event (#804)

added serializer for category in  event

* Permission middelware (#806)

* added a check for existing user and id on request

* format

* Permission refactor of QR Codes (#807)

* added permissions to qr code and refactored viewset

* format

* removed unused imports

* Permissions for payment orders (#808)

* added read permissions

* added permissions for payment order and tests

* format

* chore(iac): updated docs and force https (#810)

chore: updated docs and force https

* feat(iac): add terraform guardrails so index don't nuke our infra (#811)

feat: add guardrails so index don't fup

* Automatic registration for new users with Feide (#809)

* started on feide registration endpoint

* made endpoint for creating user with Feide

* added test for parse group

* finished

* format

* removes three years if in digtrans

* changelog update

* Feide env variables Terraform (#814)

added feid env variables

* added delete endpoint for file (#815)

* added delete endpoint for file

* Trigger Build

* changed workflow to checkout v4

* changed from docker-compose to docker compose

* Update CHANGELOG.md

* format

* format

* fixed permission for committee leaders for group forms

* updated csv for forms (#818)

* Permission for group forms and news (#820)

added permission for committees to create news, and all leaders of groups to create group forms

* Update reservation_seralizer.py (#822)

* Update reservation_seralizer.py

* Fixed linting

* Put a band aid on it *smack*

* Removed blank line..

* ????

* Group ownership of Minutes (#847)

* Refactor MinuteFactory to include group field, and added validation for checkin group access

* added validation for POST request

* Changed endpoint response (#846)

* Changed endpoint response

* Fixed test

* Update test_reservation_integration.py

---------

Co-authored-by: Mads Nylund <[email protected]>

* updated changelog.md

* finished events now appear in the correct order (newest first) (#849)

* finished events now appear in the correct order (newest first)

* added description of change in changelog

* fixed formatting

* updated method to use Django ORM instead of using python methods

* Implement Swagger (#858)

* started on removing choiceenums

* refactored cheatsheet and membership

* refacotered strike enum

* refactored Groups enum

* removed AppModel choiceenum

* added swagger

* Swagger GitHub Action (#860)

* added github action for checking if Swagger is up

* new action

* try another

* tried implementing check for container

* added curl to docker image

* added check if swagger is up

* test if swagger does not get status code 200

* added ?format=openai to trigger error

* checking that the request is working

* updated CHANGELOG.md

* Add new app (#862)

* added script for adding new app to Lepton

* added command to Makefile

* Upgrade all dependencies to latest (#857)

* Add endpoint to create new group as admin

Signed-off-by: Tmpecho <[email protected]>

* Upgrade all dependencies to latest

Signed-off-by: Tmpecho <[email protected]>

* remove bad exception handling in serializers/group.py

* fix inheritance ordering in views/group.py

* refactored group integration test, added non_public_groups to enums

* fix linting

* reformat files

* remove unused import in groups/views/group.py

* Upgrade dependency "black"

Signed-off-by: Tmpecho <[email protected]>

* Upgrade dependency "sentry-sdk"

Signed-off-by: Tmpecho <[email protected]>

* Upgrade dependency "azure-storage-blob" and remove outdated comment in requirements.txt

Signed-off-by: Tmpecho <[email protected]>

* Upgrade all non-django dependencies

Signed-off-by: Tmpecho <[email protected]>

* Upgrade dependency "Django"

Signed-off-by: Tmpecho <[email protected]>

* Upgrade dependencies and remove ignored version from docker-compose.yml

Signed-off-by: Tmpecho <[email protected]>

---------

Signed-off-by: Tmpecho <[email protected]>
Co-authored-by: 1Cezzo <[email protected]>

* Allow HS members to create a new group (#864)

* Add endpoint to create new group as admin

Signed-off-by: Tmpecho <[email protected]>

* remove bad exception handling in serializers/group.py

* fix inheritance ordering in views/group.py

* refactored group integration test, added non_public_groups to enums

* fix linting

* reformat files

* remove unused import in groups/views/group.py

---------

Signed-off-by: Tmpecho <[email protected]>
Co-authored-by: 1Cezzo <[email protected]>

* App Script Fix (#875)

added serializers dir to script

* Event registration payment orders (#876)

* added list of payment orders for registrations

* update CHANGELOG.md

* chore(deps): update python-dotenv requirement from ~=0.21.1 to ~=1.0.1 (#871)

Updates the requirements on [python-dotenv](https://github.com/theskumar/python-dotenv) to permit the latest version.
- [Release notes](https://github.com/theskumar/python-dotenv/releases)
- [Changelog](https://github.com/theskumar/python-dotenv/blob/main/CHANGELOG.md)
- [Commits](theskumar/python-dotenv@v0.21.1...v1.0.1)

---
updated-dependencies:
- dependency-name: python-dotenv
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mads Nylund <[email protected]>

* Chore(deps): Bump sentry-sdk from 1.14.0 to 2.8.0 (#866)

Bumps [sentry-sdk](https://github.com/getsentry/sentry-python) from 1.14.0 to 2.8.0.
- [Release notes](https://github.com/getsentry/sentry-python/releases)
- [Changelog](https://github.com/getsentry/sentry-python/blob/master/CHANGELOG.md)
- [Commits](getsentry/sentry-python@1.14.0...2.8.0)

---
updated-dependencies:
- dependency-name: sentry-sdk
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mads Nylund <[email protected]>

* Codex Course (#852)

* added models for course and registration, and viewset for course and tests

* added validation for date checking for courses

* added viewset for registration for codex courses

* removed unused fields from course model

* removed unused imports

* added API error mixins as mother clas

* fixed error mixin

* refactored to event model

* fixed wrong import

* fixed tests

* format

* skipped broken tests, must be refactored

* updated CHANGELOG.md

* format

---------

Signed-off-by: Tmpecho <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Erik Skjellevik <[email protected]>
Co-authored-by: haruixu <[email protected]>
Co-authored-by: Ester2109 <[email protected]>
Co-authored-by: Tam Le <[email protected]>
Co-authored-by: martcl <[email protected]>
Co-authored-by: Frikk Balder <[email protected]>
Co-authored-by: Emil Johnsen <[email protected]>
Co-authored-by: Johannes Aamot-Skeidsvoll <[email protected]>
Co-authored-by: 1Cezzo <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
11 people authored Sep 25, 2024
1 parent 07ac32a commit 2ad96e2
Show file tree
Hide file tree
Showing 109 changed files with 2,013 additions and 229 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,40 @@ jobs:
- name: Check for unstaged migrations
run: docker compose run --rm web python manage.py makemigrations --check --no-input

- name: Tear down the Stack
run: docker compose down

swagger:
runs-on: ubuntu-latest
steps:

- name: Checkout Code Repository
uses: actions/checkout@v4

- name: Build the Stack
run: docker compose build

- name: Run the Stack
run: docker compose up -d

- name: Wait for Docker container to be up
run: |
retries=10
until docker compose exec web curl -f http://localhost:8000/ || [ $retries -eq 0 ]; do
echo "Waiting for container to be up..."
retries=$((retries - 1))
sleep 5
done
- name: Make HTTP Request to Swagger
run: |
status_code=$(curl -o /dev/null -s -w "%{http_code}" http://localhost:8000/swagger/?format=openapi)
if [ "$status_code" -eq 200 ]; then
echo "Swagger UI is up"
else
echo "Failed to reach Swagger UI, status code: $status_code"
exit 1
fi
- name: Tear down the Stack
run: docker compose down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# CHANGELOG

## Tegnforklaring
Expand All @@ -14,6 +15,15 @@

## Neste versjon

## Versjon 2024.09.25

-**Codex arrangementer**. Det kan nå opprettes arrangementer på Codex, som medlemmer av Codex kan melde seg på.
-**Betalingsordre**. Man kan nå se historikk over betalingsordre for en påmelding til et arrangement.
-**Gruppe**. HS kan nå opprette en ny gruppe.
-**Swagger**. La til en GitHub Action for å verifisere at Swagger er oppe og går.
-**Swagger**. API dokumentasjon er nå tilgjengelig med Swagger.
-**Profil**. Endret rekkefølge på tidligere arrangementer slik at nyeste kommer først.

## Versjon 2024.09.14
-**Codex**. Det er nå et skille mellom dokumenter opprettet av Drift og Index.

Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ createsuperuser: ## Create a new django superuser

.PHONY: makemigrations
makemigrations: ## Create migration files
docker compose run --rm web python manage.py makemigrations
docker compose run --rm web python manage.py makemigrations ${args}

.PHONY: migrate
migrate: ## Run django migrations
Expand Down Expand Up @@ -96,4 +96,8 @@ pr: ## Pull Request format and checks

.PHONY: shell
shell: ## Open an interactive Django shell
docker compose run --rm web python manage.py shell
docker compose run --rm web python manage.py shell

.PHONY: app
app: ## Create a new Django app
python scripts/app.py
2 changes: 1 addition & 1 deletion app/badge/filters/badge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from app.badge.models import BadgeCategory, UserBadge
from app.badge.models.badge import Badge
from app.common.enums import GroupType
from app.common.enums import NativeGroupType as GroupType
from app.content.models import User
from app.group.models.membership import Membership

Expand Down
Empty file added app/codex/__init__.py
Empty file.
1 change: 1 addition & 0 deletions app/codex/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from app.codex.admin import admin
7 changes: 7 additions & 0 deletions app/codex/admin/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin

from app.codex.models.event import CodexEvent
from app.codex.models.registration import CodexEventRegistration

admin.site.register(CodexEvent)
admin.site.register(CodexEventRegistration)
Empty file added app/codex/apps.py
Empty file.
23 changes: 23 additions & 0 deletions app/codex/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django.db import models


class CodexGroups(models.TextChoices):
DRIFT = "Drift"
INDEX = "Index"

@classmethod
def all(cls) -> list:
return [cls.DRIFT, cls.INDEX]

@classmethod
def reverse(cls) -> list:
return [cls.INDEX, cls.DRIFT]


class CodexEventTags(models.TextChoices):
WORKSHOP = "Workshop"
LECTURE = "Lecture"

@classmethod
def all(cls) -> list:
return [cls.WORKSHOP, cls.LECTURE]
24 changes: 24 additions & 0 deletions app/codex/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from rest_framework import status
from rest_framework.exceptions import APIException


class APICodexEventEndRegistrationDateAfterStartDate(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = (
"Sluttdatoen for påmelding kan ikke være etter startdatoen for kurset"
)


class APICodexEventEndRegistrationDateBeforeStartRegistrationDate(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = (
"Sluttdatoen for påmelding kan ikke være før startdatoen for påmelding"
)


class CodexEventEndRegistrationDateAfterStartDate(ValueError):
pass


class CodexEventEndRegistrationDateBeforeStartRegistrationDate(ValueError):
pass
2 changes: 2 additions & 0 deletions app/codex/factories/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from app.codex.factories.event import CodexEventFactory
from app.codex.factories.registration import CodexEventRegistrationFactory
20 changes: 20 additions & 0 deletions app/codex/factories/event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from datetime import timedelta

from django.utils import timezone

import factory
from factory.django import DjangoModelFactory

from app.codex.models.event import CodexEvent


class CodexEventFactory(DjangoModelFactory):
class Meta:
model = CodexEvent

title = factory.Sequence(lambda n: f"Event {n}")
description = factory.Faker("text")
start_date = timezone.now() + timedelta(days=10)

start_registration_at = timezone.now() - timedelta(days=1)
end_registration_at = timezone.now() + timedelta(days=9)
15 changes: 15 additions & 0 deletions app/codex/factories/registration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import factory
from factory.django import DjangoModelFactory

from app.codex.factories.event import CodexEventFactory
from app.codex.models.registration import CodexEventRegistration
from app.content.factories.user_factory import UserFactory


class CodexEventRegistrationFactory(DjangoModelFactory):
class Meta:
model = CodexEventRegistration

user = factory.SubFactory(UserFactory)
event = factory.SubFactory(CodexEventFactory)
order = 0
1 change: 1 addition & 0 deletions app/codex/filters/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from app.codex.filters.event import CodexEventFilter
20 changes: 20 additions & 0 deletions app/codex/filters/event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django_filters.rest_framework import (
DateTimeFilter,
FilterSet,
OrderingFilter,
)

from app.codex.models.event import CodexEvent


class CodexEventFilter(FilterSet):
"""Filters events by tag and expired. Works with search query"""

end_range = DateTimeFilter(field_name="start_date", lookup_expr="lte")
start_range = DateTimeFilter(field_name="end_date", lookup_expr="gte")

ordering = OrderingFilter("start_date", "tag")

class Meta:
model = CodexEvent
fields = ["tag", "end_range", "start_range", "organizer"]
123 changes: 123 additions & 0 deletions app/codex/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Generated by Django 4.2.16 on 2024-09-24 16:44

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


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("group", "0020_alter_membership_membership_type_and_more"),
]

operations = [
migrations.CreateModel(
name="CodexEvent",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("title", models.CharField(max_length=255)),
("description", models.TextField(blank=True, default="")),
("start_date", models.DateTimeField()),
(
"start_registration_at",
models.DateTimeField(blank=True, default=None, null=True),
),
(
"end_registration_at",
models.DateTimeField(blank=True, default=None, null=True),
),
(
"tag",
models.CharField(
choices=[("Workshop", "Workshop"), ("Lecture", "Lecture")],
default="Lecture",
max_length=50,
),
),
("location", models.CharField(max_length=200, null=True)),
("mazemap_link", models.URLField(max_length=2000, null=True)),
(
"lecturer",
models.ForeignKey(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="codex_events",
to=settings.AUTH_USER_MODEL,
),
),
(
"organizer",
models.ForeignKey(
blank=True,
default=None,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="codex_events",
to="group.group",
),
),
],
options={
"verbose_name_plural": "Events",
"ordering": ("start_date",),
},
),
migrations.CreateModel(
name="CodexEventRegistration",
fields=[
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
(
"registration_id",
models.AutoField(primary_key=True, serialize=False),
),
("order", models.IntegerField(default=0)),
(
"event",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="codex_event_registrations",
to="codex.codexevent",
),
),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="codex_event_registrations",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"ordering": ("order", "created_at"),
"unique_together": {("user", "event")},
},
),
migrations.AddField(
model_name="codexevent",
name="registrations",
field=models.ManyToManyField(
blank=True,
default=None,
through="codex.CodexEventRegistration",
to=settings.AUTH_USER_MODEL,
),
),
]
Empty file.
17 changes: 17 additions & 0 deletions app/codex/mixins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from app.codex.exceptions import (
APICodexEventEndRegistrationDateAfterStartDate,
APICodexEventEndRegistrationDateBeforeStartRegistrationDate,
CodexEventEndRegistrationDateAfterStartDate,
CodexEventEndRegistrationDateBeforeStartRegistrationDate,
)
from app.util.mixins import APIErrorsMixin


class APICodexEventErrorsMixin(APIErrorsMixin):
@property
def expected_exceptions(self):
return {
**super().expected_exceptions,
CodexEventEndRegistrationDateAfterStartDate: APICodexEventEndRegistrationDateAfterStartDate,
CodexEventEndRegistrationDateBeforeStartRegistrationDate: APICodexEventEndRegistrationDateBeforeStartRegistrationDate,
}
Empty file added app/codex/models/__init__.py
Empty file.
Loading

0 comments on commit 2ad96e2

Please sign in to comment.