diff --git a/backend/alert/admin.py b/backend/alert/admin.py index bae38b3b7..68016e732 100644 --- a/backend/alert/admin.py +++ b/backend/alert/admin.py @@ -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", diff --git a/backend/alert/management/commands/alertstats.py b/backend/alert/management/commands/alertstats.py index cac6893d9..fa345a6a9 100644 --- a/backend/alert/management/commands/alertstats.py +++ b/backend/alert/management/commands/alertstats.py @@ -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( diff --git a/backend/alert/migrations/0001_initial.py b/backend/alert/migrations/0001_initial.py index 43a269a88..cc9c21f65 100644 --- a/backend/alert/migrations/0001_initial.py +++ b/backend/alert/migrations/0001_initial.py @@ -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)), @@ -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" ), ), ], diff --git a/backend/alert/migrations/0003_courseupdate_registration.py b/backend/alert/migrations/0003_courseupdate_registration.py index 0a217d0bd..cc8823af7 100644 --- a/backend/alert/migrations/0003_courseupdate_registration.py +++ b/backend/alert/migrations/0003_courseupdate_registration.py @@ -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)), @@ -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" ), ), ], @@ -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" ), ), ( @@ -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" ), ), ], diff --git a/backend/alert/migrations/0010_auto_20201002_0714.py b/backend/alert/migrations/0010_auto_20201002_0714.py index e4626780a..a9f1a5b86 100644 --- a/backend/alert/migrations/0010_auto_20201002_0714.py +++ b/backend/alert/migrations/0010_auto_20201002_0714.py @@ -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( diff --git a/backend/alert/migrations/0012_auto_20210418_0343.py b/backend/alert/migrations/0012_auto_20210418_0343.py index 33f06d175..1cff4b39d 100644 --- a/backend/alert/migrations/0012_auto_20210418_0343.py +++ b/backend/alert/migrations/0012_auto_20210418_0343.py @@ -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" ), ), ( @@ -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" ), ), ( diff --git a/backend/alert/models.py b/backend/alert/models.py index 370b98bd0..43a2076f1 100644 --- a/backend/alert/models.py +++ b/backend/alert/models.py @@ -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, @@ -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, @@ -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 = ( @@ -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, @@ -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: @@ -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, diff --git a/backend/alert/views.py b/backend/alert/views.py index 4407935c2..4ab17a25a 100644 --- a/backend/alert/views.py +++ b/backend/alert/views.py @@ -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"}) @@ -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"}}}, } } }, @@ -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: @@ -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: