Add optional Project.display_short_name for compact artifact cards (#1156)#1382
Merged
Conversation
…1156) Publication/talk/video cards showed the project's full name in the flask "View project" chip, which is long and noisy. Add an optional display_short_name field (e.g. "Sidewalk" for "Project Sidewalk") and render it on those three compact snippets via a new get_display_short_name() that falls back to the full name when blank. aria-labels keep the full name. Also clarify the help_text on all three name fields so the admin distinguishes them: name (full title), display_short_name (optional short card label), and short_name (lowercase, no-spaces URL slug). While here, add a Project.clean() that rejects a short_name colliding case-insensitively with an existing project's slug. The project view resolves /projects/<slug>/ via short_name__iexact, so a duplicate slug raises MultipleObjectsReturned (a 500) on both pages. This is the form-level guard; a DB-level unique constraint is deferred until prod data is de-duped. Tests: fallback behavior for get_display_short_name and slug-uniqueness validation (case-insensitive, self-excluded on edit). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1156.
Problem
Publication / talk / video cards show the project's full name in the flask "View project" chip, which is long and noisy for projects with descriptive titles (e.g. "Multi-Stakeholder Interviews to Address Urban Accessibility").
The existing
Project.short_namecan't be used for this — it's the URL slug (lowercase, no spaces, e.g.projectsidewalk), not a reader-facing label.Change
Project.display_short_name— a short display label (e.g. "Urban Access"). Optional; when blank, rendering falls back to the fullname.Project.get_display_short_name()centralizes that fallback (display_short_name or name).display_pub_snippet,display_talk_snippet,display_video_snippet) now renderget_display_short_name. Thearia-labelkeeps the full name for screen readers; the link still uses theshort_nameslug.name— full title shown as the headingdisplay_short_name— optional short card label (blank = use full name)short_name— lowercase/no-spaces URL slug, not shown to readersdisplay_short_nameadded to the Project admin form.Bonus: slug-uniqueness guard
While here, added
Project.clean()rejecting ashort_namethat collides case-insensitively with an existing project. The project view resolves/projects/<slug>/viashort_name__iexact, so a duplicate slug raisesMultipleObjectsReturned— a 500 on both project pages. This is the form-level guard (mirrors the keyword-dedup approach); a DB-level unique constraint is deferred until prod data is confirmed de-duped (follow-up issue).Before / After
Same publication card; the "before" state is reproduced by leaving
display_short_nameblank (the fallback path).Testing
python manage.py test website --settings=makeabilitylab.settings_test→ 493 passed, 8 skipped.test_project.py:get_display_short_namefallback (set / None / empty) and slug-uniqueness validation (case-insensitive, self-excluded on edit).Notes
🤖 Generated with Claude Code