def post(self, request): form = AuthenticationForm(data=request.POST) if not form.is_valid(): return self.response(request, form) user = form.get_user() auth_login(request, user) # Retrieve user to use some methods of UserProxy user = UserProxy.objects.get(pk=user.pk) if user.is_superuser or user.is_system_user or user.is_audit_user or user.is_safety_user: return redirect('management') udc_set = UDC.objects.filter(user=user) if udc_set.exists(): request.session["UDC_ID"] = udc_set[0].id elif user.is_approver: request.session["UDC_ID"] = -1 else: return redirect('no_udc') Notification.pull_announcements(user) return HttpResponseRedirect(reverse("cloud"))
def post(self, request): form = AuthenticationForm(data=request.POST) if not form.is_valid(): return self.response(request, form) user = form.get_user() auth_login(request, user) # Retrieve user to use some methods of UserProxy user = UserProxy.objects.get(pk=user.pk) if user.is_superuser or user.is_system_user or user.is_audit_user or user.is_safety_user: return redirect('management') udc_set = UDC.objects.filter(user=user) if udc_set.exists(): request.session["UDC_ID"] = udc_set[0].id elif user.is_approver: request.session["UDC_ID"] = -1 else: return redirect('no_udc') Notification.pull_announcements(user) return HttpResponseRedirect(reverse("cld"))
def feed_status(request): Notification.pull_announcements(request.user) num = Feed.living.filter(receiver=request.user, is_read=False).count() return Response({"num": num})
def feed_status(request): Notification.pull_announcements(request.user) num = Feed.living.filter(receiver=request.user, is_read=False).count() return Response({"num": num})
def post(self, request): form = AuthenticationForm(data=request.POST) login_type = request.POST.get('type') or None if not form.is_valid(): return self.response(request, form) user = form.get_user() auth_login(request, user) # Retrieve user to use some methods of UserProxy user = UserProxy.objects.get(pk=user.pk) role = "" if not user.is_superuser: udc_id = 0 udc_set = UDC.objects.filter(user=user) if udc_set.exists(): request.session["UDC_ID"] = udc_set[0].id udc_id = udc_set[0].id elif user.is_approver: request.session["UDC_ID"] = -1 else: return redirect('no_udc') role = user_role_member(request, udc_id) if user.is_superuser or role: #add session["UDC_ID"] for surperuser if UDC.objects.filter(user=user).exists(): udc_set = UDC.objects.filter(user=user) request.session["UDC_ID"] = udc_set[0].id try: Operation.objects.create(user=user, udc=udc_set[0], resource="登录", resource_id=1, resource_name="登录", action="login", result=0) except Exception as e: pass return redirect('management') elif login_type == "vdi_client": return HttpResponseRedirect(reverse("cloud")) else: try: Operation.objects.create(user=user, udc='-1', resource="普通用户登录web", resource_id=1, resource_name="登录", action="login", result=0) except Exception as e: pass auth_logout(request) return HttpResponseForbidden() udc_set = UDC.objects.filter(user=user) if udc_set.exists(): request.session["UDC_ID"] = udc_set[0].id elif user.is_approver: request.session["UDC_ID"] = -1 else: return redirect('no_udc') Notification.pull_announcements(user) return HttpResponseRedirect(reverse("cloud"))