diff --git a/coderdojochi/admin.py b/coderdojochi/admin.py index d5052cbf..6a36ae7a 100644 --- a/coderdojochi/admin.py +++ b/coderdojochi/admin.py @@ -717,6 +717,7 @@ class OrderAdmin(ImportExportMixin, ImportExportActionModelAdmin): "_created_at", "is_checked_in", "is_active", + "has_cancellation_reason", ] list_filter = [ @@ -748,6 +749,21 @@ class OrderAdmin(ImportExportMixin, ImportExportActionModelAdmin): date_hierarchy = "created_at" + fields = ( + "guardian", + "session", + "student", + "is_active", + "check_in", + "cancellation_reason", + "alternate_guardian", + "affiliate", + "order_number", + "ip", + "week_reminder_sent", + "day_reminder_sent", + ) + view_on_site = False actions = [ @@ -796,6 +812,12 @@ def _created_at(self, obj): _created_at.short_description = "Created At" + def has_cancellation_reason(self, obj): + return bool(obj.cancellation_reason) + + has_cancellation_reason.boolean = True + has_cancellation_reason.short_description = "Has Reason" + def mentor_check_in(modeladmin, request, queryset): queryset.update(check_in=timezone.now()) diff --git a/coderdojochi/migrations/0041_order_cancellation_reason.py b/coderdojochi/migrations/0041_order_cancellation_reason.py new file mode 100644 index 00000000..9900c339 --- /dev/null +++ b/coderdojochi/migrations/0041_order_cancellation_reason.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.6 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('coderdojochi', '0040_alter_mentor_avatar'), + ] + + operations = [ + migrations.AddField( + model_name='order', + name='cancellation_reason', + field=models.TextField(blank=True, help_text='Reason for cancellation or no-show', null=True), + ), + ] \ No newline at end of file diff --git a/coderdojochi/models/order.py b/coderdojochi/models/order.py index 86c9a2c6..326bc4ab 100644 --- a/coderdojochi/models/order.py +++ b/coderdojochi/models/order.py @@ -53,6 +53,11 @@ class Order(CommonInfo): day_reminder_sent = models.BooleanField( default=False, ) + cancellation_reason = models.TextField( + blank=True, + null=True, + help_text="Reason for cancellation or no-show", + ) def __str__(self): return f"{self.student.full_name} | {self.session.course.title}" diff --git a/coderdojochi/templates/dashboard/session_check_in.html b/coderdojochi/templates/dashboard/session_check_in.html index e3ef02d6..af204076 100644 --- a/coderdojochi/templates/dashboard/session_check_in.html +++ b/coderdojochi/templates/dashboard/session_check_in.html @@ -36,6 +36,12 @@ width: 10%; } + .cancellation-reason { + min-width: 150px; + width: 15%; + max-width: 200px; + } + .order-date {} .student-gender { @@ -305,6 +311,7 @@

No Shows {{ no_show_orders.count }} Parent Phone School Last Update Date + Reason #A #M @@ -321,6 +328,13 @@

No Shows {{ no_show_orders.count }} {{ order.guardian.phone | phone_number }} {{ order.student.school_name }} {{ order.updated_at | date:"M j, g:i A" }} + + {% if order.cancellation_reason %} + {{ order.cancellation_reason|truncatewords:10 }} + {% else %} + No reason given + {% endif %} + {{ order.num_attended }} {{ order.num_missed }} @@ -349,6 +363,7 @@

Cancelled Tickets {{ inactive_orders.count Parent Phone School Cancelled Date + Reason #A #M @@ -365,6 +380,13 @@

Cancelled Tickets {{ inactive_orders.count {{ order.guardian.phone | phone_number }} {{ order.student.school_name }} {{ order.updated_at | date:"M j, g:i A" }} + + {% if order.cancellation_reason %} + {{ order.cancellation_reason|truncatewords:10 }} + {% else %} + No reason given + {% endif %} + {{ order.num_attended }} {{ order.num_missed }}