Esempio n. 1
0
    def save(self, **kwargs):
        # title = self.metadata.get('title')
        # slug = self.metadata.get('slug')
        content = self.cleaned_data.get('content')

        article = self.instance
        if self.user:
            article = Article(author=self.user)

        article.title = self.cleaned_data.get('title')
        article.slug =  self.cleaned_data.get('slug')
        article.content = content
        article.content_body = self.content_body
        article.is_published = True
        article.markup = self.data.get('markup')
        # save article
        article.save()
        article.tags = self.cleaned_data.get('tags')

        # reset tags
        '''
        article.articletag_set.all().delete()
        for tag_name in self.metadata.get('tags', []):
            tag = Tag.objects.get_or_create(name=tag_name)[0]
            article.articletag_set.create(tag=tag)
        '''
        return article
Esempio n. 2
0
    def save(self, **kwargs):
        title = self.metadata.get('title')
        slug = self.metadata.get('slug')
        content = self.cleaned_data.get('content')
        is_published = self.metadata.get('published')
        image_id = self.metadata.get('image', '')

        if self.instance.pk is not None:
            article = self.instance
        else:
            article = Article(author=self.user)

        article.title = title
        article.slug = slug
        article.content = content
        article.content_body = self.content_body
        article.is_published = is_published
        article.markup = self.data.get('markup')

        # update cover image if it specified
        try:
            image = EntryImage.objects.get(id=int(image_id))
        except (EntryImage.DoesNotExist, ValueError, TypeError):
            image = None
        article.cover_image = image

        # save article
        article.save()

        # reset tags
        article.articletag_set.all().delete()
        for tag_name in self.metadata.get('tags'):
            tag = Tag.objects.get_or_create(name=tag_name)[0]
            article.articletag_set.create(tag=tag)

        return article
Esempio n. 3
0
    def save(self, **kwargs):
        # title = self.metadata.get('title')
        # slug = self.metadata.get('slug')
        content = self.cleaned_data.get('content')

        article = self.instance
        if self.user:
            article = Article(author=self.user)

        article.title = self.cleaned_data.get('title')
        article.slug = self.cleaned_data.get('slug')
        article.content = content
        article.content_body = self.content_body
        article.is_published = True
        article.markup = self.data.get('markup')
        # save article
        article.save()
        article.tags = self.cleaned_data.get('tags')

        # reset tags
        '''
        article.articletag_set.all().delete()
        for tag_name in self.metadata.get('tags', []):
            tag = Tag.objects.get_or_create(name=tag_name)[0]
            article.articletag_set.create(tag=tag)
        '''
        return article