Exemplo n.º 1
0
def supp_get_img(request, supplement_id):
    supplement = get_object_or_404(Supplement, pk=supplement_id)
    if supplement.applicant_id != request.applicant.id:
        return HttpResponseNotFound()
    
    filename = supplement.preview_path()
    if not os.path.exists(filename):
        supplement.create_preview()

    if os.path.exists(filename):
        return serve_file(filename)
    else:
        return HttpResponseNotFound()
Exemplo n.º 2
0
def doc_get_img(request, field_name, thumbnail=True):
    if not AppDocs.valid_field_name(field_name):
        return HttpResponseNotFound('Invalid field')

    docs = request.applicant.get_applicant_docs_or_none()
    if docs!=None:
        if thumbnail:
            filename = docs.thumbnail_path(field_name)
        else:
            filename = docs.preview_path(field_name)
        if os.path.exists(filename):
            return serve_file(filename)
        else:
            return HttpResponseNotFound()
    else:
        return HttpResponseNotFound()
Exemplo n.º 3
0
Arquivo: views.py Projeto: jittat/adm2
def supplement_img_view(request, filename):
    fname, ext = os.path.splitext(filename)

    try:
        supplement_id = int(fname)
    except:
        return HttpResponseForbidden()

    supplement = get_object_or_404(Supplement, pk=supplement_id)

    try:
        full_path = supplement.image.path
        
        if os.path.exists(full_path):
            return serve_file(full_path)
        else:
            return HttpResponseNotFound()
    except ValueError:
        return HttpResponseNotFound()
Exemplo n.º 4
0
Arquivo: views.py Projeto: jittat/adm2
def doc_img_view(request, applicant_id, filename):
    applicant = get_object_or_404(Applicant, pk=applicant_id)
    docs = applicant.get_applicant_docs_or_none()

    if docs!=None:
        field_name, ext = os.path.splitext(filename)

        if not AppDocs.valid_field_name(field_name):
            return HttpResponseNotFound()

        try:
            full_path = docs.__getattribute__(field_name).path

            if os.path.exists(full_path):
                return serve_file(full_path)
            else:
                return HttpResponseNotFound()
        except ValueError:
            return HttpResponseNotFound()
    else:
        return HttpResponseNotFound()