diff --git a/backend/aaiss_backend/settings.py b/backend/aaiss_backend/settings.py index 5be44db..87d8304 100644 --- a/backend/aaiss_backend/settings.py +++ b/backend/aaiss_backend/settings.py @@ -193,4 +193,4 @@ #ZIFY ZIFY_AUTH = env.str("ZIFY_AUTH", "") -SKYROOM_URL = env.str("SKYROOM_URL", "https://www.skyroom.online/ch/aut_ceit_ssc/aaiss") \ No newline at end of file +SKYROOM_BASE_URL = env.str("SKYROOM_URL", "https://www.skyroom.online/ch/aut_ceit_ssc") \ No newline at end of file diff --git a/backend/backend_api/admin.py b/backend/backend_api/admin.py index e9541c3..96bf7a2 100644 --- a/backend/backend_api/admin.py +++ b/backend/backend_api/admin.py @@ -1,8 +1,9 @@ from django import forms from django.contrib import admin from django.template.loader import render_to_string +from django.contrib.admin.helpers import ActionForm -from aaiss_backend.settings import SKYROOM_URL +from aaiss_backend.settings import SKYROOM_BASE_URL from backend_api import models from backend_api.email import MailerThread from backend_api.models import Discount, Presentation, PresentationParticipation, WorkshopRegistration @@ -67,9 +68,14 @@ class Meta: class PresentationAdmin(admin.ModelAdmin): + class PresentationForm(ActionForm): + _CHOISES = (('aaiss', 'aaiss'), ('aaiss2', 'aaiss2')) + room_name = forms.ChoiceField(choices=_CHOISES, required=True) + list_display = ('__str__', 'level', 'no_of_participants', 'year') readonly_fields = ('participants',) actions = ['export_login_credentials', 'send_registration_emails'] + action_form = PresentationForm class Meta: model = Presentation @@ -83,7 +89,7 @@ def export_login_credentials(self, request, obj): status=PresentationParticipation.StatusChoices.PURCHASED): user_credentials.append( SkyroomCredentials(registration.username, registration.password, - registration.user.name)) + registration.user.name, request.POST['room_name'])) return convert_credentials_to_csv_response(user_credentials) @admin.action(description='Send registration emails') @@ -97,16 +103,21 @@ def send_registration_emails(self, request, obj): { 'username': registration.username, 'password': registration.password, - 'meeting_url': SKYROOM_URL, + 'meeting_url': SKYROOM_BASE_URL + '/' + request.POST['room_name'], 'meeting_type': 'presentation', 'meeting_title': presentation.name, })).start() class WorkshopAdmin(admin.ModelAdmin): + class WorkshopForm(ActionForm): + _CHOISES = (('aaiss', 'aaiss'), ('aaiss2', 'aaiss2')) + room_name = forms.ChoiceField(choices=_CHOISES, required=True) + list_display = ('__str__', 'capacity', 'cost', 'has_project', 'level', 'no_of_participants', 'year') readonly_fields = ('participants',) actions = ['export_login_credentials', 'send_registration_emails'] + action_form = WorkshopForm class Meta: model = models.Workshop @@ -120,7 +131,7 @@ def export_login_credentials(self, request, obj): status=WorkshopRegistration.StatusChoices.PURCHASED): user_credentials.append( SkyroomCredentials(registration.username, registration.password, - registration.user.name)) + registration.user.name, request.POST['room_name'])) return convert_credentials_to_csv_response(user_credentials) @admin.action(description='Send registration emails') @@ -134,7 +145,7 @@ def send_registration_emails(self, request, obj): { 'username': registration.username, 'password': registration.password, - 'meeting_url': SKYROOM_URL, + 'meeting_url': SKYROOM_BASE_URL + '/' + request.POST['room_name'], 'meeting_type': 'workshop', 'meeting_title': workshop.name, })).start() diff --git a/backend/utils/skyroom_exporter.py b/backend/utils/skyroom_exporter.py index 3d41955..fb58de4 100644 --- a/backend/utils/skyroom_exporter.py +++ b/backend/utils/skyroom_exporter.py @@ -9,6 +9,7 @@ class SkyroomCredentials: username: str password: str full_name: str + room_name: str def convert_credentials_to_csv_response(credentials: list[SkyroomCredentials]) -> HttpResponse: @@ -16,5 +17,6 @@ def convert_credentials_to_csv_response(credentials: list[SkyroomCredentials]) - response['Content-Disposition'] = 'attachment; filename="login_credentials.csv"' writer = csv.writer(response) for credential in credentials: - writer.writerow([credential.username, credential.password, credential.full_name, 'aaiss', 'normal']) + writer.writerow( + [credential.username, credential.password, credential.full_name, credential.room_name, 'normal']) return response