Example #1
0
    def post(self):
        user = users.get_current_user()
        access_link = users.create_logout_url("/")

        id = int(self.request.get("id"))
        game = Games.get_by_id(id)

        template_values = {
            "user": user.nickname(),
            "access_link": access_link,
            "msg": "You can't delete a game added by other user."
        }

        if game and user.email() == game.user_email or user.email(
        ) == "*****@*****.**":
            coment = Coments.query(Coments.game_id == str(id))
            coment = list(coment)

            for comen in coment:
                comen.key.delete()

            game.key.delete()

            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(
                jinja.render_template("confirm.html", **template_values))

        else:

            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(
                jinja.render_template("error.html", **template_values))
Example #2
0
    def get(self):
        user = users.get_current_user()

        if user:
            access_link = users.create_logout_url("/")

            id = int(self.request.get("id"))
            game = Games.get_by_id(id)

            coment = Coments.query(Coments.game_id == str(id))
            coment = list(coment)

            template_values = {
                "user": user.nickname(),
                "access_link": access_link,
                "game": game,
                "coment": coment,
                "admin": "*****@*****.**"
            }

            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(jinja.render_template("view_games.html", **template_values))
        else:
            self.redirect("/")
            return
Example #3
0
    def post(self):
        user = users.get_current_user()
        access_link = users.create_logout_url("/")

        id = int(self.request.get("id"))
        game = Games.get_by_id(id)

        template_values = {
            "user": user.nickname(),
            "access_link": access_link,
            "msg": "You can't modify a game added by other user."
        }

        game.code = self.request.get("code")
        game.name = self.request.get("name")
        game.type = self.request.get("type")
        game.platform = self.request.get("platform")

        if game and user.email() == game.user_email or user.email() == "*****@*****.**":
            game_mgt.update(game)

            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(jinja.render_template("confirm.html", **template_values))

        else:
            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(jinja.render_template("error.html", **template_values))
Example #4
0
    def post(self):
        user = users.get_current_user()
        access_link = users.create_logout_url("/")

        id = int(self.request.get("id"))
        game = Games.get_by_id(id)

        try:
            estrellas = int(self.request.get("estrellas"))
        except:
            estrellas = 0

        coment = coment_mgt.create_empty_comentary()
        coment.comentary = self.request.get("txtarea")
        coment.user_email = user.email()
        coment.puntuacion = estrellas
        coment.game_id = str(id)

        template_values = {
            "user": user.nickname(),
            "access_link": access_link,
            "game": game,
            "coment": coment
        }

        if game:
            coment_mgt.update(coment)

            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(
                jinja.render_template("confirm.html", **template_values))
        else:
            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(
                jinja.render_template("error.html", **template_values))
Example #5
0
    def get(self):
        user = users.get_current_user()

        if user:
            access_link = users.create_logout_url("/")

            id = int(self.request.get("id"))
            game = Games.get_by_id(id)

            template_values = {
                "user": user.email(),
                "access_link": access_link,
                "game": game
            }

            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(jinja.render_template("edit_games.html", **template_values))
        else:
            self.redirect("/")
            return
Example #6
0
    def get(self):
        user = users.get_current_user()

        if user:
            access_link = users.create_logout_url("/")

            all_games = Games.query()
            all_games = list(all_games)

            template_values = {
                "user": user.nickname(),
                "access_link": access_link,
                "games": all_games
            }

            jinja = jinja2.get_jinja2(app=self.app)
            self.response.write(
                jinja.render_template("games.html", **template_values))
        else:
            self.redirect("/")
            return