def test_slug_generation(self): """ Tests that slugs of all possible lengths can be generated without causing an Exception """ for i in xrange(1, len(VALID_WORDS)): get_unused_slug(i)
def save(self,**kwargs): # If a new redirect if not self.pk: from redirects.utils import get_unused_slug self.full_clean(exclude=['slug','expiry','word_list']) self.slug, words = get_unused_slug(DURATION_WORD_COUNT[self.duration]) self.word_list = ','.join(words) self.expiry = django.utils.timezone.now() + DURATION_DELTA[self.duration] self.full_clean() archive_kwargs = { 'url':self.url, 'slug':self.slug, 'expiry':self.expiry, } archive = ArchivedRedirect(**archive_kwargs) archive.save() super(LiveRedirect,self).save(**kwargs)