Skip to content

Awards admin: add instant image preview + square cropping for the badge field #1408

Description

@jonfroehlich

The new Awards admin page lets editors upload a custom display badge (emblem/logo shown as the award's anchor on the public Awards page), but unlike our other image uploads (People headshots, News thumbnails, Sponsor logos) it does not follow the standard admin pattern:

  • no instant client-side preview of the selected file before saving, and
  • no cropping control.

Fix

Apply the established ImageCroppingMixin + ImageRatioField (Cropper.js) pattern to Award.badge:

  • New Award.badge_cropping square (245x245) ImageRatioField — matches the Person/Sponsor portrait anchors so every award-row anchor (badge, portrait, project thumbnail, medal) reads as a uniform square tile.
  • AwardAdmin subclasses ImageCroppingMixin; badge_cropping added to the Display fieldset; new square "Badge" thumbnail column on the changelist.
  • Public display_award_snippet.html renders the badge through {% thumbnail ... box=award.badge_cropping crop %} so the crop is actually applied (was raw badge.url).
  • .award-anchor-badge CSS switched from contain/borderless to the shared square cover+border tile for uniformity.
  • Regression tests pin the crop metadata + that the admin resolves the badge field to the Cropper.js widget.

Notes

  • Square crop is intentional (uniform award row); editors re-crop on upload.
  • Existing badges have a blank crop box until re-saved; crop_corners treats blank as "no box" and center-crops, so nothing breaks in the meantime.
  • New badge_cropping column is created by the auto-makemigrations/migrate on container start (migrations are gitignored).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions