Exemplo n.º 1
0
 def post(self):
     if not self._auth.is_authorized():
         abort(401)
     args = books_parser.parse_args()
     books = Books.add(args['title'], args['author'], args['content'],
                       args['link'], self._auth.get_user())
     return jsonify(books.serialize)
Exemplo n.º 2
0
 def dark_Books_create_form():
     if not auth.is_authorized():
         return redirect('/login')
     form = BooksCreateForm()
     if form.validate_on_submit():
         title = form.title.data
         author = form.author.data
         content = form.content.data
         link = form.link.data
         Books.add(title=title,
                   author=author,
                   content=content,
                   link=link,
                   user=auth.get_user())
         return redirect('/')
     return render_template('dark_books-create.html',
                            title='Создать книгу',
                            form=form)