예제 #1
0
def done_with_case_form(request, queue_pk, case_pk, has_review_date):
    queue = None
    queues, _ = get_user_case_queues(request, case_pk)

    if not queues:
        queue = get_queue(request, queue_pk)

    return Form(
        title=DoneWithCaseOnQueueForm.TITLE if not queue else
        DoneWithCaseOnQueueForm.TITLE_SINGULAR.format(queue["name"]),
        questions=[
            conditional(
                queues,
                Checkboxes(
                    name="queues[]",
                    options=[
                        Option(queue["id"], queue["name"]) for queue in queues
                    ],
                    title=DoneWithCaseOnQueueForm.CHECKBOX_TITLE,
                    description=DoneWithCaseOnQueueForm.CHECKBOX_DESCRIPTION,
                ),
                HiddenField(name="queues[]", value=queue_pk),
            ),
            DetailComponent(
                title=DoneWithCaseOnQueueForm.NOTE,
                components=[
                    TextArea(name="note", classes=["govuk-!-margin-0"]),
                ],
            ),
        ],
        default_button_name=DoneWithCaseOnQueueForm.SUBMIT,
        container="case",
        javascript_imports=conditional(has_review_date,
                                       {"/javascripts/assign_queue.js"}, None),
    )
예제 #2
0
    def init(self, request, **kwargs):
        self.object_pk = kwargs["pk"]
        case_ids = request.GET.getlist("cases")

        if not case_ids:
            return error_page(request, "Invalid case selection")

        queue = get_queue(request, self.object_pk)
        case_assignments, _ = get_queue_case_assignments(
            request, self.object_pk)
        assigned_users = [
            assignment["user"]
            for assignment in case_assignments["case_assignments"]
            if assignment["case"] in case_ids
        ]
        user_data, _ = get_gov_user(request,
                                    str(request.session["lite_api_user_id"]))

        self.data = {"users": assigned_users}
        self.form = assign_users_form(request, user_data["user"]["team"]["id"],
                                      queue,
                                      len(case_ids) > 1)
        self.action = put_queue_case_assignments
        self.success_url = reverse("queues:cases",
                                   kwargs={"queue_pk": self.object_pk})
        self.success_message = (Manage.AssignUsers.SUCCESS_MULTI_MESSAGE
                                if len(case_ids) > 1 else
                                Manage.AssignUsers.SUCCESS_MESSAGE)
예제 #3
0
def current_queue(request):
    kwargs = getattr(request.resolver_match, "kwargs", {})
    if "queue_pk" in kwargs and "disable_queue_lookup" not in kwargs:
        queue_pk = request.resolver_match.kwargs["queue_pk"]
        queue = get_queue(request, queue_pk)
        return {"queue": queue}

    return {}
예제 #4
0
 def init(self, request, **kwargs):
     self.object_pk = str(kwargs["pk"])
     case = get_case(request, self.object_pk)
     self.case_type = case.type
     self.case_sub_type = case.sub_type
     permissible_statuses = get_permissible_statuses(request, case)
     self.data = case.data
     self.form = change_status_form(get_queue(request, kwargs["queue_pk"]), case, permissible_statuses)
     self.context = {"case": case}
예제 #5
0
    def get(self, request, **kwargs):
        self.case_id = str(kwargs["pk"])
        self.case = get_case(request, self.case_id)
        self.queue_id = kwargs["queue_pk"]
        self.queue = get_queue(request, self.queue_id)

        self.permissions = get_user_permissions(self.request)

        if hasattr(self, "get_" + self.case.sub_type + "_" + self.case.type):
            getattr(self, "get_" + self.case.sub_type + "_" + self.case.type)()
예제 #6
0
 def init(self, request, **kwargs):
     self.object_pk = kwargs["pk"]
     case = get_case(request, self.object_pk)
     self.data = case
     self.form = move_case_form(request, get_queue(request, kwargs["queue_pk"]), case)
     self.action = put_case_queues
     self.context = {"case": case}
     self.success_message = cases.Manage.MoveCase.SUCCESS_MESSAGE
     self.success_url = reverse_lazy(
         "cases:case", kwargs={"queue_pk": self.kwargs["queue_pk"], "pk": self.object_pk}
     )
예제 #7
0
 def queue(self):
     return get_queue(self.request, self.queue_pk)
예제 #8
0
 def init(self, request, **kwargs):
     self.object_pk = kwargs["pk"]
     self.data = get_queue(request, self.object_pk)
     self.form = forms.edit_queue_form(request, self.object_pk)
     self.action = put_queue
     self.success_url = reverse_lazy("queues:manage")