Skip to content

Commit

Permalink
revert linting changes to backend/alert
Browse files Browse the repository at this point in the history
  • Loading branch information
AaDalal committed Mar 27, 2024
1 parent c725fe2 commit 1b130fc
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 73 deletions.
7 changes: 1 addition & 6 deletions backend/alert/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@


class RegistrationAdmin(admin.ModelAdmin):
readonly_fields = (
"head_registration_id",
"section_link",
"resubscribed_from",
"created_at",
)
readonly_fields = ("head_registration_id", "section_link", "resubscribed_from", "created_at")
search_fields = (
"email",
"phone",
Expand Down
4 changes: 1 addition & 3 deletions backend/alert/management/commands/alertstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def handle(self, *args, **options):
num_registrations = qs.filter(created_at__gte=start, resubscribed_from__isnull=True).count()
num_alerts_sent = qs.filter(notification_sent=True, notification_sent_at__gte=start).count()
num_resubscribe = qs.filter(
resubscribed_from__isnull=False,
created_at__gte=start,
auto_resubscribe=False,
resubscribed_from__isnull=False, created_at__gte=start, auto_resubscribe=False
).count()
num_status_updates = StatusUpdate.objects.filter(created_at__gte=start).count()
num_active_perpetual = qs.filter(
Expand Down
8 changes: 2 additions & 6 deletions backend/alert/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
Expand Down Expand Up @@ -59,8 +56,7 @@ class Migration(migrations.Migration):
(
"section",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="courses.Section",
on_delete=django.db.models.deletion.CASCADE, to="courses.Section"
),
),
],
Expand Down
16 changes: 4 additions & 12 deletions backend/alert/migrations/0003_courseupdate_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
Expand Down Expand Up @@ -60,8 +57,7 @@ class Migration(migrations.Migration):
(
"section",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="courses.Section",
on_delete=django.db.models.deletion.CASCADE, to="courses.Section"
),
),
],
Expand All @@ -72,10 +68,7 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
Expand Down Expand Up @@ -108,8 +101,7 @@ class Migration(migrations.Migration):
(
"section",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="courses.Section",
on_delete=django.db.models.deletion.CASCADE, to="courses.Section"
),
),
],
Expand Down
3 changes: 1 addition & 2 deletions backend/alert/migrations/0010_auto_20201002_0714.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class Migration(migrations.Migration):
model_name="registration",
name="created_at",
field=models.DateTimeField(
auto_now_add=True,
help_text="The datetime at which this registration was created.",
auto_now_add=True, help_text="The datetime at which this registration was created."
),
),
migrations.AlterField(
Expand Down
10 changes: 2 additions & 8 deletions backend/alert/migrations/0012_auto_20210418_0343.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
Expand Down Expand Up @@ -104,10 +101,7 @@ class Migration(migrations.Migration):
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
Expand Down
29 changes: 7 additions & 22 deletions backend/alert/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
from django.utils.timezone import make_aware

from alert.alerts import Email, PushNotification, Text
from courses.models import (
Course,
Section,
StatusUpdate,
UserProfile,
string_dict_to_html,
)
from courses.models import Course, Section, StatusUpdate, UserProfile, string_dict_to_html
from courses.util import (
does_object_pass_filter,
get_course_and_section,
Expand Down Expand Up @@ -122,8 +116,7 @@ class Registration(models.Model):
"""

created_at = models.DateTimeField(
auto_now_add=True,
help_text="The datetime at which this registration was created.",
auto_now_add=True, help_text="The datetime at which this registration was created."
)
original_created_at = models.DateTimeField(
null=True,
Expand All @@ -137,8 +130,7 @@ class Registration(models.Model):
),
)
updated_at = models.DateTimeField(
auto_now=True,
help_text="The datetime at which this registration was last modified.",
auto_now=True, help_text="The datetime at which this registration was last modified."
)

SOURCE_CHOICES = (
Expand Down Expand Up @@ -267,8 +259,7 @@ class Registration(models.Model):
),
)
notification_sent = models.BooleanField(
default=False,
help_text="True if an alert has been sent to the user, false otherwise.",
default=False, help_text="True if an alert has been sent to the user, false otherwise."
)
notification_sent_at = models.DateTimeField(
blank=True,
Expand Down Expand Up @@ -710,9 +701,7 @@ def register_for_course(
)
registration.validate_phone()
if section.registrations.filter(
email=email_address,
phone=registration.phone,
**Registration.is_active_filter(),
email=email_address, phone=registration.phone, **Registration.is_active_filter()
).exists():
return RegStatus.OPEN_REG_EXISTS, section.full_code, None
else:
Expand Down Expand Up @@ -924,14 +913,10 @@ class AddDropPeriod(models.Model):
),
)
start = models.DateTimeField(
null=True,
blank=True,
help_text="The datetime at which the add drop period started.",
null=True, blank=True, help_text="The datetime at which the add drop period started."
)
end = models.DateTimeField(
null=True,
blank=True,
help_text="The datetime at which the add drop period ended.",
null=True, blank=True, help_text="The datetime at which the add drop period ended."
)

# estimated_start and estimated_end are filled in automatically in the overridden save method,
Expand Down
18 changes: 4 additions & 14 deletions backend/alert/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ def accept_webhook(request):
if should_send_pca_alert(course_term, course_status):
try:
alert_for_course(
course_id,
semester=course_term,
sent_by="WEB",
course_status=course_status,
course_id, semester=course_term, sent_by="WEB", course_status=course_status
)
alert_for_course_called = True
response = JsonResponse({"message": "webhook recieved, alerts sent"})
Expand Down Expand Up @@ -288,12 +285,7 @@ class RegistrationViewSet(AutoPrefetchViewSetMixin, viewsets.ModelViewSet):
override_response_schema={
"registrations-list": {
"POST": {
201: {
"properties": {
"message": {"type": "string"},
"id": {"type": "integer"},
}
},
201: {"properties": {"message": {"type": "string"}, "id": {"type": "integer"}}},
}
}
},
Expand Down Expand Up @@ -459,8 +451,7 @@ def update(self, request, pk=None):
registration.deleted_at = timezone.now()
registration.save()
return Response(
{"detail": "Registration deleted"},
status=status.HTTP_200_OK,
{"detail": "Registration deleted"}, status=status.HTTP_200_OK
)
elif request.data.get("cancelled", False):
if registration.deleted:
Expand All @@ -480,8 +471,7 @@ def update(self, request, pk=None):
registration.cancelled_at = timezone.now()
registration.save()
return Response(
{"detail": "Registration cancelled"},
status=status.HTTP_200_OK,
{"detail": "Registration cancelled"}, status=status.HTTP_200_OK
)
elif "auto_resubscribe" in request.data or "close_notification" in request.data:
if registration.deleted:
Expand Down

0 comments on commit 1b130fc

Please sign in to comment.