Fail gracefully when a duplicate title or slug is submitted

VERIFIED FIXED in 2.3

Status

P2
normal
VERIFIED FIXED
8 years ago
8 years ago

People

(Reporter: erik, Assigned: rrosario)

Tracking

unspecified

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

8 years ago
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.
(Reporter)

Comment 1

8 years ago
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
(Reporter)

Comment 2

8 years ago
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()?
(Reporter)

Comment 5

8 years ago
Maybe clean()?
(Reporter)

Comment 6

8 years ago
The example in the docs doesn't call super(), but it wouldn't be the first time the docs were wrong.
(Assignee)

Updated

8 years ago
Assignee: nobody → rrosario
(Assignee)

Comment 7

8 years ago
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
Last Resolved: 8 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.