def parsePost(self):
    session = sessionmanager.getsession(self)

    if session:
        roles = session["roles"]

        if not "administrator" in roles:
            self.response.out.write("You are not an administrator for this site. Access denied.")
            return

        action = self.request.get("action", None)
        uid = self.request.get("uid", None)

        if action == "selectUid":
            objreturn = {}
            objreturn["indexes"] = []

            q = db.GqlQuery("SELECT * FROM Index WHERE uid = :1", uid)
            for index in q:
                if not index.name in objreturn["indexes"]:
                    objreturn["indexes"].append(index.name)

            self.response.out.write(json.dumps(objreturn))

        elif action == "computeIndex":
            indexname = self.request.get("indexname", None)
            libSNA = computeprofileindex.getLibSNA(self, session)
            objreturn = computeprofileindex.computeIndex(self, libSNA, indexname, False, session)

            renderPage(self, "admin")
        else:
            renderPage(self, "admin")
def parsePost(self):
    session = sessionmanager.getsession(self)

    if session:
        roles = session['roles']

        if not 'administrator' in roles:
            self.response.out.write(
                "You are not an administrator for this site. Access denied.")
            return

        action = self.request.get('action', None)
        uid = self.request.get('uid', None)

        if action == "selectUid":
            objreturn = {}
            objreturn['indexes'] = []

            q = db.GqlQuery("SELECT * FROM Index WHERE uid = :1", uid)
            for index in q:
                if not index.name in objreturn['indexes']:
                    objreturn['indexes'].append(index.name)

            self.response.out.write(json.dumps(objreturn))

        elif action == "computeIndex":
            indexname = self.request.get('indexname', None)
            libSNA = computeprofileindex.getLibSNA(self, session)
            objreturn = computeprofileindex.computeIndex(
                self, libSNA, indexname, False, session)

            renderPage(self, 'admin')
        else:
            renderPage(self, 'admin')
    def post(self):
        session = sessionmanager.getsession(self)

        if session:
            roles = session["roles"]

            if not "technician" in roles:
                self.response.out.write("You are not a technician for this site. Access denied.")
                return

            action = self.request.get("action", None)
            code = self.request.get("code", None)
            uid = self.request.get("uid", None)

            if action == "selectUid":
                objreturn = {}
                objreturn["indexes"] = []

                q = db.GqlQuery("SELECT * FROM Index WHERE uid = :1", uid)
                for index in q:
                    if not index.name in objreturn["indexes"]:
                        objreturn["indexes"].append(index.name)

                self.response.out.write(json.dumps(objreturn))
            elif action == "computeIndex":
                indexname = self.request.get("indexname", None)
                libSNA = computeprofileindex.getLibSNA(self, session)
                objreturn = computeprofileindex.computeIndex(
                    self, libSNA, indexname, False, session, saveInDatastore=False
                )

                if "nodes" in objreturn:
                    objreturn["nodes"] = str(objreturn["nodes"])
                if "edges" in objreturn:
                    objreturn["edges"] = str(objreturn["edges"])
                self.response.out.write(json.dumps(objreturn))
            elif action == "saveIndex":
                indexname = self.request.get("indexname", None)
                networkhash = self.request.get("networkhash", None)
                value = self.request.get("value", None)
                edges = self.request.get("edges", None)
                nodes = self.request.get("nodes", None)

                index = obj_index.Index(uid=self.request.get("uid", None), name=indexname)
                index.updated_time = datetime.datetime.now()
                index.networkhash = networkhash

                index.value = float(value)
                if not edges == None:
                    index.set_edgevalues(edges)
                if not nodes == None:
                    index.set_nodevalues(nodes)
                index.put()

                logging.info("Updated index data for user: "******"/tech/viewindex?uid=" + uid + "&code=" + code)
            else:
                self.redirect("/tech/viewindex?uid=" + uid + "&code=" + code)
    def post(self):
        session = sessionmanager.getsession(self)

        if session:
            roles = session['roles']

            if not 'technician' in roles:
                self.response.out.write(
                    "You are not a technician for this site. Access denied.")
                return

            action = self.request.get('action', None)
            code = self.request.get('code', None)
            uid = self.request.get('uid', None)

            if action == "selectUid":
                objreturn = {}
                objreturn['indexes'] = []

                q = db.GqlQuery("SELECT * FROM Index WHERE uid = :1", uid)
                for index in q:
                    if not index.name in objreturn['indexes']:
                        objreturn['indexes'].append(index.name)

                self.response.out.write(json.dumps(objreturn))
            elif action == "computeIndex":
                indexname = self.request.get('indexname', None)
                libSNA = computeprofileindex.getLibSNA(self, session)
                objreturn = computeprofileindex.computeIndex(
                    self,
                    libSNA,
                    indexname,
                    False,
                    session,
                    saveInDatastore=False)

                if 'nodes' in objreturn:
                    objreturn['nodes'] = str(objreturn['nodes'])
                if 'edges' in objreturn:
                    objreturn['edges'] = str(objreturn['edges'])
                self.response.out.write(json.dumps(objreturn))
            elif action == "saveIndex":
                indexname = self.request.get('indexname', None)
                networkhash = self.request.get('networkhash', None)
                value = self.request.get('value', None)
                edges = self.request.get('edges', None)
                nodes = self.request.get('nodes', None)

                index = obj_index.Index(uid=self.request.get('uid', None),
                                        name=indexname)
                index.updated_time = datetime.datetime.now()
                index.networkhash = networkhash

                index.value = float(value)
                if not edges == None: index.set_edgevalues(edges)
                if not nodes == None: index.set_nodevalues(nodes)
                index.put()

                logging.info("Updated index data for user: " + uid)
                self.redirect('/tech/viewindex?uid=' + uid + '&code=' + code)
            else:
                self.redirect('/tech/viewindex?uid=' + uid + '&code=' + code)