Skip to content

Commit f7a6cb2

Browse files
authored
Merge pull request #166 from UNLV-CS472-672/periodic_reminders
Sessions Model + Set up for Issue #50
2 parents 42f10bb + 0946945 commit f7a6cb2

File tree

17 files changed

+199
-10
lines changed

17 files changed

+199
-10
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.1.6 on 2025-04-20 04:48
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('lessons', '0006_assignment_upload_record'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='assignment',
15+
name='reminder_sent',
16+
field=models.BooleanField(default=False),
17+
),
18+
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 5.1.6 on 2025-04-20 06:47
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('lessons', '0007_alter_solution_choices_and_more'),
10+
('lessons', '0008_assignment_reminder_sent'),
11+
]
12+
13+
operations = [
14+
]

backend/apps/lessons/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class Assignment(models.Model): # Assignments: Represents assignments given to
2828

2929
deadline = models.DateTimeField(null=True, blank=True) # deadline is optional for extra credit/optional assignments
3030

31+
reminder_sent = models.BooleanField(default=False)
32+
3133
def __str__(self):
3234
return self.title
3335

backend/apps/lessons/serializers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class Meta:
1616
"student",
1717
"student_username",
1818
"upload_record",
19-
"upload_record_id"
19+
"upload_record_id",
20+
"reminder_sent"
2021
]
2122

2223

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.1.6 on 2025-04-20 03:22
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('notifications', '0003_alter_notification_info_category_and_more'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='notification',
15+
name='priority',
16+
field=models.CharField(choices=[('low', 'Low'), ('medium', 'Medium'), ('high', 'High')], default='medium', max_length=10),
17+
),
18+
]

backend/apps/notifications/migrations/0004_notification_sender.py renamed to backend/apps/notifications/migrations/0005_notification_sender.py

File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Generated by Django 5.1.6 on 2025-04-20 06:47
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('notifications', '0004_notification_priority'),
10+
('notifications', '0005_notification_sender'),
11+
]
12+
13+
operations = [
14+
]

backend/apps/notifications/models.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ class Notification(models.Model):
1414
INFO_GENERAL = 'general'
1515
INFO_SYSTEM = 'system'
1616

17+
# constants for priority types for scheduled notifications
18+
LOW = 'low'
19+
MEDIUM = 'medium'
20+
HIGH = 'high'
21+
1722
# choices for the notification_type field. the elements in the list is
1823
# a tuple of (value, display_name)
1924
NOTIFICATION_TYPES = [
@@ -29,6 +34,13 @@ class Notification(models.Model):
2934
(INFO_SYSTEM, 'System Update')
3035
]
3136

37+
# choices for priority types
38+
PRIORITY_CHOICES = [
39+
(LOW, 'Low'),
40+
(MEDIUM, 'Medium'),
41+
(HIGH, 'High')
42+
]
43+
3244
# links to the user who will receive notifications
3345
# on_delete=CASCADE means that if the user is deleted, their notifs will be deleted too
3446
# related_name='notifications' gets all notifs for a user
@@ -62,6 +74,13 @@ class Notification(models.Model):
6274
null=True
6375
)
6476

77+
# priority field
78+
priority = models.CharField(
79+
max_length=10,
80+
choices=PRIORITY_CHOICES,
81+
default=MEDIUM
82+
)
83+
6584
# when notification was created
6685
sent_at = models.DateTimeField(default=timezone.now)
6786

backend/apps/notifications/serializers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
from rest_framework import serializers
22
from .models import Notification
3-
4-
53
# for serializing notification data to JSON
64
class NotificationSerializer(serializers.ModelSerializer):
75
sender_username = serializers.CharField(source='sender.username', read_only=True)
8-
96
class Meta:
107
model = Notification
118
fields = [
@@ -18,6 +15,7 @@ class Meta:
1815
'sent_at',
1916
'scheduled_time',
2017
'is_read',
18+
'priority',
2119
'sender_username'
2220
]
2321
read_only_fields = ['id', 'sent_at']

backend/apps/notifications/tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from django.utils import timezone
33
from .models import Notification
44

5+
# TODO: this is where I'll create the celery tasks for the session and assignment reminders (6th PR)
56

67
@shared_task
78
def process_scheduled_notifications():

0 commit comments

Comments
 (0)