Merge branch 'dev'

This commit is contained in:
Jonas Winkler 2018-09-13 14:15:33 +02:00
commit 8371c2399f
9 changed files with 121 additions and 105 deletions

View File

@ -48,9 +48,7 @@ def select_action(modeladmin, request, queryset, title, action, modelclass, succ
request.current_app = modeladmin.admin_site.name request.current_app = modeladmin.admin_site.name
return TemplateResponse(request, return TemplateResponse(request, "admin/%s/%s/select_object.html" % (app_label, opts.model_name), context)
"admin/%s/%s/select_object.html" % (app_label, opts.model_name)
, context)
def simple_action(modeladmin, request, queryset, success_message="", document_action=None, queryset_action=None): def simple_action(modeladmin, request, queryset, success_message="", document_action=None, queryset_action=None):
@ -70,6 +68,7 @@ def simple_action(modeladmin, request, queryset, success_message="", document_ac
"count": n, "items": model_ngettext(modeladmin.opts, n) "count": n, "items": model_ngettext(modeladmin.opts, n)
}, messages.SUCCESS) }, messages.SUCCESS)
# Return None to display the change list page again.
return None return None
@ -99,7 +98,7 @@ def set_correspondent_on_selected(modeladmin, request, queryset):
action="set_correspondent_on_selected", action="set_correspondent_on_selected",
modelclass=Correspondent, modelclass=Correspondent,
success_message="Successfully set correspondent %(selected_object)s on %(count)d %(items)s.", success_message="Successfully set correspondent %(selected_object)s on %(count)d %(items)s.",
queryset_action=lambda queryset, correspondent: queryset.update(correspondent=correspondent)) queryset_action=lambda qs, correspondent: qs.update(correspondent=correspondent))
set_correspondent_on_selected.short_description = "Set correspondent on selected documents" set_correspondent_on_selected.short_description = "Set correspondent on selected documents"
@ -116,7 +115,7 @@ def set_document_type_on_selected(modeladmin, request, queryset):
action="set_document_type_on_selected", action="set_document_type_on_selected",
modelclass=DocumentType, modelclass=DocumentType,
success_message="Successfully set document type %(selected_object)s on %(count)d %(items)s.", success_message="Successfully set document type %(selected_object)s on %(count)d %(items)s.",
queryset_action=lambda queryset, document_type: queryset.update(document_type=document_type)) queryset_action=lambda qs, document_type: qs.update(document_type=document_type))
set_document_type_on_selected.short_description = "Set document type on selected documents" set_document_type_on_selected.short_description = "Set document type on selected documents"

View File

@ -94,6 +94,7 @@ class RecentCorrespondentFilter(admin.RelatedFieldListFilter):
def field_choices(self, field, request, model_admin): def field_choices(self, field, request, model_admin):
lookups = [] lookups = []
if settings.PAPERLESS_RECENT_CORRESPONDENT_YEARS and settings.PAPERLESS_RECENT_CORRESPONDENT_YEARS > 0:
date_limit = datetime.now() - timedelta(days=365*settings.PAPERLESS_RECENT_CORRESPONDENT_YEARS) date_limit = datetime.now() - timedelta(days=365*settings.PAPERLESS_RECENT_CORRESPONDENT_YEARS)
for c in Correspondent.objects.filter(documents__created__gte=date_limit).distinct(): for c in Correspondent.objects.filter(documents__created__gte=date_limit).distinct():
lookups.append((c.id, c.name)) lookups.append((c.id, c.name))
@ -153,6 +154,7 @@ class DocumentTypeAdmin(CommonAdmin):
return obj.document_count return obj.document_count
document_count.admin_order_field = "document_count" document_count.admin_order_field = "document_count"
class DocumentAdmin(CommonAdmin): class DocumentAdmin(CommonAdmin):
class Media: class Media:

View File

@ -4,7 +4,7 @@
{{ block.super }} {{ block.super }}
{% if file_type in "pdf jpg png" %} {% if file_type in "asd" %}
<div id="change_form_twocolumn_parent"> <div id="change_form_twocolumn_parent">
<div id="change_form_form_parent"></div> <div id="change_form_form_parent"></div>
@ -23,6 +23,8 @@
django.jQuery("#content-main").append(django.jQuery("#change_form_twocolumn_parent")); django.jQuery("#content-main").append(django.jQuery("#change_form_twocolumn_parent"));
</script> </script>
{% endif %}
{% if next_object %} {% if next_object %}
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
(function($){ (function($){
@ -33,7 +35,6 @@
})(django.jQuery); })(django.jQuery);
//]]></script> //]]></script>
{% endif %} {% endif %}
{% endif %}
{% endblock content %} {% endblock content %}

