Example #1
0
    def save(self, *args, **kwargs):
        if not self.shortcode:
            self.shortcode = create_shortcode(self)

        if 'http' not in self.url:
            self.url = 'http://' + self.url

        super(KirrURL, self).save(*args, **kwargs)
Example #2
0
 def refresh_shortcodes(self):
     qs = KirrURL.objects.filter(id__gte=1)
     new_codes = 0
     for q in qs:
         self.shortcode = create_shortcode(q)
         q.save()
         new_codes += 1
     return "New codes is {i}".format(i=new_codes)
Example #3
0
    def save(self, *args, **kwargs):

        # print('FALG: ', kwargs.get('flag'))
        if self.shortcode is None or self.shortcode == '':
            self.shortcode = create_shortcode(self)
        logger.info(
            "Created ShortURL record with URL:{0} and shortcode:{1}!".format(
                self.url, self.shortcode))
        super(ShortURL, self).save(*args, **kwargs)
Example #4
0
 def save(self, *arg, **kwargs):
     """
     Overrides save method of KirrURL model
     :param: *args
     :param: *kwargs
     """
     if not self.shortcode:
         self.shortcode = utils.create_shortcode(instance=self)
     super(KirrURL, self).save(*arg, **kwargs)
Example #5
0
 def refresh_shortcodes(self, items=None):
     qs = PcURL.objects.filter(id__gte=1)
     if items is not None and isinstance(items, int):
         qs = qs.order_by('-id')[:items]
     new_codes = 0
     for q in qs:
         q.shortcode = create_shortcode(q)
         print q.id
         q.save()
         new_codes += 1
     return "New codes made: {i}".format(i=new_codes)
Example #6
0
 def save(self, *args, **kwargs):
     if self.shortcode is None or self.shortcode == "":
         self.shortcode = create_shortcode(self)
     super(Shortener, self).save(*args, **kwargs)
Example #7
0
 def save(self, *args, **kwargs):
     if self.shortcode is None or self.shortcode == "":
         self.shortcode = create_shortcode(self)
     if not "http" in self.url:
         self.url = "http://" + self.url
     super(PcURL, self).save(*args, **kwargs)
Example #8
0
    def reset_codes(self):
        query_set = KirrURL.objects.all()

        for item in query_set:
            item.shortcode = create_shortcode(item)
            item.save()
Example #9
0
 def save(self, *args, **kwargs):
     if not self.shortcode:
         self.shortcode = create_shortcode(self)
     super(GrivURL, self).save(*args, **kwargs)