Skip to content

Conversation

@hannaseithe
Copy link
Contributor

@hannaseithe hannaseithe commented Jan 15, 2026

Short description

This PR is based on: #3917

  • a (@shared_task) script that makes sure all latest translations of events, pois and pages have unique slugs (EDIT: I have decided to delete the query for only latest translations, since the database constraint will guarantee it for all)
  • a management command that queues the script with celery

Proposed changes

  • the script is optimized for speed compared to the original migration script
  • if this command runs fast enough, I will turn it into a migration and add it to PoC: Add an Exclusion Constraint for pagetranslation's slug uniqueness #3826
  • I have added no tests for now, as its unsure we will keep the command anyways and because I see no way to create a test state with duplicate slugs with the application level constraints already in place and the database constraints coming up soon

Side effects

  • None

Faithfulness to issue description and design

There are no intended deviations from the issue and design.

How to test

  • You will have to manipulate the test-data.json to get duplicate slugs (within one region and language!)
  • Or enter the slugs into the database directly (django-admin wont work)
  • in the shell you can use the .update method or the bulk_create method as they circumvent the application level constraints that have already been implemented

Then run the command with tools/integreat-cms-cli make_slugs_unique

Resolved issues

Fixes: #
Blocks: #3826
Relates to #3917


Pull Request Review Guidelines

@hannaseithe hannaseithe marked this pull request as draft January 20, 2026 09:28
@hannaseithe hannaseithe marked this pull request as ready for review January 20, 2026 11:20
@dkehne
Copy link
Collaborator

dkehne commented Jan 22, 2026

Review Summary

What it does

  • Creates a Celery @shared_task called make_all_slugs_unique that iterates through all page/event/POI translations and regenerates slugs to ensure uniqueness
  • Adds a management command make_slugs_unique that queues this task
  • Supports --dry-run flag and filtering by object type (--objects page event poi)

Key observations

  1. Uses existing generate_unique_slug - Reuses the established slug generation logic, which is good for consistency

  2. Transaction handling - Uses transaction.atomic() to batch changes, good for data integrity

  3. Celery task with .delay() - The command queues the task asynchronously, which is appropriate for potentially long-running operations

  4. Missing from __future__ import annotations - The new management command file is missing this required import (per project guidelines)

  5. Type import issue - Final is imported inside TYPE_CHECKING block but used at module level for DEFAULT_OBJECTS. This will cause a runtime NameError:

    DEFAULT_OBJECTS: Final[tuple[SlugObject, ...]] = ("event", "poi", "page")

    Final needs to be imported outside the TYPE_CHECKING block.

  6. No tests - Author acknowledges this and explains why (can't easily create duplicate slug state with constraints in place)

  7. Dry-run passed to Celery - The dry_run parameter is passed to the async task, which works but means you can't see real-time output of what would change

Potential bug: The Final type annotation will cause a NameError at runtime since it's only imported under TYPE_CHECKING.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants