Exemplo n.º 1
0
    def post(self):
        email = self.request.get("edEmail", "")
        name = self.request.get("edName", "")
        address = self.request.get("edAddress", "")
        phone = self.request.get("edPhone", "")
        operation = self.request.get("edOp", "")

        if email and operation:
            if operation == "add":
                user = User()
                user.email = email
                user.name = name
                user.address = address
                user.phone = phone
                user.put()
                time.sleep(1)
            elif operation == "delete":
                user = User.query(User.email == email)
                if user:
                    user = user.get()
                    user.key.delete()
                    time.sleep(1)
                else:
                    self.redirect("/error?msg=user was not found")
            self.redirect("/admin")
        else:
            self.redirect("/error?msg=email and operation needed")

        return
Exemplo n.º 2
0
    def get(self):
        users = User.query()

        template_values = {
            "users": users,
            "info": AppInfo,
        }

        jinja = jinja2.get_jinja2(app=self.app)
        self.response.write(jinja.render_template("admin.html", **template_values))
Exemplo n.º 3
0
    def get(self):
        try:
            session_id = self.request.GET['session_id']
        except:
            self.redirect("/error?msg=missing session id")
            return

        try:
            client_id = self.request.GET['client_id']
        except:
            self.redirect("/error?msg=missing client id")
            return

        user = users.get_current_user()

        if user:
            if User.chk_allowed(user.email()):
                try:
                    session = ndb.Key(urlsafe=session_id).get()
                except:
                    self.redirect(
                        "/error?msg=key does not exist for session creating report"
                    )
                    return

                try:
                    user_info = User.query(User.email == user.email()).get()
                except:
                    self.redirect("/error?msg=user info was not found")
                    return

                try:
                    client = ndb.Key(urlsafe=client_id).get()
                except:
                    self.redirect(
                        "/error?msg=key does not exist for client creating report for session"
                    )
                    return

                template_values = {
                    "user_info": user_info,
                    "info": AppInfo,
                    "client": client,
                    "session": session,
                }

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