Esempio n. 1
0
class AddView(BaseView):
    _template = 'add_blog.html'
    _form = None
    _context = {}

    def get(self):
        from blog.forms import AddContentModalForm
        self._form = AddContentModalForm
        self._form._has_pagedown = True
        from .models import Article
        articles = Article.query.all()
        self._context['articles'] = articles
        return self.render()

    def post(self):
        from blog.forms import AddContentModalForm
        from auth.models import User
        self._form = AddContentModalForm(request.form)
        from blog.models import Article
        a = Article()
        self._form.populate_obj(a)
        a.author = User.query.filter(
            User.email == session.get('email', None)).first()
        a.save()
        return self.redirect('blog.index')
Esempio n. 2
0
 def post(self):
     from blog.forms import AddContentModalForm
     from auth.models import User
     self._form = AddContentModalForm(request.form)
     from blog.models import Article
     a = Article()
     self._form.populate_obj(a)
     a.author = User.query.filter(
         User.email == session.get('email', None)).first()
     a.save()
     return self.redirect('blog.index')
Esempio n. 3
0
 def post(self):
     from blog.forms import AddContentModalForm
     from auth.models import User
     self._form = AddContentModalForm(request.form)
     from blog.models import Article
     a = Article()
     self._form.populate_obj(a)
     a.author = User.query.filter(User.email==session.get('email',None)).first()
     a.save()
     return self.redirect('blog.index')
Esempio n. 4
0
class AddView(BaseView):
    _template = 'add_blog.html'
    _form = None
    _context = {}

    def get(self):
        from blog.forms import AddContentModalForm
        self._form = AddContentModalForm
        self._form._has_pagedown = True
        from .models import Article
        articles = Article.query.all()
        self._context['articles'] = articles
        return self.render()

    def post(self):
        from blog.forms import AddContentModalForm
        from auth.models import User
        self._form = AddContentModalForm(request.form)
        from blog.models import Article
        a = Article()
        self._form.populate_obj(a)
        a.author = User.query.filter(User.email==session.get('email',None)).first()
        a.save()
        return self.redirect('blog.index')