Ejemplo n.º 1
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("/")
Ejemplo n.º 2
0
    def get(self):
        user = users.get_current_user()

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

        if user:
            if User.chk_allowed(user.email()):
                user_name = user.nickname()
                access_link = users.create_logout_url("/")

                try:
                    client = ndb.Key(urlsafe=client_id).get()
                except:
                    self.redirect(
                        "/error?msg=client key was not found for sessions management"
                    )
                    return

                sessions = Session.query(
                    Session.dni == client.dni).order(-Session.added)

                template_values = {
                    "user_name": user_name,
                    "access_link": access_link,
                    "client": client,
                    "sessions": sessions,
                    "info": AppInfo,
                }

                jinja = jinja2.get_jinja2(app=self.app)
                self.response.write(
                    jinja.render_template("sessionsManagement.html",
                                          **template_values))
            else:
                self.redirect("/nouser")
        else:
            self.redirect("/")
Ejemplo n.º 3
0
    def get(self):
        user = users.get_current_user()

        if user:
            if User.chk_allowed(user.email()):
                user_name = user.nickname()
                access_link = users.create_logout_url("/")
                clients = Client.query().order(Client.surname)

                template_values = {
                    "info": AppInfo,
                    "user_name": user_name,
                    "access_link": access_link,
                    "clients": clients,
                }

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