Exemplo n.º 1
0
def shorturl_generate(sender, instance, created, **kwargs):
    if GENERATE_SHORT_URL:
        if not instance.short_url:
            instance.short_url = GooglUrlShort(
                instance.get_http_absolute_url()
            ).short()
            instance.save()
Exemplo n.º 2
0
 def save(self, *args, **kwargs):
     if not self.short_url:
         self.short_url = GooglUrlShort(self.get_http_absolute_url())\
             .short()
     self.channel_name = self.channel.name
     self.channel_long_slug = self.channel.long_slug
     self.child_class = self.__class__.__name__
     super(Article, self).save(*args, **kwargs)
Exemplo n.º 3
0
def googlshort(url):

    uid = uuid.uuid3(uuid.NAMESPACE_DNS, url)

    cache_url = cache.get('googlshort_%s' % uid)
    if cache_url:
        return cache_url

    cache_url = GooglUrlShort(url).short(False)
    cache.set('googlshort_%s' % uid, cache_url)

    return cache_url
Exemplo n.º 4
0
 def save(self, *args, **kwargs):
     if not self.short_url:
         self.short_url = GooglUrlShort(self.get_http_absolute_url())\
             .short()