def update_name(request,permissionid): result=True try: PermissionService.update_permission_name(request, permissionid) except Exception as ex: SimpleLogger.exception(ex) result=str(ex) return HttpResponse(result)
def permission_delete(request): result=True try: PermissionService.delete_permission(request) except Exception as ex: print(ex) SimpleLogger.exception(ex) result=str(ex) return HttpResponse(result)
def get_role_permission_edit_webpart(self,roleid): role=SystemRoleService.get_role(roleid) temp_role=VM_SystemRole(role) all_custom_permissions=PermissionService.all_custom_permissions() permission_list_webpart=self.get_role_permission_controll(all_custom_permissions,roleid) pagefileds={"role":temp_role,'permission_list_webpart':permission_list_webpart} return self.get_webpart(pagefileds,AdminSystemRolePath.admin_system_role_edit_page)
def get_permission_sub_navbar(self, request, sub_nav_action): permissions_count = len(PermissionService.all_custom_permissions()) return self.get_sub_nav_bar( request, self.subpage_model, AdminPermissionPath.admin_permission_subnav, sub_nav_action=sub_nav_action, permissions_count=permissions_count)
def is_permission_active(self): result = "" if self.role_id: role = SystemRoleService.get_role(self.role_id) permission = PermissionService.get_permission(self.id) if permission in role.permissions.all(): result = "active" return result
def get_permission_list_webpart(self): permissions = PermissionService.all_custom_permissions() permission_list_controll = self.get_permission_list_controll( permissions) pagefileds = { "permission_list_controll": permission_list_controll, "permissions": permissions } return self.get_webpart( pagefileds, AdminPermissionPath.admin_permission_list_webpart)
def update_role_permission(request, roleid): role = SystemRoleService.get_role(roleid) permission_id = request.POST.get("permission_id") active = request.POST.get("active") temp_permission = PermissionService.get_permission(permission_id) if active == "1": role.permissions.add(temp_permission) if active == "0": role.permissions.remove(temp_permission) role.save()
def role_permission_list(request, roleid): all_custom_permissions = PermissionService.all_custom_permissions() page_worker = AdminSystemRolePageWorker(request) result = page_worker.get_role_permission_controll(all_custom_permissions, roleid) return HttpResponse(result)
def permission_list(request): page_worker=AdminPermissionPageWorker(request) permission_list=page_worker.get_permission_list_controll(PermissionService.all_permissions()) return HttpResponse(permission_list)
def check_value_exists(request): result=False filed_name=request.POST.get("filed","") if filed_name=="codename": result=PermissionService.check_codename_exists(request) return HttpResponse(result)