예제 #1
0
    def post(self):
        id = int(self.request.get("id"))
        bookEdit = Book.get_by_id(id)
        if bookEdit:
            bookEdit.isbn = int(self.request.get("isbn"))
            bookEdit.type = self.request.get("type")
            bookEdit.title = self.request.get("title")
            bookEdit.author = self.request.get("author")
            bookEdit.avaliable = int(self.request.get("avaliable"))

            book_mgt.update(bookEdit)

        self.redirect("/seeBooks")
예제 #2
0
    def get(self):
        user = users.get_current_user()
        id = int(self.request.get("id"))
        book = Book.get_by_id(id)

        if user and not reserve_mgt.retrieve(book.isbn):
            reserve = reserve_mgt.create_empty_reserve()
            reserve.email = users.get_current_user().email()

            number = book.avaliable - 1
            book.avaliable = number
            reserve.isbn = book.isbn

            book_mgt.update(book)
            reserve_mgt.update(reserve)

        self.redirect("/seeBooks")
예제 #3
0
    def get(self):
        user = users.get_current_user()

        if user:

            access_link = users.create_logout_url("/")
            id = int(self.request.get("id"))
            book = Book.get_by_id(id)

        template_values = {
            "book": book,
            "titleView": "Ver en detalle",
            "user": user.email(),
            "access_link": access_link
        }

        jinja = jinja2.get_jinja2(app=self.app)
        self.response.write(jinja.render_template("showBook.html", **template_values))
예제 #4
0
    def get(self):
        user = users.get_current_user()

        if user:
            access_link = users.create_logout_url("/")
            id = int(self.request.get("id"))

            book = Book.get_by_id(id)
            listTitle = {"isbn", "author", "avaliable", "type"}

            template_values = {
                "book": book,
                "listTitle": listTitle,
                "titleView": "Editar libro",
                "user": user.email(),
                "access_link": access_link
            }

            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(
                jinja.render_template("edit_book.html", **template_values))
예제 #5
0
 def post(self):
     id = int(self.request.get("idem"))
     bookDelete = Book.get_by_id(id)
     bookDelete.key.delete()
     self.redirect("/seeBooks")