Esempio n. 1
0
    def get_object(self, queryset=None):
        key = self.kwargs.get('key')
        if not key: raise Http404

        article = ArticleModel.get(Key(key))
        if not article: raise Http404

        return article
Esempio n. 2
0
    def get_initial(self):
        key = self.kwargs.get('key')
        if not key: raise Http404

        self.key = Key(key)

        article = ArticleModel.get(self.key)
        if not article: raise Http404
        return article.to_safe_dict()
Esempio n. 3
0
    def get_context_data(self, **kwargs):
        key = kwargs.get('key')
        if not key: raise Http404

        article_key = Key(key)
        article = ArticleModel.get(article_key)
        if not article: raise Http404

        kwargs['article'] = article.to_safe_dict()
        return super(ArticleView, self).get_context_data(**kwargs)
Esempio n. 4
0
    def form_valid(self, form):
        title = form.cleaned_data['title']
        body = form.cleaned_data['body']
        key = form.cleaned_data['key']

        article = ArticleModel.get(Key(key))

        article.update(title, body, self.request.user)

        article.put()
        return super(UpdateArticleView, self).form_valid(form)