Show current metadata in document upload view
This commit is contained in:
@@ -1,5 +1,61 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %} :: {% with "true" as striptags %}{% include "calculate_form_title.html" %}{% endwith %}{% endblock %}
|
||||
|
||||
{% block sidebar %}
|
||||
{% for subtemplate in sidebar_subtemplates %}
|
||||
<div class="generic_subform">
|
||||
{% include subtemplate %}
|
||||
</div><!--end subform-->
|
||||
{% endfor %}
|
||||
|
||||
{% for subtemplate in sidebar_subtemplates_list %}
|
||||
{% with subtemplate.title as title %}
|
||||
{% with subtemplate.object_list as object_list %}
|
||||
{% with subtemplate.extra_columns as extra_columns %}
|
||||
{% with subtemplate.hide_object as hide_object %}
|
||||
{% with subtemplate.main_object as main_object %}
|
||||
{% with subtemplate.hide_link as hide_link %}
|
||||
{% with subtemplate.hide_header as hide_header %}
|
||||
{% with subtemplate.hide_columns as hide_columns %}
|
||||
{% with "true" as side_bar %}
|
||||
|
||||
{% with subtemplate.submit_method as submit_method %}
|
||||
{% with subtemplate.striptags as striptags %}
|
||||
{% with subtemplate.title as title %}
|
||||
{% with subtemplate.object as object %}
|
||||
{% with subtemplate.object_name as object_name %}
|
||||
{% with subtemplate.form_action as form_action %}
|
||||
{% with subtemplate.form as form %}
|
||||
|
||||
{% with subtemplate.content as content %}
|
||||
{% with subtemplate.paragraphs as paragraphs %}
|
||||
|
||||
{% include subtemplate.name %}
|
||||
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
|
||||
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container_12">
|
||||
{% if form %}
|
||||
|
||||
19
apps/common/templates/generic_subtemplate.html
Normal file
19
apps/common/templates/generic_subtemplate.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{% if side_bar %}
|
||||
<div class="block">
|
||||
<h3>{{ title }}</h3>
|
||||
<div class="content">
|
||||
{% else %}
|
||||
<div class="content">
|
||||
<h2 class="title">{{ title }}</h2>
|
||||
<div class="inner">
|
||||
{% endif %}
|
||||
|
||||
{% if content %}
|
||||
<p>{{ content }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% for paragraph in paragraphs %}
|
||||
<p>{{ paragraph }}</p>
|
||||
{% endfor %}
|
||||
|
||||
</div></div>
|
||||
@@ -1,15 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
{% block title %} :: {{ title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="content">
|
||||
<h2 class="title">{{ title }}</h2>
|
||||
<div class="inner">
|
||||
<p>{{ content }}</p>
|
||||
|
||||
{% for paragraph in paragraphs %}
|
||||
<p>{{ paragraph }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% include "generic_subtemplate.html" %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -31,6 +31,8 @@ def save_metadata_list(metadata_list, document):
|
||||
if item['value']:
|
||||
save_metadata(item, document)
|
||||
else:
|
||||
#If there is no metadata value, delete the metadata entry
|
||||
#completely from the document
|
||||
try:
|
||||
metadata_type = MetadataType.objects.get(id=item['id'])
|
||||
document_metadata = DocumentMetadata.objects.get(document=document,
|
||||
@@ -52,3 +54,21 @@ def save_metadata(metadata_dict, document):
|
||||
#http://stackoverflow.com/questions/4382875/handling-iri-in-django
|
||||
document_metadata.value=unquote_plus(metadata_dict['value'])#.decode('utf-8')
|
||||
document_metadata.save()
|
||||
|
||||
|
||||
def metadata_repr(metadata_list):
|
||||
return ', '.join(metadata_repr_as_list(metadata_list))
|
||||
|
||||
|
||||
def metadata_repr_as_list(metadata_list):
|
||||
output = []
|
||||
for metadata_dict in metadata_list:
|
||||
try:
|
||||
output.append('%s - %s' % (MetadataType.objects.get(pk=metadata_dict['id']), metadata_dict.get('value', '')))
|
||||
except:
|
||||
pass
|
||||
|
||||
return output
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +50,8 @@ from forms import DocumentTypeSelectForm, DocumentCreateWizard, \
|
||||
StagingDocumentForm, DocumentTypeMetadataType, DocumentPreviewForm, \
|
||||
MetadataFormSet, DocumentPageForm, DocumentPageTransformationForm
|
||||
|
||||
from metadata import save_metadata, save_metadata_list, decode_metadata_from_url
|
||||
from metadata import save_metadata, save_metadata_list, \
|
||||
decode_metadata_from_url, metadata_repr_as_list
|
||||
from models import Document, DocumentMetadata, DocumentType, MetadataType, \
|
||||
DocumentPage, DocumentPageTransformation
|
||||
from staging import StagingFile
|
||||
@@ -227,7 +228,16 @@ def upload_document_with_type(request, document_type_id, multiple=True):
|
||||
'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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user