Improve document print form and view.
This commit is contained in:
@@ -130,3 +130,7 @@ hr {
|
|||||||
.a-caption {
|
.a-caption {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.radio ul li {
|
||||||
|
list-style-type:none;
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,6 +59,10 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
{% render_field field class+="" %}
|
{% render_field field class+="" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% elif field|widget_type == 'radioselect' %}
|
||||||
|
<div class="radio">
|
||||||
|
{% render_field field %}
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% render_field field class+="form-control" %}
|
{% render_field field class+="form-control" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from common.forms import DetailForm
|
|||||||
from .models import (
|
from .models import (
|
||||||
Document, DocumentType, DocumentPage, DocumentTypeFilename
|
Document, DocumentType, DocumentPage, DocumentTypeFilename
|
||||||
)
|
)
|
||||||
from .literals import DEFAULT_ZIP_FILENAME
|
from .literals import DEFAULT_ZIP_FILENAME, PAGE_RANGE_CHOICES
|
||||||
from .widgets import DocumentPagesCarouselWidget, DocumentPageImageWidget
|
from .widgets import DocumentPagesCarouselWidget, DocumentPageImageWidget
|
||||||
|
|
||||||
|
|
||||||
@@ -108,10 +108,6 @@ class DocumentTypeSelectForm(forms.Form):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class PrintForm(forms.Form):
|
|
||||||
page_range = forms.CharField(label=_('Page range'), required=False)
|
|
||||||
|
|
||||||
|
|
||||||
class DocumentTypeFilenameForm_create(forms.ModelForm):
|
class DocumentTypeFilenameForm_create(forms.ModelForm):
|
||||||
"""
|
"""
|
||||||
Model class form to create a new document type filename
|
Model class form to create a new document type filename
|
||||||
@@ -146,3 +142,10 @@ class DocumentDownloadForm(forms.Form):
|
|||||||
if len(self.document_versions) > 1:
|
if len(self.document_versions) > 1:
|
||||||
self.fields['compressed'].initial = True
|
self.fields['compressed'].initial = True
|
||||||
self.fields['compressed'].widget.attrs.update({'disabled': True})
|
self.fields['compressed'].widget.attrs.update({'disabled': True})
|
||||||
|
|
||||||
|
|
||||||
|
class PrintForm(forms.Form):
|
||||||
|
page_group = forms.ChoiceField(
|
||||||
|
widget=forms.RadioSelect, choices=PAGE_RANGE_CHOICES
|
||||||
|
)
|
||||||
|
page_range = forms.CharField(label=_('Page range'), required=False)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
CACHE_PATH = 'document_cache/'
|
CACHE_PATH = 'document_cache/'
|
||||||
CHECK_DELETE_PERIOD_INTERVAL = 60
|
CHECK_DELETE_PERIOD_INTERVAL = 60
|
||||||
CHECK_TRASH_PERIOD_INTERVAL = 60
|
CHECK_TRASH_PERIOD_INTERVAL = 60
|
||||||
@@ -10,3 +12,10 @@ DOCUMENT_IMAGE_TASK_TIMEOUT = 20
|
|||||||
UPDATE_PAGE_COUNT_RETRY_DELAY = 10
|
UPDATE_PAGE_COUNT_RETRY_DELAY = 10
|
||||||
UPLOAD_NEW_VERSION_RETRY_DELAY = 10
|
UPLOAD_NEW_VERSION_RETRY_DELAY = 10
|
||||||
NEW_DOCUMENT_RETRY_DELAY = 10
|
NEW_DOCUMENT_RETRY_DELAY = 10
|
||||||
|
|
||||||
|
PAGE_RANGE_ALL = 'all'
|
||||||
|
PAGE_RANGE_RANGE = 'range'
|
||||||
|
PAGE_RANGE_CHOICES = (
|
||||||
|
(PAGE_RANGE_ALL, _('All pages')), (PAGE_RANGE_RANGE, _('Page range'))
|
||||||
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
{% extends 'appearance/base.html' %}
|
{% extends 'appearance/base.html' %}
|
||||||
|
|
||||||
|
{% block title %}{{ title }}{% endblock title %}
|
||||||
|
|
||||||
{% block content_plain %}
|
{% block content_plain %}
|
||||||
{% for page in pages %}
|
{% for page in pages %}
|
||||||
<img src="{% url 'documents:document_display_print' object.id %}?page={{ page.page_number }}" />
|
<img src="{% url 'documents:document_display_print' object.id %}?page={{ page.page_number }}" />
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ from .forms import (
|
|||||||
DocumentPropertiesForm, DocumentTypeSelectForm,
|
DocumentPropertiesForm, DocumentTypeSelectForm,
|
||||||
DocumentTypeFilenameForm_create, PrintForm
|
DocumentTypeFilenameForm_create, PrintForm
|
||||||
)
|
)
|
||||||
from .literals import DOCUMENT_IMAGE_TASK_TIMEOUT
|
from .literals import DOCUMENT_IMAGE_TASK_TIMEOUT, PAGE_RANGE_RANGE
|
||||||
from .models import (
|
from .models import (
|
||||||
DeletedDocument, Document, DocumentType, DocumentPage,
|
DeletedDocument, Document, DocumentType, DocumentPage,
|
||||||
DocumentTypeFilename, DocumentVersion, RecentDocument
|
DocumentTypeFilename, DocumentVersion, RecentDocument
|
||||||
@@ -1092,30 +1092,32 @@ def document_print(request, document_id):
|
|||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = PrintForm(request.POST)
|
form = PrintForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
if form.cleaned_data['page_range']:
|
if form.cleaned_data['page_group'] == PAGE_RANGE_RANGE:
|
||||||
page_range = form.cleaned_data['page_range']
|
page_range = form.cleaned_data['page_range']
|
||||||
|
|
||||||
if page_range:
|
if page_range:
|
||||||
page_range = parse_range(page_range)
|
page_range = parse_range(page_range)
|
||||||
|
|
||||||
pages = document.pages.filter(page_number__in=page_range)
|
pages = document.pages.filter(page_number__in=page_range)
|
||||||
else:
|
else:
|
||||||
pages = document.pages.all()
|
pages = document.pages.all()
|
||||||
|
else:
|
||||||
|
pages = document.pages.all()
|
||||||
|
|
||||||
return render_to_response('documents/document_print.html', {
|
return render_to_response('documents/document_print.html', {
|
||||||
'appearance_type': 'plain',
|
'appearance_type': 'plain',
|
||||||
'object': document,
|
'object': document,
|
||||||
'page_range': page_range,
|
'pages': pages,
|
||||||
'pages': pages,
|
'title': _('Print: %s') % document,
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
else:
|
else:
|
||||||
form = PrintForm()
|
form = PrintForm()
|
||||||
|
|
||||||
return render_to_response('appearance/generic_form.html', {
|
return render_to_response('appearance/generic_form.html', {
|
||||||
'form': form,
|
'form': form,
|
||||||
'object': document,
|
'object': document,
|
||||||
'title': _('Print: %s') % document,
|
|
||||||
'next': next,
|
'next': next,
|
||||||
|
'title': _('Print: %s') % document,
|
||||||
|
'submit_label': _('Submit'),
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user