diff --git a/aincrad/tests.py b/aincrad/tests.py index 1d9f6a38..940e8f11 100644 --- a/aincrad/tests.py +++ b/aincrad/tests.py @@ -19,9 +19,9 @@ RegistrationContainerFactory, StudentFactory, StudentRegistrationFactory, - UnitInquiryFactory, + UnitPetitionFactory, ) -from roster.models import ApplyUUID, Invoice, Student, UnitInquiry +from roster.models import ApplyUUID, Invoice, Student, UnitPetition EXAMPLE_PASSWORD = "take just the first 24" TARGET_HASH = sha256(EXAMPLE_PASSWORD.encode("ascii")).hexdigest() @@ -98,14 +98,14 @@ def aincrad_setup(db): PSetFactory.create_batch(4, student=old_alice, status="A") PSetFactory.create_batch(2, student=old_alice, status="P") - UnitInquiryFactory.create_batch( - 5, student=alice, action_type="INQ_ACT_UNLOCK", status="INQ_ACC" + UnitPetitionFactory.create_batch( + 5, student=alice, action_type="PET_ACT_UNLOCK", status="PET_ACC" ) - UnitInquiryFactory.create_batch( - 2, student=alice, action_type="INQ_ACT_DROP", status="INQ_ACC" + UnitPetitionFactory.create_batch( + 2, student=alice, action_type="PET_ACT_DROP", status="PET_ACC" ) - UnitInquiryFactory.create_batch( - 3, student=alice, action_type="INQ_ACT_UNLOCK", status="INQ_NEW" + UnitPetitionFactory.create_batch( + 3, student=alice, action_type="PET_ACT_UNLOCK", status="PET_NEW" ) alice.curriculum.add(submitted_unit) @@ -185,9 +185,9 @@ def test_init(otis, aincrad_setup): else: pytest.fail("Could not find a pset from Bôb B. in aincrad test") - inquiries = out["_children"][1]["inquiries"] - assert len(inquiries) == 3 - assert inquiries[0]["unlock_inquiry_count"] == 8 + petitions = out["_children"][1]["petitions"] + assert len(petitions) == 3 + assert petitions[0]["unlock_petition_count"] == 8 @pytest.mark.django_db @@ -293,17 +293,17 @@ def test_invoice(otis, aincrad_setup): @pytest.mark.django_db @override_settings(API_TARGET_HASH=TARGET_HASH) -def test_accept_inquiries(otis, aincrad_setup): +def test_accept_petitions(otis, aincrad_setup): resp = otis.post_20x( "api", json={ - "action": "accept_inquiries", + "action": "accept_petitions", "token": EXAMPLE_PASSWORD, }, ) assert resp.json()["result"] == "success" assert resp.json()["count"] == 3 - assert not UnitInquiry.objects.filter(status="INQ_NEW").exists() + assert not UnitPetition.objects.filter(status="PET_NEW").exists() @pytest.mark.django_db diff --git a/aincrad/views.py b/aincrad/views.py index 906ae5b3..5f104823 100644 --- a/aincrad/views.py +++ b/aincrad/views.py @@ -33,7 +33,7 @@ Invoice, Student, StudentRegistration, - UnitInquiry, + UnitPetition, ) from suggestions.models import ProblemSuggestion @@ -145,17 +145,17 @@ class JSONData(TypedDict): "student__user__profile__email_on_pset_complete", ) -INQUIRY_VENUEQ_INIT_QUERYSET = UnitInquiry.objects.filter( - status="INQ_NEW", +PETITION_VENUEQ_INIT_QUERYSET = UnitPetition.objects.filter( + status="PET_NEW", student__semester__active=True, student__legit=True, ).annotate( - unlock_inquiry_count=SubqueryCount( - "student__unitinquiry", - filter=Q(action_type="INQ_ACT_UNLOCK"), + unlock_petition_count=SubqueryCount( + "student__unitpetition", + filter=Q(action_type="PET_ACT_UNLOCK"), ), ) -INQUIRY_VENUEQ_INIT_KEYS = ( +PETITION_VENUEQ_INIT_KEYS = ( "action_type", "unit__group__name", "unit__code", @@ -164,14 +164,14 @@ class JSONData(TypedDict): "student__user__email", "explanation", "created_at", - "unlock_inquiry_count", - "student__user__profile__email_on_inquiry_complete", + "unlock_petition_count", + "student__user__profile__email_on_petition_complete", ) -INQUIRY_VENUEQ_AUTO_QUERYSET = UnitInquiry.objects.filter( +PETITION_VENUEQ_AUTO_QUERYSET = UnitPetition.objects.filter( was_auto_processed=True, created_at__gte=timezone.now() + timedelta(days=-2), ) -INQUIRY_VENUEQ_AUTO_KEYS = ( +PETITION_VENUEQ_AUTO_KEYS = ( "action_type", "unit__group__name", "unit__code", @@ -245,12 +245,12 @@ def venueq_handler(action: str, data: JSONData) -> JsonResponse: ), }, { - "_name": "Inquiries", - "inquiries": list( - INQUIRY_VENUEQ_INIT_QUERYSET.values(*INQUIRY_VENUEQ_INIT_KEYS) + "_name": "Petitions", + "petitions": list( + PETITION_VENUEQ_INIT_QUERYSET.values(*PETITION_VENUEQ_INIT_KEYS) ), "reading": list( - INQUIRY_VENUEQ_AUTO_QUERYSET.values(*INQUIRY_VENUEQ_AUTO_KEYS) + PETITION_VENUEQ_AUTO_QUERYSET.values(*PETITION_VENUEQ_AUTO_KEYS) ), }, { @@ -267,14 +267,14 @@ def venueq_handler(action: str, data: JSONData) -> JsonResponse: }, ] return JsonResponse(output_data, status=200) - elif action == "accept_inquiries": + elif action == "accept_petitions": n = 0 - for inquiry in UnitInquiry.objects.filter( - status="INQ_NEW", + for petition in UnitPetition.objects.filter( + status="PET_NEW", student__semester__active=True, student__legit=True, ): - inquiry.run_accept() + petition.run_accept() n += 1 if n > 0: return JsonResponse({"result": "success", "count": n}, status=200) @@ -814,7 +814,7 @@ def api(request: HttpRequest) -> JsonResponse: if action in ( "grade_problem_set", - "accept_inquiries", + "accept_petitions", "mark_suggestion", "triage_job", "init", diff --git a/core/migrations/0073_rename_userprofile_email_on_petition_complete.py b/core/migrations/0073_rename_userprofile_email_on_petition_complete.py new file mode 100644 index 00000000..56d86a54 --- /dev/null +++ b/core/migrations/0073_rename_userprofile_email_on_petition_complete.py @@ -0,0 +1,20 @@ +# Generated by Django 6.0.8 on 2026-08-25 14:32 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ( + "core", + "0072_rename_first_payment_deadline_semester_half_payment_deadline_and_more", + ), + ] + + operations = [ + migrations.RenameField( + model_name="userprofile", + old_name="email_on_inquiry_complete", + new_name="email_on_petition_complete", + ), + ] diff --git a/core/models.py b/core/models.py index 6a17aadb..1836c2cf 100644 --- a/core/models.py +++ b/core/models.py @@ -325,7 +325,7 @@ class UserProfile(models.Model): help_text="Receive all-student announcements. If this is set to False, announcements will only appear on OTIS-WEB.", default=True, ) - email_on_inquiry_complete = models.BooleanField( + email_on_petition_complete = models.BooleanField( verbose_name="Receive email on petition processed", help_text="Receive an email when your petition has been processed.", default=False, @@ -357,5 +357,5 @@ def __str__(self) -> str: "email_on_announcement", "email_on_pset_complete", "email_on_suggestion_processed", - "email_on_inquiry_complete", + "email_on_petition_complete", ) diff --git a/core/views.py b/core/views.py index cbe6d13e..65372782 100644 --- a/core/views.py +++ b/core/views.py @@ -289,7 +289,7 @@ class UserProfileUpdateView( model = UserProfile fields = ( "email_on_announcement", - "email_on_inquiry_complete", + "email_on_petition_complete", "email_on_pset_complete", "email_on_suggestion_processed", "show_bars", diff --git a/dashboard/templates/dashboard/portal.html b/dashboard/templates/dashboard/portal.html index 42c921cb..7a3d4b91 100644 --- a/dashboard/templates/dashboard/portal.html +++ b/dashboard/templates/dashboard/portal.html @@ -337,7 +337,7 @@

Discord

Petitions

{% if request.user.is_staff %} - Manage units + Manage units Edit units {% else %} {% if not student.enabled %} @@ -347,7 +347,7 @@

Petitions

{% elif student.newborn %}

Pick units first!

{% else %} - Manage units + Manage units {% if bonus_levels %}

You are also sufficiently high level to diff --git a/otisweb/templates/sidebar.html b/otisweb/templates/sidebar.html index bdeed160..0634ca64 100644 --- a/otisweb/templates/sidebar.html +++ b/otisweb/templates/sidebar.html @@ -131,7 +131,7 @@

Admin