diff --git a/apps/documents/__init__.py b/apps/documents/__init__.py
index ed61c3553e..c887a5636b 100644
--- a/apps/documents/__init__.py
+++ b/apps/documents/__init__.py
@@ -39,7 +39,8 @@ document_list = {'text':_(u'documents list'), 'view':'document_list', 'famfam':'
document_create = {'text':_('upload a new document'), 'view':'document_create', 'famfam':'page_add', 'permissions':{'namespace':'documents', 'permissions':[PERMISSION_DOCUMENT_CREATE]}}
document_create_multiple = {'text':_('upload multiple new documents'), 'view':'document_create_multiple', 'famfam':'page_add', 'permissions':{'namespace':'documents', 'permissions':[PERMISSION_DOCUMENT_CREATE]}}
document_create_sibling = {'text':_('upload new document using same metadata'), 'view':'document_create_sibling', 'args':'object.id', 'famfam':'page_copy', 'permissions':{'namespace':'documents', 'permissions':[PERMISSION_DOCUMENT_CREATE]}}
-document_view = {'text':_('details'), 'view':'document_view', 'args':'object.id', 'famfam':'page', 'permissions':{'namespace':'documents', 'permissions':[PERMISSION_DOCUMENT_VIEW]}}
+document_view = {'text':_('details (advanced)'), 'view':'document_view', 'args':'object.id', 'famfam':'page', 'permissions':{'namespace':'documents', 'permissions':[PERMISSION_DOCUMENT_VIEW]}}
+document_view_simple = {'text':_('details (simple)'), 'view':'document_view_simple', 'args':'object.id', 'famfam':'page', 'permissions':{'namespace':'documents', 'permissions':[PERMISSION_DOCUMENT_VIEW]}}
document_delete = {'text':_('delete'), 'view':'document_delete', 'args':'object.id', 'famfam':'page_delete', 'permissions':{'namespace':'documents', 'permissions':[PERMISSION_DOCUMENT_DELETE]}}
document_edit = {'text':_('edit'), 'view':'document_edit', 'args':'object.id', 'famfam':'page_edit', 'permissions':{'namespace':'documents', 'permissions':[PERMISSION_DOCUMENT_PROPERTIES_EDIT]}}
document_edit_metadata = {'text':_('edit metadata'), 'view':'document_edit_metadata', 'args':'object.id', 'famfam':'page_edit', 'permissions':{'namespace':'documents', 'permissions':[PERMISSION_DOCUMENT_METADATA_EDIT]}}
@@ -59,7 +60,7 @@ document_page_go_back = {'text':_('return to document'), 'view':'document_view',
staging_file_preview = {'text':_('preview'), 'class':'fancybox-noscaling', 'view':'staging_file_preview', 'args':'object.id', 'famfam':'drive_magnify'}
staging_file_delete = {'text':_('delete'), 'view':'staging_file_delete', 'args':'object.id', 'famfam':'drive_delete'}
-register_links(Document, [document_view, document_edit, document_edit_metadata, document_delete, document_download, document_find_duplicates, document_clear_transformations], menu_name='sidebar')
+register_links(Document, [document_view_simple, document_view, document_edit, document_edit_metadata, document_delete, document_download, document_find_duplicates, document_clear_transformations], menu_name='sidebar')
register_links(Document, [document_list, document_create, document_create_multiple, document_create_sibling], menu_name='sidebar')
if ENABLE_SINGLE_DOCUMENT_UPLOAD:
diff --git a/apps/documents/forms.py b/apps/documents/forms.py
index a1a34a0ef6..9ee808037e 100644
--- a/apps/documents/forms.py
+++ b/apps/documents/forms.py
@@ -49,12 +49,11 @@ class DocumentPageForm(DetailForm):
self.fields['page_image'].initial = self.instance
page_image = forms.CharField(widget=DocumentPageImageWidget())
-
+
class ImageWidget(forms.widgets.Widget):
def render(self, name, value, attrs=None):
output = []
-
page_count = value.documentpage_set.count()
if page_count > 1:
output.append('
%s
' % ugettext(u'Pages'))
@@ -71,13 +70,13 @@ class ImageWidget(forms.widgets.Widget):
})
output.append('
%s' % ugettext(u'Click on the image for full size view'))
+ if not self.attrs.get('hide_detail_link', False):
+ for document_page in value.documentpage_set.all():
+ output.append('
%(text)s' % {
+ 'page_number': document_page.page_number,
+ 'url':reverse('document_page_view', args=[document_page.id]),
+ 'text':ugettext(u'Page %s details') % document_page.page_number})
- for document_page in value.documentpage_set.all():
- output.append('
%(text)s' % {
- 'page_number': document_page.page_number,
- 'url':reverse('document_page_view', args=[document_page.id]),
- 'text':ugettext(u'Page %s details') % document_page.page_number})
- #output.append(super(ImageWidget, self).render(name, value, attrs))
return mark_safe(u''.join(output))
@@ -105,12 +104,25 @@ class DocumentForm(forms.ModelForm):
class DocumentPreviewForm(forms.Form):
def __init__(self, *args, **kwargs):
self.document = kwargs.pop('document', None)
+ self.hide_detail_link = kwargs.pop('hide_detail_link', False)
+
super(DocumentPreviewForm, self).__init__(*args, **kwargs)
self.fields['preview'].initial = self.document
+ self.fields['preview'].widget.attrs['hide_detail_link']=self.hide_detail_link
preview = forms.CharField(widget=ImageWidget())
+class DocumentContentForm(forms.Form):
+ def __init__(self, *args, **kwargs):
+ self.document = kwargs.pop('document', None)
+ super(DocumentContentForm, self).__init__(*args, **kwargs)
+ page_break_template = u'\n\n\n------------------ %s ------------------\n\n\n' % _(u'page break')
+ self.fields['contents'].initial = page_break_template.join([page.content for page in self.document.documentpage_set.all() if page.content])
+
+ contents = forms.CharField(label=_(u'Contents'), widget=forms.widgets.Textarea(attrs={'rows':24, 'cols':80}))
+
+
class DocumentForm_view(DetailForm):
class Meta:
model = Document
diff --git a/apps/documents/models.py b/apps/documents/models.py
index 2d9482782a..6985c4017e 100644
--- a/apps/documents/models.py
+++ b/apps/documents/models.py
@@ -98,7 +98,7 @@ class Document(models.Model):
@models.permalink
def get_absolute_url(self):
- return ('document_view', [self.id])
+ return ('document_view_simple', [self.id])
def update_checksum(self, save=True):
diff --git a/apps/documents/urls.py b/apps/documents/urls.py
index a7c0f92a7b..867dd91a42 100644
--- a/apps/documents/urls.py
+++ b/apps/documents/urls.py
@@ -19,6 +19,7 @@ urlpatterns = patterns('documents.views',
url(r'^document/type/(?P\d+)/upload/single/$', 'upload_document_with_type', {'multiple':False}, 'upload_document_with_type'),
url(r'^document/type/(?P\d+)/upload/multiple/$', 'upload_document_with_type', {'multiple':True}, 'upload_multiple_documents_with_type'),
url(r'^document/(?P\d+)/$', 'document_view', (), 'document_view'),
+ url(r'^document/(?P\d+)/simple/$', 'document_view_simple', (), 'document_view_simple'),
url(r'^document/(?P\d+)/delete/$', 'document_delete', (), 'document_delete'),
url(r'^document/(?P\d+)/edit/$', 'document_edit', (), 'document_edit'),
url(r'^document/(?P\d+)/edit/metadata/$', 'document_edit_metadata', (), 'document_edit_metadata'),
diff --git a/apps/documents/views.py b/apps/documents/views.py
index 57afa89990..80be4fde0e 100644
--- a/apps/documents/views.py
+++ b/apps/documents/views.py
@@ -741,3 +741,77 @@ def document_clear_transformations(request, document_id):
'title':_(u'Are you sure you with to clear all the page transformations for document: %s?') % document,
'previous':previous,
}, context_instance=RequestContext(request))
+
+from forms import DocumentContentForm
+
+def document_view_simple(request, document_id):
+ check_permissions(request.user, 'documents', [PERMISSION_DOCUMENT_VIEW])
+
+ document = get_object_or_404(Document, pk=document_id)
+
+ content_form = DocumentContentForm(document=document)
+
+ metadata_groups, errors = document.get_metadata_groups()
+ if (request.user.is_staff or request.user.is_superuser) and errors:
+ for error in errors:
+ messages.warning(request, _(u'Metadata group query error: %s' % error))
+
+ preview_form = DocumentPreviewForm(document=document, hide_detail_link=True)
+ form_list = [
+ {
+ 'form':content_form,
+ 'object':document,
+ 'grid':6,
+ },
+ {
+ 'form':preview_form,
+ 'title':_(u'document preview'),
+ 'object':document,
+ 'grid':6,
+ 'grid_clear':True,
+ },
+ ]
+ subtemplates_dict = [
+ {
+ 'name':'generic_list_subtemplate.html',
+ 'title':_(u'metadata'),
+ 'object_list':document.documentmetadata_set.all(),
+ 'extra_columns':[{'name':_(u'value'), 'attribute':'value'}],
+ 'hide_link':True,
+ },
+ ]
+
+ sidebar_groups = []
+ for group, data in metadata_groups.items():
+ if len(data) or GROUP_SHOW_EMPTY:
+ if len(data):
+ if len(data) > GROUP_MAX_RESULTS:
+ total_string = '(%s out of %s)' % (GROUP_MAX_RESULTS, len(data))
+ else:
+ total_string = '(%s)' % len(data)
+ else:
+ total_string = ''
+
+ extra_columns = [{'name':'current','attribute':lambda x:
+ '' if x == document else ''}]
+
+ if GROUP_SHOW_THUMBNAIL:
+ extra_columns.append({'name':_(u'thumbnail'), 'attribute':
+ lambda x: '
' % (reverse('document_preview', args=[x.id]),
+ reverse('document_thumbnail', args=[x.id]))})
+
+ sidebar_groups.append({
+ 'title':'%s %s' % (group.label, total_string),
+ 'name':'generic_list_subtemplate.html',
+ 'object_list':data[:GROUP_MAX_RESULTS],
+ 'hide_columns':True,
+ 'hide_header':True,
+ 'extra_columns':extra_columns,
+ })
+
+ return render_to_response('generic_detail.html', {
+ 'form_list':form_list,
+ 'object':document,
+ 'subtemplates_dict':subtemplates_dict,
+ 'sidebar_subtemplates_dict':sidebar_groups,
+ }, context_instance=RequestContext(request))
diff --git a/docs/Changelog.txt b/docs/Changelog.txt
index 25f7d27698..9c42c42189 100644
--- a/docs/Changelog.txt
+++ b/docs/Changelog.txt
@@ -1,5 +1,8 @@
2011-Mar-11
* Don't allow duplicate documents in queues
+* Don't raise PermissionDenied exception in PermissionDenied middleware, even while debugging
+* Fixed page number detection
+* Created 'simple document' for non technical users with all of a document pages content
2011-Mar-10
* Added new setting: side bar search box
diff --git a/docs/TODO b/docs/TODO
index f46e8d9423..854256608f 100644
--- a/docs/TODO
+++ b/docs/TODO
@@ -108,7 +108,9 @@ Documents
* Improve doc page template/view
* Document page edit view
* Show all document's pages content combined
-* Create 'simple view' = stripped down document view for non technical users
+* Create 'simple view' document view for non technical users - DONE
+* Unify document form classes
+* Use document preview code for staging file also
Filesystem serving
==================
@@ -156,4 +158,6 @@ OCR
* Don't allow duplicate documents in queues - STARTED
* OCR queue schedule support
* Make automatic OCR a function of OCR app and not of Documents app (via signals)
+* Two types of OCR nodes: thin, fat (thin = document file is passed serialize to node,
+ fat = has direct access to document storage read document file)