mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Merge branch 'master' into workflow-improvements
This commit is contained in:
		| @@ -110,7 +110,7 @@ class CommonAdmin(admin.ModelAdmin): | ||||
|  | ||||
| class CorrespondentAdmin(CommonAdmin): | ||||
|  | ||||
|     list_display = ("name", "match", "matching_algorithm") | ||||
|     list_display = ("name", "match", "matching_algorithm", "document_count") | ||||
|     list_filter = ("matching_algorithm",) | ||||
|     list_editable = ("match", "matching_algorithm") | ||||
|  | ||||
| @@ -122,9 +122,14 @@ class CorrespondentAdmin(CommonAdmin): | ||||
|                 document.correspondent = obj | ||||
|                 document.save(update_fields=("correspondent",)) | ||||
|  | ||||
|     def document_count(self, obj): | ||||
|         return obj.documents.count() | ||||
|  | ||||
|  | ||||
| class TagAdmin(CommonAdmin): | ||||
|  | ||||
|     list_display = ("name", "colour", "match", "matching_algorithm") | ||||
|     list_display = ("name", "colour", "match", "matching_algorithm", | ||||
|                     "document_count") | ||||
|     list_filter = ("colour", "matching_algorithm") | ||||
|     list_editable = ("colour", "match", "matching_algorithm") | ||||
|  | ||||
| @@ -135,6 +140,9 @@ class TagAdmin(CommonAdmin): | ||||
|             if obj.matches(document.content): | ||||
|                 document.tags.add(obj) | ||||
|  | ||||
|     def document_count(self, obj): | ||||
|         return obj.documents.count() | ||||
|  | ||||
|  | ||||
| def add_tag_to_selected(modeladmin, request, queryset): | ||||
|     opts = modeladmin.model._meta | ||||
|   | ||||
| @@ -8,7 +8,6 @@ from django import forms | ||||
| from django.conf import settings | ||||
|  | ||||
| from .models import Document, Correspondent | ||||
| from .consumer import Consumer | ||||
|  | ||||
|  | ||||
| class UploadForm(forms.Form): | ||||
|   | ||||
							
								
								
									
										40
									
								
								src/documents/templates/admin/base_site.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								src/documents/templates/admin/base_site.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| {% extends 'admin/base_site.html' %} | ||||
