Exemple #1
0
 def xhr_update(self):
     sch = pysite.dd.build_schema(colander.MappingSchema, self.DD, fieldlist=self.EDIT_FIELDLIST)
     try:
         data = pysite.dd.deserialize(sch, self.request.POST)
     except colander.Invalid as exc:
         return {"status": False, "msg": "Errors", "errors": exc.asdict()}
     try:
         vv = {}
         for k, v in data.items():
             # If client did not set a new password, keep the current one.
             if k == "pwd" and (v is None or v == ""):
                 continue
             vv[k[self.PREFIXLEN :]] = v
         vv["id"] = int(self.request.POST["id"])
         vv["editor"] = self.request.user.uid
         vv["mtime"] = datetime.datetime.now()
         manager.update_role(vv)
         return {"status": True, "msg": "Ok"}
     except (StatementError, NoResultFound, PySiteError) as exc:
         return {"status": False, "msg": str(exc), "errors": {}}
Exemple #2
0
 def update_role(self):
     data = self._parse(self._args.data)
     data['editor'] = pysite.authmgr.const.ROOT_UID
     data['mtime'] = datetime.datetime.now()
     rs = usrmanager.update_role(data)
     self._print(self._db_data_to_list([rs])[0])