def download(request, **kwargs): my_auth = MyBasicAuthentication() is_login = my_auth.is_authenticated(request, **kwargs) if is_login: with_sg = 'no' config_permission = "no" sg_param = { 'account': is_login['i'], 'token': is_login['t'], 'operator': is_login['u'] } sg_res = BackendRequest.get_source_group(sg_param) if sg_res['result']: item = sg_res.get('items', []) if item: with_sg = 'yes' func_auth_res = BackendRequest.get_func_auth({'token': is_login['t']}) if func_auth_res['result']: if func_auth_res["results"]["parser_conf"]: config_permission = "yes" return render( request, 'download/download.html', { "active": "download", "subnav": "download", "user": is_login["u"], "email": is_login["e"], "cf_per": config_permission, "role": is_login["r"], "userid": is_login["i"], "with_sg": with_sg, "rgid": request.GET.get('rgid', "") }) else: return HttpResponseRedirect('/auth/login/')
def config(request, **kwargs): my_auth = MyBasicAuthentication() is_login = my_auth.is_authenticated(request, **kwargs) if is_login: res = BackendRequest.get_func_auth({ "token": is_login["t"], }) if res["results"]["enable_security"]: with_sg = check_with_sourcegroup(is_login) cf_per = check_with_permission(is_login) return render( request, 'security/config.html', { "active": "source", "subnav": "security", "user": is_login["u"], "email": is_login["e"], "token": is_login["t"], "userid": is_login["i"], "role": is_login["r"], "with_sg": with_sg, "cf_per": cf_per }) else: raise Http404 else: return HttpResponseRedirect('/auth/login/')
def visitor(request, **kwargs): my_auth = MyBasicAuthentication() is_login = my_auth.is_authenticated(request, **kwargs) if is_login: res = BackendRequest.get_func_auth({ "token": is_login["t"], }) # if res["results"]["enable_security"]: # with_sg = check_with_sourcegroup(is_login) # cf_per = check_with_permission(is_login) page_data = { "active": "applications", "subnav": "visitor", "user": is_login["u"], "email": is_login["e"], "token": is_login["t"], "userid": is_login["i"], "role": is_login["r"] } return render(request, 'application/apache/visitor.html', {"page_data": json.dumps(page_data)}) # else: # raise Http404 else: return HttpResponseRedirect('/auth/login/')
def check_with_permission(login): config_permission = "no" func_auth_res = BackendRequest.get_func_auth({'token': login['t']}) if func_auth_res['result']: if func_auth_res["results"]["parser_conf"]: config_permission = "yes" return config_permission
def lists(request, **kwargs): my_auth = MyBasicAuthentication() is_login = my_auth.is_authenticated(request, **kwargs) if is_login: visit_permit = BackendRequest.can_visit({ "token": is_login['t'], "operator": is_login['u'], "requestUrl": request.path[1:] }) if visit_permit['result'] and visit_permit['can_visit']: with_sg = 'no' config_permission = "no" sg_param = { 'account': is_login['i'], 'token': is_login['t'], 'operator': is_login['u'] } sg_res = BackendRequest.get_source_group(sg_param) if sg_res['result']: item = sg_res.get('items', []) if item: with_sg = 'yes' func_auth_res = BackendRequest.get_func_auth( {'token': is_login['t']}) if func_auth_res['result']: if func_auth_res["results"]["parser_conf"]: config_permission = "yes" page_data = { "active": "dictionary", "subnav": "dictionary", "user": is_login["u"], "email": is_login["e"], "cf_per": config_permission, "role": is_login["r"], "userid": is_login["i"], "with_sg": with_sg, "rgid": request.GET.get('rgid', "") } return render(request, 'dictionary/list.html', {"page_data": json.dumps(page_data)}) else: raise PermissionDenied else: return HttpResponseRedirect('/auth/login/')