Exemplo n.º 1
0
def _handle_save_document(request, document, form=None):
    if AUTOMATIC_OCR:
        document_queue = add_document_to_queue(document)
        messages.success(request, _(u'Document: %(document)s was added to the OCR queue: %(queue)s.') % {
            'document':document, 'queue':document_queue.label})
    
    if form and 'document_type_available_filenames' in form.cleaned_data:
        if form.cleaned_data['document_type_available_filenames']:
            document.file_filename = form.cleaned_data['document_type_available_filenames'].filename
            document.save()

    save_metadata_list(decode_metadata_from_url(request.GET), document)
    try:
        document_create_fs_links(document)
    except Exception, e:
        messages.error(request, e)
Exemplo n.º 2
0
def _handle_save_document(request, document, form=None):
    # TODO: move this to OCR app as a post_save signal on create==True
    if AUTOMATIC_OCR:
        submit_document_to_queue(request, document)

    if form and "document_type_available_filenames" in form.cleaned_data:
        if form.cleaned_data["document_type_available_filenames"]:
            document.file_filename = form.cleaned_data["document_type_available_filenames"].filename
            document.save()

    save_metadata_list(decode_metadata_from_url(request.GET), document)
    try:
        warnings = document_create_fs_links(document)
        if request.user.is_staff or request.user.is_superuser:
            for warning in warnings:
                messages.warning(request, warning)
    except Exception, e:
        messages.error(request, e)
Exemplo n.º 3
0
def _handle_save_document(request, document, form=None):
    #TODO: move this to OCR app as a post_save signal on create==True
    if AUTOMATIC_OCR:
        submit_document_to_queue(request, document)
    
    if form and 'document_type_available_filenames' in form.cleaned_data:
        if form.cleaned_data['document_type_available_filenames']:
            document.file_filename = form.cleaned_data['document_type_available_filenames'].filename
            document.save()

    save_metadata_list(decode_metadata_from_url(request.GET), document)
    try:
        warnings = document_create_fs_links(document)
        if request.user.is_staff or request.user.is_superuser:
            for warning in warnings:
                messages.warning(request, warning)        
    except Exception, e:
        messages.error(request, e)
Exemplo n.º 4
0
                        }
                    ]
                }
            )
            context["form_list"].append(
                {"form": staging_form, "title": _(u"upload a document from staging"), "grid": 6, "grid_clear": True}
            )

    context.update(
        {
            "sidebar_subtemplates_list": [
                {
                    "title": _(u"Current metadata"),
                    "name": "generic_subtemplate.html",
                    #'content':metadata_repr(decode_metadata_from_url(request.GET)),
                    "paragraphs": metadata_repr_as_list(decode_metadata_from_url(request.GET)),
                }
            ]
        }
    )
    return render_to_response("generic_form.html", context, context_instance=RequestContext(request))


def document_view(request, document_id):
    check_permissions(request.user, "documents", [PERMISSION_DOCUMENT_VIEW])

    document = get_object_or_404(Document, pk=document_id)
    form = DocumentForm_view(
        instance=document,
        extra_fields=[
            {"label": _(u"Filename"), "field": "file_filename"},
Exemplo n.º 5
0
            context['form_list'].append(
                {
                    'form':staging_form,
                    'title':_(u'upload a document from staging'),
                    'grid':6,
                    'grid_clear':True,   
                },
            )
            
    context.update({
        'sidebar_subtemplates_list':[
            {
                'title':_(u'Current metadata'),
                'name':'generic_subtemplate.html',
                #'content':metadata_repr(decode_metadata_from_url(request.GET)),
                'paragraphs':metadata_repr_as_list(decode_metadata_from_url(request.GET))
            }]
    })
    return render_to_response('generic_form.html', context,
        context_instance=RequestContext(request))
    
def document_view(request, document_id):
    check_permissions(request.user, 'documents', [PERMISSION_DOCUMENT_VIEW])
            
    document = get_object_or_404(Document, pk=document_id)
    form = DocumentForm_view(instance=document, extra_fields=[
        {'label':_(u'Filename'), 'field':'file_filename'},
        {'label':_(u'File extension'), 'field':'file_extension'},
        {'label':_(u'File mimetype'), 'field':'file_mimetype'},
        {'label':_(u'File mime encoding'), 'field':'file_mime_encoding'},
        {'label':_(u'File size'), 'field':lambda x: pretty_size(x.file.storage.size(x.file.path)) if x.exists() else '-'},