Two things, found together while looking at the row of controls under each
pending claim.
The child dropdown stood taller than the btn-sm/input-sm around it because
ClaimReviewForm.child hardcoded its own class="select select-bordered w-full"
on the widget. templatetags/field.html's select branch already builds the
full class list itself (base classes + the size modifier), so the widget's
own class rendered as a second, non-merging class="..." attribute right next
to the generated one -- select-sm was in the markup, just shadowed by a
duplicate attribute the browser never applied. No other Select field in the
app hardcodes a class this way, which is why nothing else had the problem.
Fixed by dropping it and passing size="small" through {% form_field %}
instead, the same way every other compact inline select in the app does.
Also pulled Approve and Reject apart with justify-between rather than letting
both sit in one flex-wrap run, so they stay on opposite sides of the row
(and don't end up adjacent on a wrap) rather than one stray click apart.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
42 lines
2.2 KiB
Python
42 lines
2.2 KiB
Python
from django import forms
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
class ParentClaimForm(forms.Form):
|
|
"""The public "link me to my child" form -- see members.models.ParentClaim.
|
|
|
|
Every child field is free text. There is deliberately no picker, no search
|
|
and no autocomplete: this page is reachable without logging in, so anything
|
|
that confirmed whether a given child exists would turn it into a way to
|
|
enumerate the club's children. The submitter types what they know and an
|
|
admin matches it against the real record.
|
|
"""
|
|
|
|
parent_first_name = forms.CharField(label=_("Your first name"), max_length=150)
|
|
parent_last_name = forms.CharField(label=_("Your last name"), max_length=150)
|
|
parent_email = forms.EmailField(label=_("Your email address"), help_text=_("We'll use this to set up your login once the club has confirmed the link."))
|
|
|
|
child_first_name = forms.CharField(label=_("Child's first name"), max_length=150)
|
|
child_last_name = forms.CharField(label=_("Child's last name"), max_length=150)
|
|
child_date_of_birth = forms.DateField(label=_("Child's date of birth"), widget=forms.DateInput(attrs={"type": "date"}))
|
|
|
|
|
|
class ClaimReviewForm(forms.Form):
|
|
"""An admin approving one claim: which child it actually refers to.
|
|
|
|
The child is chosen from the shortlist rather than typed, and the shortlist
|
|
is only ever children who have no parent on file -- approving a claim can
|
|
never quietly re-parent a child who already has one.
|
|
"""
|
|
|
|
# No hardcoded "class" here -- templatetags/field.html's own select branch
|
|
# already builds the full class list (including the size modifier), and a
|
|
# class baked into the widget attrs would render a second, conflicting
|
|
# class="..." on the <select> alongside it rather than merging with it.
|
|
child = forms.ModelChoiceField(queryset=None, label=_("Link to"), widget=forms.Select())
|
|
|
|
def __init__(self, *args, candidates=None, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.fields["child"].queryset = candidates
|
|
self.fields["child"].label_from_instance = lambda child: f"{child} ({child.date_of_birth:%d %b %Y})" if child.date_of_birth else str(child)
|