From b1ae76aea0141354b479e1c0451bc003e9b6e248 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Mon, 30 May 2011 18:06:12 -0500 Subject: [PATCH] Add an index on MediaEntries making sure slugs + uploader combos are unique --- mediagoblin/db/models.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 37420834..3da97a49 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -95,7 +95,7 @@ class MediaEntry(Document): 'thumbnail_file': [unicode]} required_fields = [ - 'uploader', 'created', 'media_type'] + 'uploader', 'created', 'media_type', 'slug'] default_values = { 'created': datetime.datetime.utcnow, @@ -103,11 +103,10 @@ class MediaEntry(Document): migration_handler = migrations.MediaEntryMigration - # Actually we should referene uniqueness by uploader, but we - # should fix http://bugs.foocorp.net/issues/340 first. - # indexes = [ - # {'fields': ['uploader', 'slug'], - # 'unique': True}] + indexes = [ + # Referene uniqueness of slugs by uploader + {'fields': ['uploader', 'slug'], + 'unique': True}] def main_mediafile(self): pass -- 2.25.1