Esempio n. 1
0
def get_application(id, request):
    application = get_request(request,
                              "applications",
                              url_extension=str(id) + "/",
                              data_only=True)
    application["goods"] = get_goods_names(application["goods"], request)
    return application
Esempio n. 2
0
def get_admin_application(id, request):
    application = get_request(request,
                              "admin",
                              url_extension=str(id) + "/",
                              data_only=True)
    application["goods"] = get_admin_goods(request, application)
    return application
Esempio n. 3
0
def get_admin_goods(request, application):
    ids = application["goods"]
    goods = get_request(request, "admin_goods", data_only=True)
    final = list()
    for i in range(0, len(goods)):
        if goods[i]["id"] in ids:
            final.append(goods[i])
    return final
Esempio n. 4
0
def reject(request, application_id):
    r = get_request(request,
                    "decline",
                    url_extension=str(application_id) + "/")
    if r.status_code == 400:
        request.session['error'] = "Error occurred when rejecting application"
    else:
        request.session['message'] = "Successfully rejected an application"
    return HttpResponseRedirect('/admin/')
Esempio n. 5
0
def get_applications(request):
    applications = get_request(request, "applications", data_only=True)
    return add_progress_to_applications(applications)
Esempio n. 6
0
def submit_application(request, application_id):
    r = get_request(request, "submit", url_extension=str(application_id) + "/")
    request.session['message'] = "Error occurred submitting an application" if r.status_code == 400 \
        else "Successfully submitted an application"
    return HttpResponseRedirect('/applications/')
Esempio n. 7
0
def get_goods(request):
    return get_request(request, "goods", data_only=True)
Esempio n. 8
0
def get_good(id, request):
    return get_request(request,
                       "goods",
                       data_only=True,
                       url_extension=str(id) + "/")