Skip to content

Commit

Permalink
feat(backend): add sending recorded links action
Browse files Browse the repository at this point in the history
  • Loading branch information
Adibov committed Dec 27, 2023
1 parent f256de8 commit 77dcaaa
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
31 changes: 31 additions & 0 deletions backend/backend_api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
@@ -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),
),
]
2 changes: 2 additions & 0 deletions backend/backend_api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions backend/backend_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class WorkshopSerializer(serializers.ModelSerializer):

class Meta:
model = models.Workshop
fields = '__all__'
exclude = ['recorded_link']


class PresentationSerializer(serializers.ModelSerializer):
Expand All @@ -70,7 +70,7 @@ class PresentationSerializer(serializers.ModelSerializer):

class Meta:
model = models.Presentation
fields = '__all__'
exclude = ['recorded_link']


class WorkshopRegistrationSerializer(serializers.ModelSerializer):
Expand Down
15 changes: 15 additions & 0 deletions backend/templates/html/record_links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AAISS 2023 Recorded Links</title>
</head>
<body>
<div>Here are the recorded links for the AAISS 2023 presentations and workshops that you attended:</div>
<br>
{% for presentation in presentations %}
<a href="{{ presentation.url }}">{{ presentation.name }}</a>
<br>
{% endfor %}
</body>
</html>

0 comments on commit 77dcaaa

Please sign in to comment.