Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Commit

Permalink
Models: truncate slugs
Browse files Browse the repository at this point in the history
  • Loading branch information
sevein committed Nov 24, 2017
1 parent 8bb47e9 commit c37dc8a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fpr/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ def __unicode__(self):

def _slug(self):
""" Returns string to be slugified. """
return "{} {}".format(self.description, self.version)
src = '{} {}'.format(self.description, self.version)
encoded = src.encode('utf-8')[:self.slug.max_length]
return encoded.decode('utf-8', 'ignore')


# ########### NORMALIZATION ############
Expand Down Expand Up @@ -389,7 +391,9 @@ def __unicode__(self):

def _slug(self):
""" Returns string to be slugified. """
return "{} {}".format(self.description, self.version)
src = '{} {}'.format(self.description, self.version)
encoded = src.encode('utf-8')[:self.slug.max_length]
return encoded.decode('utf-8', 'ignore')


# ########################### API V1 & V2 MODELS #############################
Expand Down

0 comments on commit c37dc8a

Please sign in to comment.