aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/db/mixin.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2013-01-23 16:49:54 -0600
committerChristopher Allan Webber <cwebber@dustycloud.org>2013-01-23 16:49:54 -0600
commita81082fcaf41666841f40b823ddcef0255aebbe3 (patch)
treebfa8781e18bcb5c02d7ddd29d0c577fb816e485e /mediagoblin/db/mixin.py
parent394a4a37f7f71a6182d47cf7e6fcdf4fcccddd5d (diff)
downloadmediagoblin-a81082fcaf41666841f40b823ddcef0255aebbe3.tar.lz
mediagoblin-a81082fcaf41666841f40b823ddcef0255aebbe3.tar.xz
mediagoblin-a81082fcaf41666841f40b823ddcef0255aebbe3.zip
New mediaentry slug tests now pass!
- fixed some issues with "whacking uuid junk on the slug" - uuid4() -> uuid.uuid4() so that mock will work right - added all the tests!
Diffstat (limited to 'mediagoblin/db/mixin.py')
-rw-r--r--mediagoblin/db/mixin.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py
index 98414d72..b69e7d51 100644
--- a/mediagoblin/db/mixin.py
+++ b/mediagoblin/db/mixin.py
@@ -27,7 +27,7 @@ These functions now live here and get "mixed in" into the
real objects.
"""
-from uuid import uuid4
+import uuid
from werkzeug.utils import cached_property
@@ -113,9 +113,10 @@ class MediaEntryMixin(object):
# okay, still no success;
# let's whack junk on there till it's unique.
- self.slug += '-'
+ self.slug += '-' + uuid.uuid4().hex[:4]
+ # keep going if necessary!
while check_media_slug_used(self.uploader, self.slug, self.id):
- self.slug += uuid4().hex[:4]
+ self.slug += uuid.uuid4().hex[:4]
@property
def description_html(self):