Closed Bug 599989 Opened 14 years ago Closed 14 years ago

Fail gracefully when a duplicate title or slug is submitted

Categories

(support.mozilla.org :: Knowledge Base Software, task, P2)

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: erik, Assigned: rrosario)

Details

Trying to make a new document having the same title-locale or slug-locale pair as an existing one throws an IntegrityError. Do something nicer. I've introduced SlugCollision and TitleCollision in the redirect branch and will be raising them at appropriate times; we just have to catch them in the view.
We now have a wiki.views.json_view view that we could use to do real-time validation (thought we should still tolerate collisions that happen server-side). http://github.com/jsocol/kitsune/commit/f74eeabcb03038ee8ee737b1a171ba9bfade6f86
According to http://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objects, the ModelForm validation should check the unique_together constraints. Why doesn't it?
Did you try updating your django version?
(In reply to comment #2)
> According to
> http://docs.djangoproject.com/en/dev/ref/models/instances/#validating-objects,
> the ModelForm validation should check the unique_together constraints. Why
> doesn't it?

It totally should. Are we overriding a method without calling super()?
Maybe clean()?
The example in the docs doesn't call super(), but it wouldn't be the first time the docs were wrong.
Assignee: nobody → rrosario
Landed:
https://github.com/jsocol/kitsune/commit/953efe2d4b61082979154d7222ee997d80dac9b4

There is a separate issue still, where title and slug uniqueness with locale is case-insensitive, but the check for creating redirects automatically is case-sensitive. I'll file that in a separate bug.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Verified duplicate article names and slugs give error message
Status: RESOLVED → VERIFIED
Verified duplicate article names and slugs give error message
You need to log in before you can comment on or make changes to this bug.