예제 #1
0
 def save(self, *args, **kwargs):
     if not self.title and self.value_type == 'course_personal':
         course = Course.objects.filter(user=self.user, value_type='course_personal')
         sum = len(course)+1
         self.title = _('Custom course %s') % sum
     if not self.slug:
         if self.title and self.value_type == 'course_front':
             self.slug = uuslug(self.title, instance=self)
         else:
             self.slug = uuslug('%s' % self.pk, instance=self)
     super(Course, self).save(*args, **kwargs)
예제 #2
0
파일: models.py 프로젝트: yomanpatil/remo
    def save(self, *args, **kwargs):
        if not self.pk:
            self.slug = uuslug(self.name, instance=self)
        else:
            # Update action items
            current_poll = Poll.objects.get(id=self.pk)
            action_model = ContentType.objects.get_for_model(self)
            action_items = ActionItem.objects.filter(content_type=action_model,
                                                     object_id=self.pk)

            if current_poll.end != self.end:
                action_items.update(due_date=self.end.date())

            if current_poll.valid_groups != self.valid_groups:
                action_items.delete()

            if not settings.CELERY_ALWAYS_EAGER:
                if self.is_current_voting:
                    celery_control.revoke(self.task_end_id)
                elif self.is_future_voting:
                    celery_control.revoke(self.task_start_id)
                    celery_control.revoke(self.task_end_id)

            if not self.is_future_voting:
                obj = Poll.objects.get(pk=self.id)
                if self.end > obj.end:
                    self.is_extended = True

        super(Poll, self).save()
예제 #3
0
파일: models.py 프로젝트: cbingos/blueberry
 def save(self,*args, **kwargs):
     self.slug = uuslug(self.title, instance=self,max_length=28,).replace('-','')
     if not self.productImg:
         pass
     else:
         self.create_thumbnail()
     super(ProductArticle, self).save(*args, **kwargs)
예제 #4
0
파일: models.py 프로젝트: bmelton/djig
 def save(self, *args, **kwargs):
     if not self.id:
         self.slug = uuslug(self.title, instance=self)
         self.title = self.title.encode("ascii", "ignore")
         self.created = datetime.datetime.now()
         assign('djig.group_view', everybody_group, self)
     super(Article, self).save(*args, **kwargs)
def add_events(apps, schema_editor):
    Event = apps.get_model('voting', 'Event')
    for event_name in EVENTS:
        if not Event.objects.filter(name=event_name).exists():
            event = Event(name=event_name)
            event.slug = uuslug(event_name, event)
            event.save()
예제 #6
0
    def save(self, *args, **kwargs):
        if not self.created:
            self.created        = datetime.now()

        if not self.slug:
            self.slug           = uuslug(self.name, instance=self)
            # self.legacy_username= str(self.user.username)
        super(Topic, self).save(*args, **kwargs)
예제 #7
0
파일: models.py 프로젝트: Copser/Poems_blog
    def save(self, *args, **kwargs):
        """TODO: Docstring for save.
        :returns: TODO

        """
        self.slug = uuslug(self.title, instance=self,
                           max_length=100)
        super(Post, self).save(*args, **kwargs)
예제 #8
0
 def save(self, *args, **kwargs):
     # Create unique slug
     self.slug = uuslug(self.title,
                        instance=self,
                        max_length=SLUG_LENGTH)
     # Prevent empty strings as slug
     if not self.slug:
         self.slug = uuslug('sans titre',
                            instance=self,
                            max_length=SLUG_LENGTH)
     # Delete old image
     try:
         this = BlogPost.objects.get(pk=self.pk)
         if this.image != self.image:
             this.image.delete()
     except:
         pass
     super().save(*args, **kwargs)
예제 #9
0
    def save(self, **kwargs):
        if self.slug is None:
            self.slug = uuslug(self.title, instance=self)

        if self.content_type_id is None:
            klass_name = self.__class__.__name__.lower()
            ct = ContentType.objects.get(model=klass_name)
            self.content_type = ct
        super(ECMCatalogEntry, self).save(**kwargs)
예제 #10
0
 def save(self, *args, **kwargs):
     """
     Rewrite the `save()` function to handle slug uniqueness
     """
     if kwargs.pop('force_slug_update', True):
         self.slug = uuslug(self.title, instance=self, max_length=80)
     update_date = kwargs.pop('update_date', True)
     if update_date:
         self.update_date = datetime.now()
     super(PublishableContent, self).save(*args, **kwargs)
