예제 #1
0
 def get(self, article_key=None, errors=None):
     article = Article.get(article_key)
     if article is None or not article.is_active:
         return self.error(404)
     base_rev_key = self.request.get('base')
     base_rev = None
     if base_rev_key:
         base_rev = ArticleRevision.get(base_rev_key)
     if base_rev is None:
         base_rev = article.get_current_revision()
     content = base_rev.content
     return self.render('revision_add.html', locals())
예제 #2
0
 def post(self, article_key=None):
     article = Article.get(article_key)
     if article is None or not article.is_active:
         return self.error(404)
     rev_key = self.request.get('revision_key')
     if not rev_key:
         return self.error(404)
     rev = ArticleRevision.get(rev_key)
     if rev is None or rev.article.key() != article.key():
         return self.error(401)
     article.current_rev_key = str(rev.key())
     article.put()
     return self.redirect(article.href())
예제 #3
0
    def get(self, article_key=None):
        article = Article.get(article_key)
        if article is None or not article.is_active:
            return self.error(404)

        revision = None
        rev_key = self.request.get('rev', '')
        if rev_key:
            revision = ArticleRevision.get(rev_key)

        if not revision:
            revision = article.get_current_revision()

        return self.render('article_view.html', locals())
예제 #4
0
    def post(self, article_key=None):
        article = Article.get(article_key)
        if article is None or not article.is_active:
            return self.error(404)

        errors = []
        content = self.request.get('content', '').strip()
        if not content:
            errors.append('Content cannot be empty')

        if errors:
            return self.render('revision_add.html', locals())

        user = self.get_current_user()
        rev = ArticleRevision(user=user, article=article,
                              content=content)
        rev.put()
        if user == article.creator:
            article.current_rev_key = str(rev.key())
        article.put()
        full_rev_url = urlparse.urljoin(self.request.uri, rev.href())
        blip = Blip.new(user, u'edited article %s %s' % (article.title,
                                                         full_rev_url))
        return self.redirect(article.href())