View File

@ -1,2 +1 @@
<img src="{{download_url}}" style="max-width: 100%"> <img src="{{download_url}}" style="max-width: 100%">

View File

@ -15,6 +15,7 @@
</div> </div>
<script type="text/javascript" src="{% static 'documents/js/pdf.js' %}"></script> <script type="text/javascript" src="{% static 'documents/js/pdf.js' %}"></script>
<script type="text/javascript" src="{% static 'documents/js/pdf.worker.js' %}"></script> <script type="text/javascript" src="{% static 'documents/js/pdf.worker.js' %}"></script>
{# Load and display PDF document#} {# Load and display PDF document#}
<script> <script>
var pdfjsLib = window['pdfjs-dist/build/pdf']; var pdfjsLib = window['pdfjs-dist/build/pdf'];
@ -57,6 +58,7 @@ var pdfDoc = null,
// Update page counters // Update page counters
document.getElementById('page_num').textContent = num; document.getElementById('page_num').textContent = num;
} }
/** /**
* If another page rendering in progress, waits until the rendering is * If another page rendering in progress, waits until the rendering is
* finised. Otherwise, executes rendering immediately. * finised. Otherwise, executes rendering immediately.
@ -68,6 +70,7 @@ var pdfDoc = null,
renderPage(num); renderPage(num);
} }
} }
/** /**
* Displays previous page. * Displays previous page.
*/ */
@ -78,7 +81,9 @@ var pdfDoc = null,
pageNum--; pageNum--;
queueRenderPage(pageNum); queueRenderPage(pageNum);
} }
document.getElementById('prev').addEventListener('click', onPrevPage); document.getElementById('prev').addEventListener('click', onPrevPage);
/** /**
* Displays next page. * Displays next page.
*/ */
@ -89,7 +94,9 @@ var pdfDoc = null,
pageNum++; pageNum++;
queueRenderPage(pageNum); queueRenderPage(pageNum);
} }
document.getElementById('next').addEventListener('click', onNextPage); document.getElementById('next').addEventListener('click', onNextPage);
/** /**
* Displays next page. * Displays next page.
*/ */
@ -97,7 +104,9 @@ var pdfDoc = null,
scale *= 1.2; scale *= 1.2;
queueRenderPage(pageNum); queueRenderPage(pageNum);
} }
document.getElementById('zoomin').addEventListener('click', onZoomIn); document.getElementById('zoomin').addEventListener('click', onZoomIn);
/** /**
* Displays next page. * Displays next page.
*/ */
@ -105,7 +114,9 @@ var pdfDoc = null,
scale /= 1.2; scale /= 1.2;
queueRenderPage(pageNum); queueRenderPage(pageNum);
} }
document.getElementById('zoomout').addEventListener('click', onZoomOut); document.getElementById('zoomout').addEventListener('click', onZoomOut);
/** /**
* Asynchronously downloads PDF. * Asynchronously downloads PDF.
*/ */

View File

@ -298,4 +298,8 @@ FY_END = os.getenv("PAPERLESS_FINANCIAL_YEAR_END")
# Specify the default date order (for autodetected dates) # Specify the default date order (for autodetected dates)
DATE_ORDER = os.getenv("PAPERLESS_DATE_ORDER", "DMY") DATE_ORDER = os.getenv("PAPERLESS_DATE_ORDER", "DMY")
PAPERLESS_RECENT_CORRESPONDENT_YEARS = int(os.getenv("PAPERLESS_RECENT_CORRESPONDENT_YEARS", 1)) # Specify for how many years a correspondent is considered recent. Recent
# correspondents will be shown in a separate "Recent correspondents" filter as
# well. Set to 0 to disable this filter.
PAPERLESS_RECENT_CORRESPONDENT_YEARS = int(os.getenv(
"PAPERLESS_RECENT_CORRESPONDENT_YEARS", 0))