예제 #11
0
파일: models.py 프로젝트: phodal/xunta
 def save(self, *args, **kwargs):
     keywords = []
     self.slug = uuslug(self.title, instance=self)
     if not self.keywords_string and getattr(settings, "AUTO_TAG", False):
         keywords = self.title.rstrip(punctuation).split()
     super(Juba, self).save(*args, **kwargs)
     if keywords:
         lookup = reduce(ior, [Q(title__iexact=k) for k in keywords])
         for keyword in Keyword.objects.filter(lookup):
             self.keywords.add(AssignedKeyword(keyword=keyword))
예제 #12
0
파일: models.py 프로젝트: Binzzzz/remo
 def save(self, *args, **kwargs):
     if not self.pk:
         self.slug = uuslug(self.name, instance=self)
     elif not settings.CELERY_ALWAYS_EAGER:
         if self.is_current_voting:
             celery_control.revoke(self.task_end_id)
         elif self.is_future_voting:
             celery_control.revoke(self.task_start_id)
             celery_control.revoke(self.task_end_id)
     super(Poll, self).save()
예제 #13
0
    def save(self, force_insert=False, force_update=False, using=None,
             update_fields=None):

        self.slug = uuslug(self.name,
                           instance=self,
                           max_length=100,
                           start_no=2,
                           word_boundary=True,
                           save_order=True)
        if not self.slug:
            self.slug = uuslug(self.heading + '_blog',
                               instance=self,
                               max_length=100,
                               start_no=2,
                               word_boundary=True,
                               save_order=True)

        self.slug = self.slug.lower()

        super(Blog, self).save(force_insert, force_update, using, update_fields)
예제 #14
0
파일: models.py 프로젝트: Arlefreak/vov
 def save(self, *args, **kwargs):
     self.sku = uuslug(self.name, instance=self, slug_field='sku')
     variants = ProductVariant.objects.filter(product=self)
     stock = 0
     for item in variants:
         stock += item.inventory
     if (stock > 0):
         self.status = 'IN'
     else:
         self.status = 'OUT'
     super(Product, self).save(**kwargs)
예제 #15
0
 def save(self):
     # tags = Tag.objects.all()
     # for tag in tags:
         # self.content = re.sub(u'<a class="keyword"\s*[^>]*>%s</a>'%(tag.name),
                               # u'%s'%(tag.name), self.content)
     # for tag in tags:
         # self.content = re.sub(u'%s'%(tag.name),
                               # u'<a class="keyword" href="/tag/%s/">%s</a>'%(tag.slug, tag.name), self.content, 1)
     if not self.slug:
         self.slug = uuslug(self.title, instance=self)
     return super(Blog, self).save()
예제 #16
0
    def slugify(self, tag, i=None):
        slug = uuslug(tag,
                      instance=self,
                      max_length=100,
                      start_no=2,
                      word_boundary=True,
                      save_order=True)
        if not slug:
            slug = uuslug(tag + '_tag',
                          instance=self,
                          max_length=100,
                          start_no=2,
                          word_boundary=True,
                          save_order=True)

        slug = slug.lower()

        if i is not None:
            slug += "_%d" % i

        return slug
예제 #17
0
파일: models.py 프로젝트: phodal/xunta
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.title, instance=self)
     keywords = []
     if not self.keywords_string and getattr(settings, "AUTO_TAG", False):
         func_name = getattr(settings, "AUTO_TAG_FUNCTION",
                             "drum.links.utils.auto_tag")
         keywords = import_dotted_path(func_name)(self)
     super(Link, self).save(*args, **kwargs)
     if keywords:
         lookup = reduce(ior, [Q(title__iexact=k) for k in keywords])
         for keyword in Keyword.objects.filter(lookup):
             self.keywords.add(AssignedKeyword(keyword=keyword), bulk=False)
예제 #18
0
    def save(self, force_insert=False, force_update=False, using=None,
             update_fields=None):
        """Pre-save routine like updating the slug field etc."""

        if not self.is_draft and self.created is None:
            self.created = timezone.now()

        self.slug = uuslug(self.heading,
                           instance=self,
                           max_length=100,
                           start_no=2,
                           word_boundary=True,
                           save_order=True)
        if not self.slug:
            self.slug = uuslug(self.heading + '_post',
                               instance=self,
                               max_length=100,
                               start_no=2,
                               word_boundary=True,
                               save_order=True)

        self.slug = self.slug.lower()

        super(Post, self).save(force_insert, force_update, using, update_fields)
예제 #19
0
 def save(self, *args, **kwargs):
     if self.pk is not None:
         orig = Memorial.objects.get(pk=self.pk)
         if not self.discount_price:
             self.discount_price = self.base_price
         # update discount_percent
         if orig and ((orig.discount_price != self.discount_price) or (orig.base_price != self.base_price)):
             if self.base_price > 0:
                 # error!
                 division_value = 100 - (float(self.discount_price) / float(self.base_price) * 100)
                 self.discount_percent = round(division_value)
         if not self.discount_price:
             self.discount_price = self.base_price
     # generate slug
     self.slug = uuslug(self.title, instance=self)
     super(Memorial, self).save(*args, **kwargs)
