diff --git a/backend/backend_api/admin.py b/backend/backend_api/admin.py index 96bf7a2..83ef67a 100644 --- a/backend/backend_api/admin.py +++ b/backend/backend_api/admin.py @@ -38,6 +38,37 @@ class PresenterAdmin(admin.ModelAdmin): class UserAdmin(admin.ModelAdmin): list_display = ('account',) + actions = ['send_record_links'] + + @admin.action(description='Send presentation/workshop record links') + def send_record_links(self, request, obj): + for user in obj: + presentation_participation = PresentationParticipation.objects.filter(user=user, + status=PresentationParticipation. + StatusChoices.PURCHASED) + workshop_participation = WorkshopRegistration.objects.filter(user=user, + status=WorkshopRegistration.StatusChoices.PURCHASED) + if len(presentation_participation) == 0 and len(workshop_participation) == 0: + continue + + presentation_links = [] + for presentation in presentation_participation: + presentation_links.append({ + 'url': presentation.presentation.recorded_link, + 'name': presentation.presentation.name + }) + for workshop in workshop_participation: + presentation_links.append({ + 'url': workshop.workshop.recorded_link, + 'name': workshop.workshop.name + }) + MailerThread(f"AAISS recorded links", + [user.account.email], + render_to_string('record_links.html', + { + 'presentations': presentation_links, + })).start() + class DiscountAdmin(admin.ModelAdmin): diff --git a/backend/backend_api/migrations/0058_presentation_recorded_link_workshop_recorded_link_and_more.py b/backend/backend_api/migrations/0058_presentation_recorded_link_workshop_recorded_link_and_more.py new file mode 100644 index 0000000..c1300aa --- /dev/null +++ b/backend/backend_api/migrations/0058_presentation_recorded_link_workshop_recorded_link_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.4 on 2023-12-27 21:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('backend_api', '0057_make_passwords_random'), + ] + + operations = [ + migrations.AddField( + model_name='presentation', + name='recorded_link', + field=models.URLField(default=None, null=True), + ), + migrations.AddField( + model_name='workshop', + name='recorded_link', + field=models.URLField(default=None, null=True), + ), + ] diff --git a/backend/backend_api/models.py b/backend/backend_api/models.py index a89178b..cee4c44 100644 --- a/backend/backend_api/models.py +++ b/backend/backend_api/models.py @@ -104,6 +104,7 @@ class Workshop(models.Model): prerequisites = models.CharField(max_length=BIG_MAX_LENGTH, default='', blank=True) capacity = models.PositiveSmallIntegerField(default=50) year = models.IntegerField(blank=False, default=2020) + recorded_link = models.URLField(null=True, default=None) NOT_ASSIGNED = 'NOT_ASSIGNED' ELEMENTARY = 'Elementary' @@ -175,6 +176,7 @@ class Presentation(models.Model): cost = models.PositiveIntegerField(default=0) capacity = models.PositiveIntegerField(default=50) has_project = models.BooleanField(default=False, blank=False) + recorded_link = models.URLField(null=True, default=None) NOT_ASSIGNED = 'NOT_ASSIGNED' ELEMENTARY = 'Elementary' diff --git a/backend/backend_api/serializers.py b/backend/backend_api/serializers.py index e2b5a01..73a078c 100644 --- a/backend/backend_api/serializers.py +++ b/backend/backend_api/serializers.py @@ -61,7 +61,7 @@ class WorkshopSerializer(serializers.ModelSerializer): class Meta: model = models.Workshop - fields = '__all__' + exclude = ['recorded_link'] class PresentationSerializer(serializers.ModelSerializer): @@ -70,7 +70,7 @@ class PresentationSerializer(serializers.ModelSerializer): class Meta: model = models.Presentation - fields = '__all__' + exclude = ['recorded_link'] class WorkshopRegistrationSerializer(serializers.ModelSerializer): diff --git a/backend/templates/html/record_links.html b/backend/templates/html/record_links.html new file mode 100644 index 0000000..527f4f4 --- /dev/null +++ b/backend/templates/html/record_links.html @@ -0,0 +1,15 @@ + + + + + AAISS 2023 Recorded Links + + +
Here are the recorded links for the AAISS 2023 presentations and workshops that you attended:
+
+{% for presentation in presentations %} +{{ presentation.name }} +
+{% endfor %} + + \ No newline at end of file