Ejemplo n.º 1
0
def complete_instance(sender, instance, **kwargs):
    logger.debug('page {pk:%s} @pre_save' % instance.pk)
    if not instance.slug:
        instance.slug = helpers.get_unique_slug(instance,
                                                instance.name,
                                                max_length=32)
        logger.debug('page {pk:%s, slug:%s} @pre_save slug generated' %
                     (instance.pk, instance.slug))
Ejemplo n.º 2
0
    def save(self, *args, **kwargs):
        if not self.slug:
            self.slug = helpers.get_unique_slug(self, self.name, 100)

        # for a in settings.LANGUAGES:
        #   config_language = a[3]
        # self.search = SearchVector('name', weight='A', config='simple')

        super(Tag, self).save(*args, **kwargs)
Ejemplo n.º 3
0
    def save(self, *args, **kwargs):
        """
    perform save
    """
        self._saved = getattr(self, '_saved', 0)
        self._saved = self._saved + 1
        logger.debug('story@save  {pk:%s} init save, time=%s' %
                     (self.pk, self._saved))

        # check slug
        if not self.slug:
            self.slug = helpers.get_unique_slug(self,
                                                self.title,
                                                max_length=68)
            logger.debug('story@save {pk:%s, slug:%s} slug generated.' %
                         (self.pk, self.slug))

        if self.date is None:
            logger.debug(
                'story@save {slug:%s,pk:%s} not having a default date. Fixing...'
                % (self.slug, self.pk))
            self.date = self.date_last_modified

        # this is the woner
        # print 'owner', self.owner
        # create story file if it is not exists; if the story eists already, cfr the followinf story_ready
        if self._saved == 1:
            try:
                self.write_contents()
                self.commit_contents()
            except Exception as e:
                logger.exception(e)
            else:
                logger.debug(
                    'story@save {pk:%s}: write_contents_to_path done.' %
                    self.pk)

        logger.debug(
            'story@save {slug:%s,pk:%s} completed, ready to dispatch @postsave, time=%s'
            % (self.slug, self.pk, self._saved))
        super(Story, self).save(*args, **kwargs)
Ejemplo n.º 4
0
 def save(self, *args, **kwargs):
     if not self.pk and not self.slug:
         self.slug = helpers.get_unique_slug(self, self.fullname)
     super(Author, self).save(*args, **kwargs)