|  | ||||
| {# NOTE: This should probably be extending base.html.  See CSS comment below details. #} | ||||
|  | ||||
|  | ||||
| {% load custom_css from customisation %} | ||||
| {% load custom_js from customisation %} | ||||
|  | ||||
|  | ||||
| {% block blockbots %} | ||||
|  | ||||
| 	{% comment %} | ||||
| 		This really should be extending `extrastyle`, but the the | ||||
| 		django-flat-responsive package decided that it wanted to put its CSS in | ||||
| 		this block, so to make sure that overrides are in fact overriding | ||||
| 		everything else, we have to do the Wrong Thing here. | ||||
|  | ||||
| 		Once we switch to Django 2.x and drop django-flat-responsive, we should | ||||
| 		switch this to `extrastyle` where it should be. | ||||
| 	{% endcomment %} | ||||
|  | ||||
| 	{{ block.super }} | ||||
|  | ||||
| 	{% custom_css %} | ||||
|  | ||||
| {% endblock blockbots %} | ||||
|  | ||||
|  | ||||
| {% block footer %} | ||||
|  | ||||
| 	{% comment %} | ||||
| 		The Django admin doesn't have a block for Javascript you'd want placed in | ||||
| 		the footer, so we have to use this one instead. | ||||
| 	{% endcomment %} | ||||
|  | ||||
| 	{{ block.super }} | ||||
|  | ||||
| 	{% custom_js %} | ||||
|  | ||||
| {% endblock footer %} | ||||
| @@ -4,6 +4,24 @@ | ||||
| {% load i18n static %} | ||||
|  | ||||
|  | ||||
| {# This block adds a search form on the admin start page and on the module start page so that #} | ||||
| {# the user can quickly search for documents #} | ||||
| {% block pretitle %} | ||||
| <div> | ||||
|     <h3>{% trans 'Search documents' %}</h3> | ||||
|  | ||||
|     <div id="toolbar"><form id="changelist-search" method="get" action="{% url 'admin:documents_document_changelist' %}"> | ||||
|             <div><!-- DIV needed for valid HTML --> | ||||
|                 <label for="searchbar"><img src="{% static "admin/img/search.svg" %}" alt="Search"></label> | ||||
|                 <input type="text" size="40" name="q" value="" id="searchbar" autofocus=""> | ||||
|                 <input type="submit" value="{% trans 'Search' %}"> | ||||
|             </div> | ||||
|         </form> | ||||
|     </div> | ||||
| </div> | ||||
| {% endblock %} | ||||
|  | ||||
|  | ||||
| {# This whole block is here just to override the `get_admin_log` line so #} | ||||
| {# that the log entries aren't limited to the current user #} | ||||
| {% block sidebar %} | ||||
|   | ||||
							
								
								
									
										37
									
								
								src/documents/templatetags/customisation.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/documents/templatetags/customisation.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| import os | ||||
|  | ||||
| from django import template | ||||
| from django.conf import settings | ||||
| from django.utils.safestring import mark_safe | ||||
|  | ||||
| register = template.Library() | ||||
|  | ||||
|  | ||||
| @register.simple_tag() | ||||
| def custom_css(): | ||||
|     theme_path = os.path.join( | ||||
|         settings.MEDIA_ROOT, | ||||
|         "overrides.css" | ||||
|     ) | ||||
|     if os.path.exists(theme_path): | ||||
|         return mark_safe( | ||||
|             '<link rel="stylesheet" type="text/css" href="{}" />'.format( | ||||
|                 os.path.join(settings.MEDIA_URL, "overrides.css") | ||||
|             ) | ||||
|         ) | ||||
|     return "" | ||||
|  | ||||
|  | ||||
| @register.simple_tag() | ||||
| def custom_js(): | ||||
|     theme_path = os.path.join( | ||||
|         settings.MEDIA_ROOT, | ||||
|         "overrides.js" | ||||
|     ) | ||||
|     if os.path.exists(theme_path): | ||||
|         return mark_safe( | ||||
|             '<script src="{}"></script>'.format( | ||||
|                 os.path.join(settings.MEDIA_URL, "overrides.js") | ||||
|             ) | ||||
|         ) | ||||
|     return "" | ||||
| @@ -2,7 +2,7 @@ from django.utils.deprecation import MiddlewareMixin | ||||
| from .models import User | ||||
|  | ||||
|  | ||||
| class Middleware (MiddlewareMixin): | ||||
| class Middleware(MiddlewareMixin): | ||||
|     """ | ||||
|       This is a dummy authentication middleware class that creates what | ||||
|       is roughly an Anonymous authenticated user so we can disable login | ||||
|   | ||||
| @@ -67,12 +67,12 @@ INSTALLED_APPS = [ | ||||
|     "reminders.apps.RemindersConfig", | ||||
|     "paperless_tesseract.apps.PaperlessTesseractConfig", | ||||
|  | ||||
|     "flat_responsive", | ||||
|     "flat_responsive",  # TODO: Remove as of Django 2.x | ||||
|     "django.contrib.admin", | ||||
|  | ||||
|     "rest_framework", | ||||
|     "crispy_forms", | ||||
|     "django_filters" | ||||
|     "django_filters", | ||||
|  | ||||
| ] | ||||
|  | ||||
|   | ||||
| @@ -1 +1 @@ | ||||
| __version__ = (1, 3, 0) | ||||
| __version__ = (2, 1, 0) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jonas Winkler
					Jonas Winkler