Update the file caching app

- Add view to list available caches.
- Add links to view and purge caches.
- Add permissions.
- Add events.
- Add purge task.
- Remove document image clear link and view.
  This is now handled by the file caching app.

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-07-25 02:24:33 -04:00
parent 9315776926
commit 88bc29e4d7
19 changed files with 309 additions and 56 deletions
+2 -2
View File
@@ -47,7 +47,7 @@ from .handlers import (
handler_remove_empty_duplicates_lists, handler_scan_duplicates_for
)
from .links import (
link_clear_image_cache, link_document_clear_transformations,
link_document_clear_transformations,
link_document_clone_transformations, link_document_delete,
link_document_document_type_edit, link_document_download,
link_document_duplicates_list, link_document_edit,
@@ -377,7 +377,7 @@ class DocumentsApp(MayanAppConfig):
menu_setup.bind_links(links=(link_document_type_setup,))
menu_tools.bind_links(
links=(link_clear_image_cache, link_duplicated_document_scan)
links=(link_duplicated_document_scan,)
)
# Document type links
-2
View File
@@ -12,8 +12,6 @@ icon_document_type = Icon(
icon_menu_documents = Icon(driver_name='fontawesome', symbol='book')
icon_clear_image_cache = Icon(driver_name='fontawesome', symbol='file-image')
icon_dashboard_document_types = icon_document_type
icon_dashboard_documents_in_trash = Icon(
driver_name='fontawesome', symbol='trash-alt'
+1 -11
View File
@@ -8,7 +8,7 @@ from mayan.apps.converter.permissions import (
from mayan.apps.navigation.classes import Link
from .icons import (
icon_clear_image_cache, icon_document_list_recent_access,
icon_document_list_recent_access,
icon_recent_added_document_list, icon_document_page_navigation_first,
icon_document_page_navigation_last, icon_document_page_navigation_next,
icon_document_page_navigation_previous, icon_document_page_return,
@@ -264,16 +264,6 @@ link_document_list_deleted = Link(
text=_('Trash can'), view='documents:document_list_deleted'
)
# Tools
link_clear_image_cache = Link(
icon_class=icon_clear_image_cache,
description=_(
'Clear the graphics representations used to speed up the documents\' '
'display and interactive transformations results.'
), permissions=(permission_document_tools,),
text=_('Clear document image cache'),
view='documents:document_clear_image_cache'
)
link_trash_can_empty = Link(
permissions=(permission_empty_trash,), text=_('Empty trash'),
view='documents:trash_can_empty'
-4
View File
@@ -61,10 +61,6 @@ queue_documents_periodic.add_task_type(
schedule=timedelta(seconds=DELETE_STALE_STUBS_INTERVAL),
)
queue_tools.add_task_type(
dotted_path='mayan.apps.documents.tasks.task_clear_image_cache',
label=_('Clear image cache')
)
queue_tools.add_task_type(
dotted_path='mayan.apps.documents.tasks.task_scan_duplicates_all',
label=_('Duplicated document scan')
-11
View File
@@ -41,17 +41,6 @@ def task_check_trash_periods():
DocumentType.objects.check_trash_periods()
@app.task(ignore_result=True)
def task_clear_image_cache():
Document = apps.get_model(
app_label='documents', model_name='Document'
)
logger.info('Starting document cache invalidation')
Document.objects.invalidate_cache()
logger.info('Finished document cache invalidation')
@app.task(ignore_result=True)
def task_delete_document(trashed_document_id):
DeletedDocument = apps.get_model(
+1 -5
View File
@@ -13,7 +13,7 @@ from .api_views import (
APIRecentDocumentListView
)
from .views import (
ClearImageCacheView, DocumentDocumentTypeEditView, DocumentDownloadFormView,
DocumentDocumentTypeEditView, DocumentDownloadFormView,
DocumentDownloadView, DocumentDuplicatesListView, DocumentEditView,
DocumentListView, DocumentPageListView, DocumentPageNavigationFirst,
DocumentPageNavigationLast, DocumentPageNavigationNext,
@@ -272,10 +272,6 @@ urlpatterns = [
view=DocumentTransformationsClearView.as_view(),
name='document_multiple_clear_transformations'
),
url(
regex=r'^cache/clear/$', view=ClearImageCacheView.as_view(),
name='document_clear_image_cache'
),
url(
regex=r'^page/(?P<pk>\d+)/$', view=DocumentPageView.as_view(),
name='document_page_view'
+2 -15
View File
@@ -8,25 +8,12 @@ from django.utils.translation import ugettext_lazy as _
from mayan.apps.common.generics import ConfirmView
from ..permissions import permission_document_tools
from ..tasks import task_clear_image_cache, task_scan_duplicates_all
from ..tasks import task_scan_duplicates_all
__all__ = ('ClearImageCacheView', 'ScanDuplicatedDocuments')
__all__ = ('ScanDuplicatedDocuments',)
logger = logging.getLogger(__name__)
class ClearImageCacheView(ConfirmView):
extra_context = {
'title': _('Clear the document image cache?')
}
view_permission = permission_document_tools
def view_action(self):
task_clear_image_cache.apply_async()
messages.success(
self.request, _('Document cache clearing queued successfully.')
)
class ScanDuplicatedDocuments(ConfirmView):
extra_context = {
'title': _('Scan for duplicated documents?')