示例#1
0
 def init(self, request, **kwargs):
     self.object_pk = kwargs["pk"]
     self.data = get_user(request, self.object_pk)["user"]
     self.form = assign_sites(request)
     self.action = put_assign_sites
     self.success_url = reverse_lazy("organisation:members:user",
                                     kwargs={"pk": self.object_pk})
示例#2
0
    def get(self, request, **kwargs):
        if not request.authbroker_client.authorized:
            return render(request, "core/start.html")
        try:
            user = get_user(request)
            user_permissions = user["role"]["permissions"]
        except (JSONDecodeError, TypeError, KeyError):
            return redirect("auth:login")

        organisation = get_organisation(request,
                                        str(request.session["organisation"]))
        notifications, _ = get_notifications(request)
        existing = has_existing_applications_and_licences_and_nlrs(request)

        context = {
            "organisation":
            organisation,
            "user_data":
            user,
            "notifications":
            notifications,
            "existing":
            existing,
            "user_permissions":
            user_permissions,
            "FEATURE_FLAG_ONLY_ALLOW_SIEL":
            settings.FEATURE_FLAG_ONLY_ALLOW_SIEL,
            "FEATURE_FLAG_ALLOW_CLC_QUERY_AND_PV_GRADING":
            settings.FEATURE_FLAG_ALLOW_CLC_QUERY_AND_PV_GRADING,
        }

        return render(request, "core/hub.html", context)
示例#3
0
    def get(self, request, *args, **kwargs):
        organisation = get_user(request, params={"in_review":
                                                 True})["organisations"][0]
        organisation_name = organisation["name"]
        organisation_status = organisation["status"]["key"]

        if organisation_status != "in_review":
            raise Http404

        return success_page(
            request=request,
            title=f"You've successfully registered: {organisation_name}",
            secondary_title="We're currently processing your application.",
            description="",
            what_happens_next=[
                "Export Control Joint Unit (ECJU) is processing your request for an export control account. "
                "We'll send you an email when we've made a final decision."
            ],
            links={},
            back_link=conditional(
                request.GET.get("show_back_link", False),
                BackLink(generic.BACK,
                         reverse_lazy("core:pick_organisation"))),
            animated=True,
            additional_context={"user_in_limbo": True},
        )
示例#4
0
    def get_additional_context(self):
        user = get_user(self.request)
        user_role_id = user["role"]["id"]
        roles = get_roles(self.request, self.organisation_id, page=self.request.GET.get("page", 1))
        all_permissions = get_permissions(self.request)

        return {
            "roles": roles,
            "user_role_id": user_role_id,
            "immutable_roles": [SUPER_USER_ROLE_ID, DEFAULT_USER_ROLE_ID],
            "all_permissions": all_permissions,
        }
示例#5
0
 def get_success_url(self):
     user = get_user(self.request)
     if not user["organisations"]:
         return reverse("core:register_an_organisation_triage")
     elif len(user["organisations"]) == 1:
         organisation = user["organisations"][0]
         if organisation["status"]["key"] != "in_review":
             self.request.session["organisation"] = user["organisations"][0]["id"]
         else:
             return reverse("core:register_an_organisation_confirm")
     elif len(user["organisations"]) > 1:
         return reverse("core:pick_organisation")
     return settings.LOGIN_REDIRECT_URL
示例#6
0
 def init(self, request, **kwargs):
     self.forms = register_triage()
     self.action = validate_register_organisation_triage
     self.additional_context = {"user_in_limbo": True}
     if not request.authbroker_client.authorized:
         raise Http404
     else:
         profile = get_profile(request.authbroker_client)
         request.session["email"] = profile["email"]
         request.session["first_name"] = profile.get("user_profile", {}).get("first_name")
         request.session["last_name"] = profile.get("user_profile", {}).get("last_name")
     if "user_token" in request.session and get_user(request)["organisations"]:
         raise Http404
示例#7
0
    def init(self, request, **kwargs):
        _type = self.kwargs["type"]
        location = self.kwargs["location"]

        self.forms = (register_a_commercial_organisation_group(
            request, location) if _type == "commercial" else
                      register_an_individual_group(request, location))
        self.action = register_commercial_organisation if _type == "commercial" else register_private_individual
        self.hide_components = ["site.address.address_line_2"]
        self.additional_context = {"user_in_limbo": True}

        if not request.authbroker_client.authorized:
            raise Http404
        if "user_token" in request.session and get_user(
                request)["organisations"]:
            raise Http404
示例#8
0
    def get(self, request, **kwargs):
        request_user = get_organisation_user(
            request, str(request.session["organisation"]), str(kwargs["pk"]))
        user = get_user(request)

        is_request_user_super_user = is_super_user(request_user)
        is_user_super_user = is_super_user(user)
        is_self_editing = user["id"] == request_user["id"]

        show_change_status = not is_self_editing and is_user_super_user and not is_request_user_super_user
        show_change_role = not is_self_editing and is_user_super_user
        show_assign_sites = not is_self_editing and not is_request_user_super_user

        context = {
            "signed_in_user": user,
            "profile": request_user,
            "show_change_status": show_change_status,
            "show_change_role": show_change_role,
            "show_assign_sites": show_assign_sites,
        }
        return render(request, "organisation/members/profile.html", context)
示例#9
0
    def dispatch(self, request, *args, **kwargs):
        user = get_user(request)
        self.organisations = user["organisations"]
        self.form = select_your_organisation_form(self.organisations)

        return super(PickOrganisation, self).dispatch(request, *args, **kwargs)
示例#10
0
def get_user_permissions(request):
    user = get_user(request)
    return user["role"]["permissions"]