Exemple #1
0
def case_list_view(request):
    """
    List of all cases for paralegals and coordinators to view.
    """
    issue_qs = _get_issue_qs_for_user(request.user)
    form = IssueSearchForm(request.GET)
    issue_qs = form.search(issue_qs).order_by("-created_at").all()
    page, next_page, prev_page = get_page(request,
                                          issue_qs,
                                          per_page=14,
                                          return_qs=False)
    context = {
        "issues": IssueDetailSerializer(page.object_list, many=True).data,
        "next_page": next_page,
        "total_pages": page.paginator.num_pages,
        "total_count": page.paginator.count,
        "prev_page": prev_page,
        "choices": {
            "stage": CaseStage.CHOICES,
            "topic": CaseTopic.CHOICES,
            "outcome": CaseOutcome.CHOICES,
            "is_open": [
                ("True", "Open"),
                ("False", "Closed"),
            ],
        },
    }
    if is_react_api_call(request):
        return Response(context)
    else:
        return render_react_page(request, f"Cases", "case-list", context)
Exemple #2
0
def case_detail_assign_view(request, pk):
    """
    Form where coordinators can assign a paralegal to a case
    """
    issue = _get_issue(request, pk)
    serializer = IssueAssignmentSerializer(data=request.data, instance=issue)
    serializer.is_valid(raise_exception=True)
    serializer.save()
    return Response({"issue": IssueDetailSerializer(issue).data})
Exemple #3
0
def case_detail_update_view(request, pk):
    """
    Form where you update the case status.
    """
    issue = _get_issue(request, pk)
    serializer = IssueDetailSerializer(data=request.data,
                                       instance=issue,
                                       partial=True)
    serializer.is_valid(raise_exception=True)
    serializer.save()
    return Response({"issue": IssueDetailSerializer(issue).data})
Exemple #4
0
def email_list_view(request, pk):
    issue = _get_issue_for_emails(request, pk)
    case_email_address = build_clerk_address(issue)
    email_threads = _get_email_threads(issue)
    context = {
        "issue": IssueDetailSerializer(issue).data,
        "email_threads": EmailThreadSerializer(email_threads, many=True).data,
        "case_email_address": case_email_address,
        "urls": get_detail_urls(issue),
        "draft_url": reverse("case-email-draft", args=(issue.pk, )),
    }
    return render_react_page(request, f"Case {issue.fileref}", "email-list",
                             context)
Exemple #5
0
def case_detail_documents_view(request, pk):
    """
    The documents of a given case.
    """
    try:
        issue = (Issue.objects.check_permissions(request).select_related(
            "client").get(pk=pk))
    except Issue.DoesNotExist:
        raise Http404()

    context = {
        "issue": IssueDetailSerializer(issue).data,
        "urls": get_detail_urls(issue),
    }
    return render_react_page(request, f"Case {issue.fileref}", "document-list",
                             context)
Exemple #6
0
def case_detail_note_view(request, pk):
    """
    Form where paralegals can leave notes about case progress.
    """
    issue = _get_issue(request, pk)
    data = {
        "issue": issue.id,
        "creator": request.user.id,
        **request.data,
    }
    serializer = IssueNoteCreateSerializer(data=data)
    serializer.is_valid(raise_exception=True)
    serializer.save()
    notes = _get_issue_notes(request, pk)
    return Response({
        "issue": IssueDetailSerializer(issue).data,
        "notes": IssueNoteSerializer(notes, many=True).data,
    })
Exemple #7
0
def email_thread_view(request, pk, slug):
    issue = _get_issue_for_emails(request, pk)
    case_email_address = build_clerk_address(issue)
    email_threads = [t for t in _get_email_threads(issue) if t.slug == slug]
    if email_threads:
        # Assume thread slugs are unique.
        email_thread = email_threads[0]
    else:
        raise Http404()
    context = {
        "issue": IssueDetailSerializer(issue).data,
        "subject": email_thread.subject,
        "emails": EmailSerializer(email_thread.emails, many=True).data,
        "case_email_address": case_email_address,
        "case_email_list_url": reverse("case-email-list", args=(issue.pk, )),
    }
    return render_react_page(request, f"Case {issue.fileref}", "email-thread",
                             context)
Exemple #8
0
def case_detail_view(request, pk):
    """
    The details of a given case.
    """
    issue = _get_issue(request, pk)
    tenancy = _get_tenancy(issue)
    notes = _get_issue_notes(request, pk)
    context = {
        "issue": IssueDetailSerializer(issue).data,
        "tenancy": TenancySerializer(tenancy).data,
        "notes": IssueNoteSerializer(notes, many=True).data,
        "details": _get_submitted_details(issue),
        "actionstep_url": _get_actionstep_url(issue),
        "urls": get_detail_urls(issue),
        "permissions": {
            "is_paralegal_or_better": request.user.is_paralegal_or_better,
            "is_coordinator_or_better": request.user.is_coordinator_or_better,
        },
    }
    return render_react_page(request, f"Case {issue.fileref}", "case-detail",
                             context)