예제 #20
0
파일: models.py 프로젝트: psvramaraju/remo
    def save(self, *args, **kwargs):
        if not self.pk:
            self.slug = uuslug(self.name, instance=self)
        else:
            if not settings.CELERY_ALWAYS_EAGER:
                if self.is_current_voting:
                    celery_control.revoke(self.task_end_id)
                elif self.is_future_voting:
                    celery_control.revoke(self.task_start_id)
                    celery_control.revoke(self.task_end_id)

            if not self.is_future_voting:
                obj = Poll.objects.get(pk=self.id)
                if self.end > obj.end:
                    self.is_extended = True

        super(Poll, self).save()
예제 #21
0
    def save(self, *args, **kwargs):
        if len(self.content) > 200:
            self.excerpt        = "%s..." % (self.content[0:200])
        else:
            self.excerpt        = self.content

        if not self.id:
            self.created        = datetime.now()
            self.slug           = uuslug(self.title, instance=self)
            self.uid            = str(uuid4())           
        else:
            self.modified = datetime.now()

        # Will want to move this out to a signal to keep the model clean.
        version             = EntryVersion()
        version.title       = self.title
        version.uid         = self.uid
        version.slug        = self.slug
        version.start_date  = self.start_date
        version.save()
        super(Entry, self).save(*args, **kwargs)
예제 #22
0
    def get_or_init_instance(self, instance_loader, row):
        """Override method for custom functionality."""

        # If there isn't a username or the application is not complete,
        # do not return an instance.
        row['mozillian_username'] = get_mozillian_username(row)

        # Validate email
        email_validator = EmailValidator()
        try:
            email_validator(row['email'])
        except ValidationError:
            row['email'] = ''
        row['full_name'] = row['first_name'] + ' ' + row['last_name']

        instance, created = (super(MozillianGroupResouce, self)
                             .get_or_init_instance(instance_loader, row))
        entry_id = row['entry_id']
        application, _ = Application.objects.get_or_create(entry_id=entry_id)
        instance.application = application
        instance.slug = uuslug(instance.full_name, instance)
        return (instance, created)
예제 #23
0
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.title, instance=self, max_length=100)
     super(Post, self).save(*args, **kwargs)
예제 #24
0
 def save(self):
     self.slug = uuslug(self.title, instance=self)
     super(Category, self).save()
예제 #25
0
 def save(self):
     if self.name:
         self.slug = uuslug(self.name, instance=self)
     else:
         self.slug = 'anonymous'
     super(Author, self).save()
예제 #26
0
파일: models.py 프로젝트: vechnoe/products
 def save(self, *args, **kwargs):
     if not self.id:
         self.slug = uuslug(self.name, instance=self)
     super(Product, self).save(*args, **kwargs)
예제 #27
0
파일: models.py 프로젝트: SpaceFox/textes
 def save(self):
     self.slug = uuslug(self.title, instance=self)
     super(Genre, self).save()
예제 #28
0
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.author, instance=self)
     super(Autor, self).save(*args, **kwargs)
예제 #29
0
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.name, instance=self, start_no=9, max_length=19, word_boundary=True)
     super(SmartTruncatedExactWordBoundrySlug, self).save(*args, **kwargs)
예제 #30
0
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.name, instance=self)
     super(CoolSlug, self).save(*args, **kwargs)
예제 #31
0
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.title, instance=self)
     super(ImageList, self).save(*args, **kwargs)
예제 #32
0
    def save(self, *args, **kwargs):
        if not self.id:
            self.slug = uuslug(self.title, instance=self)

        super(Project, self).save(*args, **kwargs)
예제 #33
0
 def make_slug(thread, title):
     slug = uuslug(title,
                   filter_dict={'category': thread.category},
                   instance=thread,
                   max_length=SLUG_LENGTH)
     return slug
예제 #34
0
 def save(self, *args, **kwargs):
     if self.slug == None:  #注意,chafield未设default时,会被默认为'',而不是None
         self.slug = uuslug(self.title, instance=self, separator='')
     super(Artical, self).save(*args, **kwargs)
예제 #35
0
    def save(self, *args, **kwargs):
        self.slug = uuslug(self.name, instance=self)

        # Deletes cache of context processor that holds list of categories.
        cache.delete("default_context__header_categories")
        super().save(*args, **kwargs)
예제 #36
0
 def save(self, *args, **kwargs):
     """Persists a tag, recalculating its slug."""
     self.slug = uuslug(self.name, instance=self)
     super(Tag, self).save(*args, **kwargs)
