Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions coderdojochi/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ class OrderAdmin(ImportExportMixin, ImportExportActionModelAdmin):
"_created_at",
"is_checked_in",
"is_active",
"has_cancellation_reason",
]

list_filter = [
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -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())
Expand Down
18 changes: 18 additions & 0 deletions coderdojochi/migrations/0041_order_cancellation_reason.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
5 changes: 5 additions & 0 deletions coderdojochi/models/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
22 changes: 22 additions & 0 deletions coderdojochi/templates/dashboard/session_check_in.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
width: 10%;
}

.cancellation-reason {
min-width: 150px;
width: 15%;
max-width: 200px;
}

.order-date {}

.student-gender {
Expand Down Expand Up @@ -305,6 +311,7 @@ <h2 class="title">No Shows <span class="badge">{{ no_show_orders.count }}</span>
<th class="parent-phone">Parent Phone</th>
<th class="student-school">School</th>
<th class="order-date">Last Update Date</th>
<th class="cancellation-reason">Reason</th>
<th class="text-right num-attended"><abbr title="Number Attended">#A</abbr></th>
<th class="text-right num-missed"><abbr title="Number Missed">#M</abbr></th>
</tr>
Expand All @@ -321,6 +328,13 @@ <h2 class="title">No Shows <span class="badge">{{ no_show_orders.count }}</span>
<td>{{ order.guardian.phone | phone_number }}</td>
<td>{{ order.student.school_name }}</td>
<td>{{ order.updated_at | date:"M j, g:i A" }}</td>
<td class="cancellation-reason">
{% if order.cancellation_reason %}
{{ order.cancellation_reason|truncatewords:10 }}
{% else %}
<em>No reason given</em>
{% endif %}
</td>
<td class="text-right vert-align">{{ order.num_attended }}</td>
<td class="text-right vert-align {% if order.num_missed >= 3 %}danger{% endif %}">{{ order.num_missed }}</td>
</tr>
Expand Down Expand Up @@ -349,6 +363,7 @@ <h2 class="title">Cancelled Tickets <span class="badge">{{ inactive_orders.count
<th class="parent-phone">Parent Phone</th>
<th class="student-school">School</th>
<th class="order-date">Cancelled Date</th>
<th class="cancellation-reason">Reason</th>
<th class="text-right num-attended"><abbr title="Number Attended">#A</abbr></th>
<th class="text-right num-missed"><abbr title="Number Missed">#M</abbr></th>
</tr>
Expand All @@ -365,6 +380,13 @@ <h2 class="title">Cancelled Tickets <span class="badge">{{ inactive_orders.count
<td>{{ order.guardian.phone | phone_number }}</td>
<td>{{ order.student.school_name }}</td>
<td>{{ order.updated_at | date:"M j, g:i A" }}</td>
<td class="cancellation-reason">
{% if order.cancellation_reason %}
{{ order.cancellation_reason|truncatewords:10 }}
{% else %}
<em>No reason given</em>
{% endif %}
</td>
<td class="text-right">{{ order.num_attended }}</td>
<td class="text-right {% if order.num_missed >= 3 %}danger{% endif %}">{{ order.num_missed }}</td>
</tr>
Expand Down