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

Test #752

Merged
merged 36 commits into from
Jan 15, 2024
Merged

Test #752

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
96ecf8d
refactored exception for order init error (#712)
MadsNyl Oct 13, 2023
360abc5
Refactor(paid event)/rename exception (#717)
MadsNyl Oct 13, 2023
25b679a
notification for waiting list and when coming from waiting list (#725)
MadsNyl Oct 18, 2023
cff144e
use env variable for celery broker url (#726)
martcl Oct 19, 2023
1ddbf1f
Give HS user permissions (#727)
thomsen85 Oct 23, 2023
91aa459
Update CHANGELOG.md
MadsNyl Oct 23, 2023
f0dbfa8
Feat(event)/waitlist (#724)
lille-morille Oct 25, 2023
8112c50
Fix(registration)/waitlist limit (#729)
MadsNyl Oct 26, 2023
f5bf798
added endpotint for manually adding members to an event (#730)
MadsNyl Oct 27, 2023
1033ecd
Feat(qr)/qr generator (#719)
MadsNyl Oct 27, 2023
d297fc4
added users and groups to fixture (#731)
MadsNyl Oct 27, 2023
01357fe
made it possible to add members before and after registration open ti…
MadsNyl Nov 6, 2023
6fe59de
Update CHANGELOG.md
MadsNyl Nov 6, 2023
9a6b13c
Merge remote-tracking branch 'origin/master' into dev
MadsNyl Nov 6, 2023
db684df
Merge branch 'dev' of https://github.com/TIHLDE/Lepton into dev
MadsNyl Nov 6, 2023
ded42be
Activity (#736)
MadsNyl Nov 16, 2023
5caae41
Update CHANGELOG.md
MadsNyl Nov 16, 2023
0093727
Merge branch 'master' of https://github.com/TIHLDE/Lepton into dev
MadsNyl Nov 16, 2023
c2d8f44
Merge branch 'dev' of https://github.com/TIHLDE/Lepton into dev
MadsNyl Nov 16, 2023
9d09af3
Added filter for expired and upcoming events (#714)
Ester2109 Nov 20, 2023
0545831
fixed bug with added order. set the status to SALE. Added 400 status …
MadsNyl Dec 11, 2023
250a995
fixed issue expired events (#743)
MadsNyl Dec 12, 2023
b9af21f
fixed filtering
MadsNyl Dec 14, 2023
0c7853f
feat(emojis): added emojis (#553)
norgor Dec 14, 2023
7cd500e
Fix Dev deployment (#744)
MadsNyl Dec 15, 2023
7b9928d
fixed migrations (#745)
MadsNyl Dec 15, 2023
95665c5
Update deploy_dev.yml
martcl Dec 27, 2023
4a0bd25
Update AdminGroup enum value KOK to Kontkom (#746)
MadsNyl Dec 29, 2023
9298f4e
fixed event filter (#747)
Ester2109 Jan 8, 2024
b408c66
refactored event serializer: update to free event only if there are n…
MadsNyl Jan 9, 2024
603abeb
removed write permission on Event for jubkom (#748)
MadsNyl Jan 11, 2024
10f28e9
Update CHANGELOG.md (#749)
MadsNyl Jan 15, 2024
f823092
deploy_prod
MadsNyl Jan 15, 2024
38b6f5e
merge
MadsNyl Jan 15, 2024
0e3379f
QUICKFIX/master into main (#751)
thomsen85 Jan 15, 2024
d8007f4
Fix(event)/expired shows activities (#753)
MadsNyl Jan 15, 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
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
run: |
touch .env
echo "AZURE_STORAGE_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}" >> .env
echo "VIPPS_MERCHANT_SERIAL_NUMBER=${{ secrets.VIPPS_MERCHANT_SERIAL_NUMBER }}" >> .env

- name: Build the Stack
run: docker-compose build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
deploy:
uses: TIHLDE/Lepton/.github/workflows/deploy_to_azure.yml@dev
with:
registry_name: leptondevregistry
registry_name: leptonregistrydev
secrets:
registry_username: ${{ secrets.ACI_DEV_USERNAME }}
registry_password: ${{ secrets.ACI_DEV_PASSWORD }}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

## Neste versjon

## Versjon 2023.01.15
- ✨ **Reaksjoner** Brukere kan reagere med emojier på arrangementer og nyheter.
- 🎨 **JubKom Rettigheter** Medlemmer av JubKom kan ikke lenger lage arrangementer.
- 🦟 **KoK Rettigheter** Medlemmer av KoK kan nå lage arrangementer, nyheter og manuelt legge til medlemmer på arrangement.
- 🦟 **Aktiviteter** Filterering av aktiviteter og arrangementer fungerer nå riktig. I visning av gruppe, vil nå også aktiviteter vises.
- 🦟 **Manuell Registering** Man får nå en feilmelding om at man ikke kan legge til dobbel manuell registering for en bruker på et arrangement.
- ⚡ **Mine Arrangementer** En bruker kan nå se alle sine tidligere arrangementer som de har deltatt på.
- 🦟 **Vipps** En ny versjon av Vipps betaling har nå kommet.

## Versjon 2023.11.06
- ✨ **Påmelding** Medlemmer av undergrupper kan nå manuelt legge til brukere på arrangementer.
- ⚡ **Venteliste** Brukere på venteliste kan nå se sin egen plass på ventelisten.
Expand All @@ -24,13 +33,15 @@
## Versjon 2023.10.23
- ⚡ **Brukere** HS kan styre medlemmer
- ✨ **Bannere** Filtrering på bannere
- ✨ **emoji** Nyheter kan nå ha reaksjoner
- ✨ **Spørreskjemaer** NOK medlemmer kan lage spørreskjema.
- ⚡ **Bruker** Nå kan ikke HS lenger endre eller slette brukere.
- ⚡ **Mails** Nå logger vi på eposttjeneren kun en gang per batch med epost som sendes.
- 🦟 **Bøter** Nå skal bilder på bøter ikke lengre forsvinne.
- ✨ **Betalte arrangementer med Vipps betaling**. Det kan nå opprettes arrangementer som krever betaling for å melde seg på. Denne betalingen betales via Vipps.
- ⚡ **Nyheter** Fondesforvalere kan nå lage nyheter.
- ⚡ **Arrangementer** Du kan nå se hvilken plass du har på ventelisten til et arrangement.
- ✨ **Profil** Filtrere kommende og tidligere arrangementer

## Versjon 2022.10.13

Expand Down
3 changes: 2 additions & 1 deletion app/common/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AdminGroup(ChoiceEnum):
NOK = "Nok"
PROMO = "Promo"
SOSIALEN = "Sosialen"
KOK = "Kok"
KOK = "Kontkom"

@classmethod
def all(cls):
Expand All @@ -43,6 +43,7 @@ class Groups(ChoiceEnum):
JUBKOM = "JubKom"
REDAKSJONEN = "Redaksjonen"
FONDET = "Forvaltningsgruppen"
PLASK = "Plask"


class AppModel(ChoiceEnum):
Expand Down
11 changes: 10 additions & 1 deletion app/content/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

class APIPaidEventCantBeChangedToFreeEventException(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = "Arrangementet er et betalt arrangement, og kan ikke endres til et gratis arrangement"
default_detail = "Arrangementet er et betalt arrangement med påmeldte deltagere, og kan ikke endres til et gratis arrangement"


class APIEventCantBeChangedToPaidEventException(APIException):
status_code = status.HTTP_400_BAD_REQUEST
default_detail = "Arrangementet er et gratis arrangement med påmeldte deltagere, og kan ikke endres til et betalt arrangement"


class APIUserAlreadyAttendedEvent(APIException):
Expand Down Expand Up @@ -48,3 +53,7 @@ class UnansweredFormError(ValueError):

class EventIsFullError(ValueError):
pass


class RefundFailedError(ValueError):
pass
1 change: 1 addition & 0 deletions app/content/factories/event_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ class Meta:
start_registration_at = timezone.now() - timedelta(days=1)
end_registration_at = timezone.now() + timedelta(days=9)
sign_off_deadline = timezone.now() + timedelta(days=8)
emojis_allowed = True
1 change: 1 addition & 0 deletions app/content/factories/news_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ class Meta:
title = factory.Faker("sentence", nb_words=5)
header = factory.Faker("sentence", nb_words=5)
body = factory.Faker("paragraph", nb_sentences=10)
emojis_allowed = True
2 changes: 1 addition & 1 deletion app/content/migrations/0054_qrcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ class Migration(migrations.Migration):
"verbose_name_plural": "qr_codes",
},
),
]
]
18 changes: 18 additions & 0 deletions app/content/migrations/0054_registration_payment_expiredate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.5 on 2023-10-18 08:55

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("content", "0053_event_contact_person"),
]

operations = [
migrations.AddField(
model_name="registration",
name="payment_expiredate",
field=models.DateTimeField(default=None, null=True),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class Migration(migrations.Migration):
field=models.CharField(default=None, max_length=600),
preserve_default=False,
),
]
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.5 on 2023-12-15 17:46

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("content", "0056_registration_created_by_admin"),
]

operations = [
migrations.AddField(
model_name="event",
name="emojis_allowed",
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name="news",
name="emojis_allowed",
field=models.BooleanField(default=False),
),
]
13 changes: 13 additions & 0 deletions app/content/migrations/0058_merge_20231217_2155.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by Django 4.2.5 on 2023-12-17 20:55

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("content", "0054_registration_payment_expiredate"),
("content", "0057_event_emojis_allowed_news_emojis_allowed"),
]

operations = []
18 changes: 16 additions & 2 deletions app/content/models/event.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from datetime import timedelta

from django.contrib.contenttypes.fields import GenericRelation
from django.core.exceptions import ValidationError
from django.db import models

from app.common.enums import AdminGroup, Groups
from app.common.enums import AdminGroup
from app.common.permissions import (
BasePermissionModel,
check_has_access,
set_user_id,
)
from app.content.models import Category
from app.content.models.user import User
from app.emoji.models.reaction import Reaction
from app.forms.enums import EventFormType
from app.group.models.group import Group
from app.util.models import BaseModel, OptionalImage
Expand All @@ -19,7 +21,7 @@

class Event(BaseModel, OptionalImage, BasePermissionModel):

write_access = (*AdminGroup.admin(), AdminGroup.PROMO, Groups.JUBKOM)
write_access = (*AdminGroup.admin(), AdminGroup.PROMO)

title = models.CharField(max_length=200)
start_date = models.DateTimeField()
Expand Down Expand Up @@ -77,6 +79,10 @@ class Event(BaseModel, OptionalImage, BasePermissionModel):
runned_sign_off_deadline_reminder = models.BooleanField(default=False)
runned_sign_up_start_notifier = models.BooleanField(default=False)

""" Reactions """
emojis_allowed = models.BooleanField(default=False)
reactions = GenericRelation(Reaction)

class Meta:
ordering = ("start_date",)

Expand All @@ -102,6 +108,11 @@ def list_count(self):
"""Number of users registered to attend the event"""
return self.get_participants().count()

@property
def has_participants(self):
"""Returns if the event has users registered to attend the event"""
return self.list_count > 0

@property
def waiting_list_count(self):
"""Number of users on the waiting list"""
Expand Down Expand Up @@ -134,6 +145,9 @@ def get_waiting_list(self):
def user_has_attended_event(self, user):
return self.get_participants().filter(user=user, has_attended=True).exists()

def user_is_participant(self, user):
return self.get_participants().filter(user=user).exists()

@property
def is_past_sign_off_deadline(self):
return now() >= self.sign_off_deadline
Expand Down
4 changes: 4 additions & 0 deletions app/content/models/news.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from django.conf import settings
from django.contrib.contenttypes.fields import GenericRelation
from django.db import models

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


Expand All @@ -17,6 +19,8 @@ class News(BaseModel, OptionalImage, BasePermissionModel):
related_name="created_news",
)
body = models.TextField()
emojis_allowed = models.BooleanField(default=False)
reactions = GenericRelation(Reaction)

write_access = [*AdminGroup.all(), Groups.FONDET]

Expand Down
62 changes: 62 additions & 0 deletions app/content/models/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from django.db import models
from django.db.models import Q

from sentry_sdk import capture_exception

from app.common.enums import StrikeEnum
from app.common.permissions import BasePermissionModel
from app.communication.enums import UserNotificationSettingType
Expand All @@ -17,7 +19,9 @@
from app.content.models.event import Event
from app.content.models.strike import create_strike
from app.content.models.user import User
from app.content.util.registration_utils import get_payment_expiredate
from app.forms.enums import EventFormType
from app.payment.util.order_utils import check_if_order_is_paid, has_paid_order
from app.util import now
from app.util.models import BaseModel
from app.util.utils import datetime_format
Expand All @@ -36,6 +40,7 @@ class Registration(BaseModel, BasePermissionModel):
is_on_wait = models.BooleanField(default=False, verbose_name="waiting list")
has_attended = models.BooleanField(default=False)
allow_photo = models.BooleanField(default=True)
payment_expiredate = models.DateTimeField(null=True, default=None)
created_by_admin = models.BooleanField(default=False)

class Meta:
Expand Down Expand Up @@ -86,7 +91,27 @@ def delete_submission_if_exists(self):
)[:1]
Submission.objects.filter(form=event_form, user=self.user).delete()

def refund_payment_if_exist(self):
from app.content.util.event_utils import refund_vipps_order

if not self.event.is_paid_event:
return

orders = self.event.orders.filter(user=self.user)

if has_paid_order(orders):
for order in orders:
if check_if_order_is_paid(order):
refund_vipps_order(
order_id=order.order_id,
event=self.event,
transaction_text=f"Refund for {self.event.title} - {self.user.first_name} {self.user.last_name}",
)
self.send_notification_and_mail_for_refund(order)

def delete(self, *args, **kwargs):
from app.content.util.event_utils import start_payment_countdown

moved_registration = None
if not self.is_on_wait:
if self.event.is_past_sign_off_deadline:
Expand All @@ -99,9 +124,26 @@ def delete(self, *args, **kwargs):
moved_registration = self.move_from_waiting_list_to_queue()

self.delete_submission_if_exists()

# TODO: Add this for refund
# self.refund_payment_if_exist()

registration = super().delete(*args, **kwargs)
if moved_registration:
moved_registration.save()

if (
moved_registration.event.is_paid_event
and not moved_registration.is_on_wait
):
try:
start_payment_countdown(
moved_registration.event, moved_registration
)
except Exception as countdown_error:
capture_exception(countdown_error)
moved_registration.delete()

return registration

def admin_unregister(self, *args, **kwargs):
Expand All @@ -115,6 +157,7 @@ def admin_unregister(self, *args, **kwargs):
moved_registration.save()

def save(self, *args, **kwargs):

if not self.registration_id:
self.create()

Expand Down Expand Up @@ -208,6 +251,19 @@ def send_notification_and_mail(self):
self.event.pk
).send()

def send_notification_and_mail_for_refund(self, order):
Notify(
[self.user],
f'Du har blitt meldt av "{self.event.title}" og vil bli refundert',
UserNotificationSettingType.UNREGISTRATION,
).add_paragraph(f"Hei, {self.user.first_name}!").add_paragraph(
f"Du har blitt meldt av {self.event.title} og vil bli refundert."
).add_paragraph(
"Du vil få pengene tilbake på kontoen din innen 2 til 3 virkedager. I enkelte tilfeller, avhengig av bank, tar det inntil 10 virkedager."
).add_paragraph(
f"Hvis det skulle oppstå noen problemer så kontakt oss på [email protected]. Ditt ordrenummer er {order.order_id}."
).send()

def should_swap_with_non_prioritized_user(self):
return (
self.is_on_wait
Expand Down Expand Up @@ -279,6 +335,12 @@ def move_from_waiting_list_to_queue(self):
registrations_in_waiting_list[0],
)
registration_move_to_queue.is_on_wait = False

if self.event.is_paid_event:
registration_move_to_queue.payment_expiredate = get_payment_expiredate(
self.event
)

return registration_move_to_queue

def move_from_queue_to_waiting_list(self):
Expand Down
Loading
Loading