Skip to content

Commit

Permalink
Bugfixes to slug handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lmorchard committed Feb 22, 2013
1 parent 81bf49d commit 963f2ff
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions badger/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def mk_upload_to(field_fn, ext, tmpl=MK_UPLOAD_TMPL):
"""upload_to builder for file upload fields"""
def upload_to(instance, filename):
base, slug = instance.get_upload_meta()
slug_hash = (hashlib.md5(instance.slug.encode('utf-8', 'ignore'))
slug_hash = (hashlib.md5(slug.encode('utf-8', 'ignore'))
.hexdigest())
return tmpl % dict(now=int(time()), rand=random.randint(0, 1000),
slug=slug[:50], base=base, field_fn=field_fn,
Expand Down Expand Up @@ -434,8 +434,7 @@ def clean(self):

def save(self, **kwargs):
"""Save the submission, updating slug and screenshot thumbnails"""
awards_count = self.award_set.count()
if awards_count == 0:
if not self.slug:
self.slug = slugify(self.title)

super(Badge, self).save(**kwargs)
Expand Down

0 comments on commit 963f2ff

Please sign in to comment.