예제 #1
0
 def save(self):
     post = super(AdminPostForm, self).save(commit=False)
     
     if post.pk is None:
         if self.cleaned_data["publish"]:
             post.published = datetime.now()
     else:
         if Post.objects.filter(pk=post.pk, published=None).count():
             if self.cleaned_data["publish"]:
                 post.published = datetime.now()
     
     post.teaser_html = parse(self.cleaned_data["teaser"], emitter=BiblionHtmlEmitter)
     post.content_html = parse(self.cleaned_data["content"], emitter=BiblionHtmlEmitter)
     post.updated = datetime.now()
     post.save()
     
     r = Revision()
     r.post = post
     r.title = post.title
     r.teaser = self.cleaned_data["teaser"]
     r.content = self.cleaned_data["content"]
     r.author = post.author
     r.updated = post.updated
     r.published = post.published
     r.save()
     
     if can_tweet() and self.cleaned_data["tweet"]:
         post.tweet()
     
     return post
예제 #2
0
파일: forms.py 프로젝트: nrb/biblion
 def save(self):
     post = super(AdminPostForm, self).save(commit=False)
     
     if post.pk is None:
         if self.cleaned_data["publish"]:
             post.published = datetime.now()
     else:
         if Post.objects.filter(pk=post.pk, published=None).count():
             if self.cleaned_data["publish"]:
                 post.published = datetime.now()
     
     render_func = curry(load_path_attr(PARSER[0]), **PARSER[1])
     
     post.teaser_html = render_func(self.cleaned_data["teaser"])
     post.content_html = render_func(self.cleaned_data["content"])
     post.updated = datetime.now()
     post.save()
     
     r = Revision()
     r.post = post
     r.title = post.title
     r.teaser = self.cleaned_data["teaser"]
     r.content = self.cleaned_data["content"]
     r.author = post.author
     r.updated = post.updated
     r.published = post.published
     r.save()
     
     if can_tweet() and self.cleaned_data["tweet"]:
         post.tweet()
     
     return post
예제 #3
0
 def save(self):
     post = super(AdminPostForm, self).save(commit=False)
     
     if post.pk is None:
         if self.cleaned_data["publish"]:
             post.published = datetime.now()
     else:
         if Post.objects.filter(pk=post.pk, published=None).count():
             if self.cleaned_data["publish"]:
                 post.published = datetime.now()
     
     render_func = curry(load_path_attr(PARSER[0], **PARSER[1]))
     
     post.teaser_html = render_func(self.cleaned_data["teaser"])
     post.content_html = render_func(self.cleaned_data["content"])
     post.updated = datetime.now()
     post.save()
     
     r = Revision()
     r.post = post
     r.title = post.title
     r.teaser = self.cleaned_data["teaser"]
     r.content = self.cleaned_data["content"]
     r.author = post.author
     r.updated = post.updated
     r.published = post.published
     r.save()
     
     if can_tweet() and self.cleaned_data["tweet"]:
         post.tweet()
     
     return post
예제 #4
0
파일: forms.py 프로젝트: akaihola/biblion
 def save(self):
     post = super(AdminPostForm, self).save(commit=False)
     
     if post.pk is None:
         if self.cleaned_data["publish"]:
             post.published = datetime.now()
     else:
         if Post.objects.filter(pk=post.pk, published=None).count():
             if self.cleaned_data["publish"]:
                 post.published = datetime.now()
     
     post.teaser_html = parse(self.cleaned_data["teaser"], emitter=BiblionHtmlEmitter)
     post.content_html = parse(self.cleaned_data["content"], emitter=BiblionHtmlEmitter)
     post.updated = datetime.now()
     post.save()
     
     r = Revision()
     r.post = post
     r.title = post.title
     r.teaser = self.cleaned_data["teaser"]
     r.content = self.cleaned_data["content"]
     r.author = post.author
     r.updated = post.updated
     r.published = post.published
     r.save()
     
     if can_tweet() and self.cleaned_data["tweet"]:
         post.tweet()
     
     return post
예제 #5
0
파일: forms.py 프로젝트: IbnSaeed/biblion
    def save(self):
        published = False
        post = super(AdminPostForm, self).save(commit=False)

        if post.pk is None:
            if self.cleaned_data["publish"]:
                post.published = datetime.now()
                published = True
        else:
            if Post.objects.filter(pk=post.pk, published=None).count():
                if self.cleaned_data["publish"]:
                    post.published = datetime.now()
                    published = True

        render_func = curry(
            load_path_attr(
                settings.BIBLION_MARKUP_CHOICE_MAP[self.cleaned_data["markup"]]["parser"]
            )
        )

        post.teaser_html = render_func(self.cleaned_data["teaser"])
        post.content_html = render_func(self.cleaned_data["content"])
        post.updated = datetime.now()
        post.save()

        r = Revision()
        r.post = post
        r.title = post.title
        r.teaser = self.cleaned_data["teaser"]
        r.content = self.cleaned_data["content"]
        r.author = post.author
        r.updated = post.updated
        r.published = post.published
        r.save()

        if can_tweet() and self.cleaned_data["tweet"]:
            post.tweet()

        if published:
            post_published.send(sender=Post, post=post)

        return post
예제 #6
0
    def save(self):
        published = False
        post = super(AdminPostForm, self).save(commit=False)

        if post.pk is None:
            if self.cleaned_data["publish"]:
                post.published = datetime.now()
                published = True
        else:
            if Post.objects.filter(pk=post.pk, published=None).count():
                if self.cleaned_data["publish"]:
                    post.published = datetime.now()
                    published = True

        render_func = curry(
            load_path_attr(
                MARKUP_CHOICE_MAP[self.cleaned_data["markup"]]["parser"]))

        post.teaser_html = render_func(self.cleaned_data["teaser"])
        post.content_html = render_func(self.cleaned_data["content"])
        post.updated = datetime.now()
        post.save()

        r = Revision()
        r.post = post
        r.title = post.title
        r.teaser = self.cleaned_data["teaser"]
        r.content = self.cleaned_data["content"]
        r.author = post.author
        r.updated = post.updated
        r.published = post.published
        r.save()

        if can_tweet() and self.cleaned_data["tweet"]:
            post.tweet()

        if published:
            post_published.send(sender=Post, post=post)

        return post