mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Code style changed
This commit is contained in:
parent
8d003a6a85
commit
909586bf25
@ -43,14 +43,12 @@ def select_action(modeladmin, request, queryset, title, action, modelclass, succ
|
||||
media=modeladmin.media,
|
||||
action=action,
|
||||
objects=modelclass.objects.all(),
|
||||
itemname=model_ngettext(modelclass,1)
|
||||
itemname=model_ngettext(modelclass, 1)
|
||||
)
|
||||
|
||||
request.current_app = modeladmin.admin_site.name
|
||||
|
||||
return TemplateResponse(request,
|
||||
"admin/%s/%s/select_object.html" % (app_label, opts.model_name)
|
||||
, context)
|
||||
return TemplateResponse(request, "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):
|
||||
@ -70,6 +68,7 @@ def simple_action(modeladmin, request, queryset, success_message="", document_ac
|
||||
"count": n, "items": model_ngettext(modeladmin.opts, n)
|
||||
}, messages.SUCCESS)
|
||||
|
||||
# Return None to display the change list page again.
|
||||
return None
|
||||
|
||||
|
||||
@ -99,7 +98,7 @@ def set_correspondent_on_selected(modeladmin, request, queryset):
|
||||
action="set_correspondent_on_selected",
|
||||
modelclass=Correspondent,
|
||||
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"
|
||||
|
||||
|
||||
@ -116,7 +115,7 @@ def set_document_type_on_selected(modeladmin, request, queryset):
|
||||
action="set_document_type_on_selected",
|
||||
modelclass=DocumentType,
|
||||
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"
|
||||
|
||||
|
||||
|
@ -96,8 +96,8 @@ class RecentCorrespondentFilter(admin.RelatedFieldListFilter):
|
||||
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)
|
||||
for c in Correspondent.objects.filter(documents__created__gte = date_limit).distinct():
|
||||
lookups.append( (c.id, c.name) )
|
||||
for c in Correspondent.objects.filter(documents__created__gte=date_limit).distinct():
|
||||
lookups.append((c.id, c.name))
|
||||
return lookups
|
||||
|
||||
|
||||
@ -154,6 +154,7 @@ class DocumentTypeAdmin(CommonAdmin):
|
||||
return obj.document_count
|
||||
document_count.admin_order_field = "document_count"
|
||||
|
||||
|
||||
class DocumentAdmin(CommonAdmin):
|
||||
|
||||
class Media:
|
||||
@ -200,10 +201,10 @@ class DocumentAdmin(CommonAdmin):
|
||||
extra_context['download_url'] = doc.download_url
|
||||
extra_context['file_type'] = doc.file_type
|
||||
if self.document_queue and object_id and int(object_id) in self.document_queue:
|
||||
#There is a queue of documents
|
||||
# There is a queue of documents
|
||||
current_index = self.document_queue.index(int(object_id))
|
||||
if current_index < len(self.document_queue) - 1:
|
||||
#... and there are still documents in the queue
|
||||
# ... and there are still documents in the queue
|
||||
extra_context['next_object'] = self.document_queue[current_index + 1]
|
||||
return super(DocumentAdmin, self).change_view(
|
||||
request, object_id, form_url, extra_context=extra_context,
|
||||
|
@ -127,7 +127,7 @@ class DocumentClassifier(object):
|
||||
def classify_document(self, document, classify_correspondent=False, classify_document_type=False, classify_tags=False, replace_tags=False):
|
||||
X = self.data_vectorizer.transform([preprocess_content(document.content)])
|
||||
|
||||
update_fields=()
|
||||
update_fields = ()
|
||||
|
||||
if classify_correspondent and self.correspondent_classifier is not None:
|
||||
y_correspondent = self.correspondent_classifier.predict(X)
|
||||
|
@ -3,7 +3,7 @@ import os.path
|
||||
import pickle
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from documents.classifier import DocumentClassifier
|
||||
from documents.classifier import DocumentClassifier
|
||||
from paperless import settings
|
||||
from ...mixins import Renderable
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user