예제 #37
0
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.name, instance=self, start_no=2, max_length=17, word_boundary=False)
     super(TruncatedSlug, self).save(*args, **kwargs)
예제 #38
0
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.name, instance=self, start_no=2, max_length=17, word_boundary=False, separator='_')
     super(TruncatedSlugDifferentSeparator, self).save(*args, **kwargs)
예제 #39
0
 def make_slug(self, title):
     slug = uuslug(title,
                   filter_dict={'category': self.category},
                   instance=self,
                   max_length=SLUG_LENGTH)
     return slug
예제 #40
0
 def save(self, *args, **kwargs):
     value = getattr(self, 'slug_field')
     self.slug = uuslug(getattr(self, value), instance=self)
     super().save(*args, **kwargs)
예제 #41
0
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.name, instance=self, start_no=2)
     super(AnotherSlug, self).save(*args, **kwargs)
예제 #42
0
    def save(self, *args, **kwargs):
        """Custom save method."""

        if not self.id:
            self.slug = uuslug(self.name, instance=self)
        super(Activity, self).save(*args, **kwargs)
예제 #43
0
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.title, instance=self, max_length=100)
     super(Post, self).save(*args, **kwargs)
예제 #44
0
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.name, instance=self, separator='_')
     super(CoolSlugDifferentSeparator, self).save(*args, **kwargs)
예제 #45
0
파일: models.py 프로젝트: ak4code/gh-mayak
 def save(self, *args, **kwargs):
     if not self.slug:
         self.slug = uuslug(self.meta_title, instance=self)
     super(SEOBase, self).save(*args, **kwargs)
예제 #46
0
파일: models.py 프로젝트: vacuumfull/na
def created_slug(sender, instance, **_):
    """Generate custom slug before save object."""
    if instance.pk is None:
        instance.slug = uuslug(instance.title, instance=instance)
예제 #47
0
 def save(self, *args, **kwargs):
     self.title = i18n_lower(self.title)
     self.slug = uuslug(self.title, instance=self)
     super().save(*args, **kwargs)
예제 #48
0
 def save(self, *args, **kwargs):
     if not self.pk:
         self.slug = uuslug(self.username, instance=self)
     super(MozillianProfile, self).save(*args, **kwargs)
예제 #49
0
파일: models.py 프로젝트: dayjobs/dayjobs
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.name, instance=self)
     self.job_url = '/jobs/' + self.slug
     self.day = datetime.strftime(datetime.now().date(), '%m-%d-%Y')
     super(Job, self).save(*args, **kwargs)
예제 #50
0
 def save(self, *args, **kwargs):
     if not self.pk:
         self.slug = uuslug(self.name, instance=self)
     super(Event, self).save(*args, **kwargs)
예제 #51
0
 def save(self, *args, **kwargs):
     if not self.pk:
         self.slug = uuslug(self.name, instance=self)
     super(Event, self).save(*args, **kwargs)
예제 #52
0
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.name, instance=self)
     super(Product, self).save(*args, **kwargs)
예제 #53
0
파일: models.py 프로젝트: SpaceFox/textes
 def save(self):
     self.slug = uuslug(self.title, instance=self)
     self.author_comment_html = markdown.markdown(self.author_comment)
     super(Novel, self).save()
예제 #54
0
def pre_save_post_receiver(sender, instance, *args, **kwargs):
    if not instance.slug:
        instance.slug = uuslug(instance.title, instance=instance)
예제 #55
0
파일: models.py 프로젝트: mci/mpatlas
 def save(self, *args, **kwargs):
     # self.slug = uuslug(self.name, instance=self, separator="_") # optional non-dash separator
     self.slug = uuslug(self.name, instance=self)
     super(Initiative, self).save(*args, **kwargs)
예제 #56
0
파일: models.py 프로젝트: rorik302/logistic
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.name_short, instance=self)
     super(CompanyType, self).save(*args, **kwargs)
예제 #57
0
파일: models.py 프로젝트: whitespy/svs
 def save(self, *args, **kwargs):
     if not self.slug:
         self.slug = uuslug(self.name, instance=self)
     super(Service, self).save(*args, **kwargs)
예제 #58
0
 def save(self):
     self.slug = uuslug(self.title, instance=self)
     super(BookList, self).save()
예제 #59
0
 def save(self, *args, **kwargs):
     self.slug = uuslug(self.title, instance=self)
     super(Problem, self).save(*args, **kwargs)
예제 #60
0
 def save(self, *args, **kwargs):
     #self.slug = uuslug(self.name, instance=self, separator="_")
     self.slug = uuslug(self.name, instance=self)
     super(Rhythm, self).save(*args, **kwargs)