Skip to content

feat: add unique URLs for Artwork, Marker, Object, and Exhibit - #957

Open
vjpixel wants to merge 2 commits into
developfrom
claude/scan-repo-bugs-35wDb
Open

vjpixel wants to merge 2 commits into
developfrom
claude/scan-repo-bugs-35wDb

Conversation

@vjpixel

@vjpixel vjpixel commented Jun 21, 2026

Copy link
Copy Markdown
Member
  • Add slug fields (unique, auto-generated) to Marker, Object, and Artwork models
  • Add save() method to auto-generate slugs from titles with collision handling
  • Add get_absolute_url() to Marker, Object, Artwork, and Exhibit models
  • Add detail views: marker_detail, object_detail, artwork_detail
  • Register URL patterns: markers//, objects//, artworks//
  • Create Jinja2 templates for marker_detail, object_detail, artwork_detail
  • Add migration 0028 to add slug fields to marker, object, and artwork tables

- Add slug fields (unique, auto-generated) to Marker, Object, and Artwork models
- Add save() method to auto-generate slugs from titles with collision handling
- Add get_absolute_url() to Marker, Object, Artwork, and Exhibit models
- Add detail views: marker_detail, object_detail, artwork_detail
- Register URL patterns: markers/<slug>/, objects/<slug>/, artworks/<slug>/
- Create Jinja2 templates for marker_detail, object_detail, artwork_detail
- Add migration 0028 to add slug fields to marker, object, and artwork tables
@vjpixel
vjpixel requested a review from pablodiegoss June 21, 2026 13:43
@vjpixel vjpixel added the priority: low Low priority - can be addressed later label Jun 21, 2026
Comment thread src/core/models.py
Comment on lines +468 to +476
base_slug = slugify(self.title) or "artwork"
slug = base_slug
counter = 1
while Artwork.objects.filter(slug=slug).exclude(pk=self.pk).exists():
slug = f"{base_slug}-{counter}"
counter += 1
self.slug = slug
super().save(*args, **kwargs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using this counter in a while. If it conflicts with an existing slug, use directly the ID which is unique, not a counter in a while

@pablodiegoss pablodiegoss left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You added new URLs and views, but there is no button anywhere on the site that takes to that URL you defined as the slug, you will have to guess the slug generated for each marker/artwork/object and type it directly into the browser to go to your new page. It is basically hidden from every user besides you, IF you can guess what is the slug to type

@pablodiegoss

Copy link
Copy Markdown
Member

Our current "details" page are the modal pages we have when the user clicks on any content. Clicking on content opens the modal page and I'm not sure if you are trying to include this new link to replace the modal or include the new links at the modal pages to "see more details" of some content.

Resolves the conflict and the 405 it was hiding.

Conflicts were additive on both sides and both sides are kept:
- Marker: slug alongside in_use / is_used_by_other_user
- Object: slug, save() and get_absolute_url() alongside the spritesheet
  fields, width and height
- urls.py: both ar_view and artwork_detail imports

The slug migration is renumbered 0028 -> 0045 and redepended on
0044_populate_sound_in_use_fields, because develop already carries a 0028
and two would leave the graph with conflicting leaf nodes. 0046 regenerates
the pghistory triggers for the new field.

Separately, the <slug:slug> detail routes were inserted alphabetically,
which placed them before their literal siblings. Django matches in order and
"create", "edit", "upload" and "convert-spritesheet" all satisfy the slug
converter, so every POST to those endpoints resolved to a GET-only detail
view and returned 405 - 49 failing tests after the merge. Each detail route
now comes last within its prefix group, with a comment and a regression test
asserting the resolution order.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXUw7kyELDu8ycGQxtaFbb

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: low Low priority - can be addressed later

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants