fix(adjustments): convert multi-line {# #} comments to {% comment %} blocks

Checkpoint-1 bug: the row partial's docstring used a multi-line {# ... #}
block. Django's single-line comment syntax doesn't match across newlines,
so the opening {# and closing #} were treated as literal text and spilled
into every rendered row — flooding the table body with the raw comment.
Worse, the browser partially parsed the literal <tr> inside the comment
text as an HTML tag, breaking the table layout entirely.

Fix: moved the multi-line docstring into a {% comment %}...{% endcomment %}
block and compressed three other multi-line {# #} blocks to single lines.

Also tripped on a second foot-gun: you can't put literal {# or #} inside
a {% comment %} block — Django's tokenizer still sees them as a nested
comment marker. Removed the meta-note about "{# ... #} is single-line
only" from inside the comment block.

All 58 tests pass. Table renders correctly with all 10 columns + type
badges + row actions visible.
This commit is contained in:
Konrad du Plessis 2026-04-23 16:19:38 +02:00
parent 06b3315641
commit e088192103
2 changed files with 15 additions and 25 deletions

View File

@ -1,14 +1,15 @@
{# === _adjustment_row.html ===
Single <tr> used by BOTH the flat Adjustments view and (later) the grouped view.
Context:
- `adj` — a PayrollAdjustment instance
- `additive_types` — list of type labels that are additive (used to decide
whether the amount should be prefixed with + or - in the display)
Row actions differ based on whether the adjustment has already been paid:
- Paid -> single [View Payslip] icon button
- Unpaid -> three buttons: [Preview][Edit][x]
(these reuse the existing modals on the dashboard — no new JS)
#}
{# === _adjustment_row.html — row partial for the Adjustments tab === #}
{% comment %}
Single table row used by BOTH the flat Adjustments view and (later) the grouped view.
Context:
- adj a PayrollAdjustment instance
- additive_types list of type labels that are additive (used to decide
whether the amount should be prefixed with + or - in the display)
Row actions differ by paid status:
- Paid -> single View Payslip icon button
- Unpaid -> three buttons: Preview, Edit, Delete
(these reuse the existing modals on the dashboard -- no new JS)
{% endcomment %}
{% load format_tags %}
<tr data-adj-id="{{ adj.id }}" class="{% if adj.payroll_record %}adj-row-paid{% else %}adj-row-unpaid{% endif %}">
@ -95,9 +96,8 @@
<i class="fas fa-eye"></i>
</a>
{% else %}
{# UNPAID: preview + edit + delete #}
{# Preview button — class .preview-payslip-btn is already wired up in the
main dashboard JS (opens the preview modal for this worker). #}
{# UNPAID row: Preview (reuses .preview-payslip-btn handler), #}
{# Edit (reuses .adjustment-badge handler), Delete (opens #deleteConfirmModal). #}
<button type="button"
class="btn btn-sm btn-outline-info preview-payslip-btn"
data-worker-id="{{ adj.worker.id }}"
@ -105,9 +105,6 @@
title="Preview payslip" data-bs-toggle="tooltip">
<i class="fas fa-eye"></i>
</button>
{# Edit button — class .adjustment-badge is already wired up in the
main dashboard JS (populates + opens #editAdjustmentModal). We reuse
it here so no new JS is needed for editing. #}
<button type="button"
class="btn btn-sm btn-outline-primary adjustment-badge"
data-adj-id="{{ adj.id }}"
@ -120,8 +117,6 @@
title="Edit" data-bs-toggle="tooltip">
<i class="fas fa-pen"></i>
</button>
{# Delete button — opens the existing #deleteConfirmModal directly
(short-circuits the edit modal's usual two-step flow). #}
<button type="button"
class="btn btn-sm btn-outline-danger adj-delete-btn"
data-adj-id="{{ adj.id }}"

View File

@ -682,12 +682,7 @@
</div>
</div>
{# --- Pagination --- #}
{# Hrefs go through the `url_replace` template tag (see
core/templatetags/format_tags.py). It rebuilds the current querystring
with ONLY the `page` key swapped out — prevents the `?page=2&page=3`
stacking bug that happened when we naively appended `&page=X` to the
raw `request.GET.urlencode`. #}
{# --- Pagination (hrefs go through `url_replace` so `page=` doesn't stack) --- #}
{% if adj_page.has_other_pages %}
<nav class="mt-3 d-flex justify-content-center">
<ul class="pagination pagination-sm">