def SubmitForm(request): try: IsOk = '1' try: key = request.GET['key'] except: key = None response = HttpResponse() curUser = CommonUtils.Current(response, request) if not key: role = Pirole() role = role.loadJson(request) role.id = uuid.uuid4() # user.isstaff = 0 # user.isvisible = 1 # user.isdimission = 0 role.deletemark = 0 role.allowdelete = 1 role.allowedit = 1 role.createon = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') role.createby = curUser.RealName role.modifiedon = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') role.modifiedby = curUser.RealName role.enabled = 1 returnCode, returnMessage, returnValue = RoleService.Add(curUser, role) if returnCode == StatusCode.statusCodeDic['OKAdd']: response.content = json.dumps({'Success':True, 'Data':IsOk, 'Message':returnMessage}) return response else: response.content = json.dumps({'Success': False, 'Data': '0', 'Message': returnMessage}) return response else: role = RoleService.GetEntity(curUser, key) if role: role = role.loadJson(request) if curUser: role.modifiedby = curUser.RealName role.modifieduserid = curUser.Id returnCode, returnMessage = RoleService.Update(curUser, role) if returnCode == StatusCode.statusCodeDic['OKUpdate']: response.content = json.dumps({'Success': True, 'Data': IsOk, 'Message': returnMessage}) return response else: response.content = json.dumps({'Success': False, 'Data': '0', 'Message': returnMessage}) return response except Exception as e: print(e) response = HttpResponse() response.content = json.dumps({'Success': False, 'Data': '0', 'Message': FrameworkMessage.MSG3020}) return response
def GetEntity(request): try: key = request.POST['key'] except: key = None entity = RoleService.GetEntity(CommonUtils.Current(HttpResponse(), request), key) response = HttpResponse() response.content = entity.toJSON() return response