Пример #1
0
def provider_list(request):
    nonhtml, tables = get(request, (["provider", Q()],))
    if nonhtml:
        return nonhtml
    context = {
        "provider": tables[0],
    }
    return as_html(request, "providerlist.html", context)
Пример #2
0
def view(request):
    term = request.GET.get("q")
    query = Q(ref_id__icontains=term)

    nonhtml, tables = get(request, [ ["case", query], ])
    if nonhtml: 
        return nonhtml

    return as_html(request, "searchview.html", { "search": tables[0], })
Пример #3
0
def district_view(request):
    district = request.GET.get("d")
    context = {
        "districts": Zone.objects.all(),
    }
    if district:
        nonhtml, tables = get(request, (["case", Q(zone=district)],))
        if nonhtml:
            return nonhtml
        context["cases"] = tables[0]

    return as_html(request, "districtview.html", context)
Пример #4
0
def provider_view(request, object_id):
    provider = get_object_or_404(Provider, id=object_id)
    nonhtml, tables = get(request, (
        ["case", Q(provider=provider)],
        ["message", Q(sent_by=provider.user)],
        ["event", Q(content_type="provider", object_id=provider.pk)]
        ))
    if nonhtml:
        return nonhtml
    context = {
        "object": provider,
        "cases": tables[0],
        "messages": tables[1],
        "event": tables[2]
    }
    return as_html(request, "providerview.html", context)
Пример #5
0
def child_list(request):
    q = Q()
    if not has_roles(request.user, "partner"):
        q = Q(provider__in=get_providers(request.user))

    nonhtml, tables = get(request, [
        ["case", q & Q(active=True)],
        ["reports", q],
        ["case", q & Q(active=False)]
    ])
    if nonhtml:
        return nonhtml

    context = {}
    context["active"] = tables[0]
    context["reports"] = tables[1]
    context["inactive"] = tables[2]

    return as_html(request, "child_list.html", context)
Пример #6
0
def setup(request):
    nonhtml, tables = get(request, [
        ["facilities", Q()],
        ["zones", Q(category=5)],
        ["zones", Q(category=4)],
        ["message", Q(form_error=False)],
        ["message", Q(form_error=True)],
    ])
    if nonhtml:
        return nonhtml

    context = {
        "facilities": tables[0],
        "regions": tables[1],
        "districts": tables[2],
        "message_pass": tables[3],
        "message_fail": tables[4]
    }

    return as_html(request, "setup.html", context)
Пример #7
0
def case_view(request, object_id):
    case = get_object_or_404(Case, id=object_id)
    nonhtml, tables = get(request, [
        ["malnutrition", Q(case=case)],
        ["diagnosis", Q(case=case)],
        ["malaria", Q(case=case)],
        ["event", Q(content_type="case", object_id=object_id)],
        ])

    if nonhtml:
        return nonhtml

    context = {
        "object": case,
        "malnutrition": tables[0],
        "diagnosis": tables[1],
        "malaria": tables[2],
        "event": tables[3],
    }
    return as_html(request, "caseview.html", context)
Пример #8
0
def dashboard(request):
    nonhtml, tables = get(request, [
        ["case", Q()],
        ["event", Q()],
        ["message", Q()],
    ])
    if nonhtml:
        return nonhtml

    has_provider = True
    context = {
        "case_table": tables[0],
        "event_table": tables[1],
        "message_table": tables[2]
    }    

    try:
        mobile = request.user.provider.mobile
        if request.method == "POST":
            messageform = MessageForm(request.POST)
            if messageform.is_valid():
                result = message_users(mobile, **messageform.cleaned_data)
                context["msg"] = result
        else:
            messageform = MessageForm()
    except ObjectDoesNotExist:
        has_provider = False
        messageform = None

    context.update({
            "message_form": messageform,
            "has_provider": has_provider,
            "summary": get_summary(),
            "graph": get_graph()
        })

    return as_html(request, "dashboard.html", context)