Add a "Check now" button to the interval sources for testing.
Ref: GitLab issue #313 Thanks to @gersilex for the suggestion. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
Mayan EDMS v2.2 release notes
|
||||
=============================
|
||||
|
||||
Released: XX, 2017
|
||||
Released: April XX, 2017
|
||||
|
||||
What's new
|
||||
==========
|
||||
@@ -61,6 +61,7 @@ resolved to '/api/documents/<pk>/pages/<page_pk>/pages'.
|
||||
|
||||
Other changes
|
||||
-------------
|
||||
- Add "Check now" button to interval sources.
|
||||
- Remove the installation app
|
||||
- Add support for page search
|
||||
- Remove recent searches feature
|
||||
|
||||
@@ -23,11 +23,11 @@ from .handlers import (
|
||||
)
|
||||
from .links import (
|
||||
link_document_create_multiple, link_setup_sources,
|
||||
link_setup_source_create_imap_email, link_setup_source_create_pop3_email,
|
||||
link_setup_source_create_watch_folder, link_setup_source_create_webform,
|
||||
link_setup_source_create_staging_folder, link_setup_source_delete,
|
||||
link_setup_source_edit, link_setup_source_logs, link_staging_file_delete,
|
||||
link_upload_version
|
||||
link_setup_source_check_now, link_setup_source_create_imap_email,
|
||||
link_setup_source_create_pop3_email, link_setup_source_create_watch_folder,
|
||||
link_setup_source_create_webform, link_setup_source_create_staging_folder,
|
||||
link_setup_source_delete, link_setup_source_edit, link_setup_source_logs,
|
||||
link_staging_file_delete, link_upload_version
|
||||
)
|
||||
from .widgets import StagingFileThumbnailWidget
|
||||
|
||||
@@ -126,6 +126,10 @@ class SourcesApp(MayanAppConfig):
|
||||
menu_object.bind_links(
|
||||
links=(link_staging_file_delete,), sources=(StagingFile,)
|
||||
)
|
||||
menu_object.bind_links(
|
||||
links=(link_setup_source_check_now,),
|
||||
sources=(IMAPEmail, POP3Email, WatchFolderSource,)
|
||||
)
|
||||
menu_secondary.bind_links(
|
||||
links=(
|
||||
link_setup_sources, link_setup_source_create_webform,
|
||||
|
||||
@@ -87,3 +87,7 @@ link_setup_source_logs = Link(
|
||||
text=_('Logs'), view='sources:setup_source_logs',
|
||||
args=('resolved_object.pk',), permissions=(permission_sources_setup_view,)
|
||||
)
|
||||
link_setup_source_check_now = Link(
|
||||
text=_('Check now'), view='sources:setup_source_check',
|
||||
args=('resolved_object.pk',), permissions=(permission_sources_setup_view,)
|
||||
)
|
||||
|
||||
@@ -7,9 +7,9 @@ from .api_views import (
|
||||
APIStagingSourceListView, APIStagingSourceView
|
||||
)
|
||||
from .views import (
|
||||
SetupSourceCreateView, SetupSourceDeleteView, SetupSourceEditView,
|
||||
SetupSourceListView, SourceLogListView, StagingFileDeleteView,
|
||||
UploadInteractiveVersionView, UploadInteractiveView
|
||||
SetupSourceCheckView, SetupSourceCreateView, SetupSourceDeleteView,
|
||||
SetupSourceEditView, SetupSourceListView, SourceLogListView,
|
||||
StagingFileDeleteView, UploadInteractiveVersionView, UploadInteractiveView
|
||||
)
|
||||
from .wizards import DocumentCreateWizard
|
||||
|
||||
@@ -59,6 +59,10 @@ urlpatterns = [
|
||||
r'^setup/(?P<source_type>\w+)/create/$',
|
||||
SetupSourceCreateView.as_view(), name='setup_source_create'
|
||||
),
|
||||
url(
|
||||
r'^setup/(?P<pk>\d+)/check/$', SetupSourceCheckView.as_view(),
|
||||
name='setup_source_check'
|
||||
),
|
||||
|
||||
# Document create views
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ from common import menu_facet
|
||||
from common.models import SharedUploadedFile
|
||||
from common.utils import encapsulate
|
||||
from common.views import (
|
||||
MultiFormView, SingleObjectCreateView, SingleObjectDeleteView,
|
||||
SingleObjectEditView, SingleObjectListView
|
||||
ConfirmView, MultiFormView, SingleObjectCreateView,
|
||||
SingleObjectDeleteView, SingleObjectEditView, SingleObjectListView
|
||||
)
|
||||
from common.widgets import two_state_template
|
||||
from documents.models import DocumentType, Document
|
||||
@@ -41,7 +41,7 @@ from .permissions import (
|
||||
permission_sources_setup_edit, permission_sources_setup_view,
|
||||
permission_staging_file_delete
|
||||
)
|
||||
from .tasks import task_source_handle_upload
|
||||
from .tasks import task_check_interval_source, task_source_handle_upload
|
||||
from .utils import get_class, get_form_class, get_upload_form_class
|
||||
|
||||
|
||||
@@ -435,6 +435,32 @@ class StagingFileDeleteView(SingleObjectDeleteView):
|
||||
|
||||
|
||||
# Setup views
|
||||
class SetupSourceCheckView(ConfirmView):
|
||||
"""
|
||||
Trigger the task_check_interval_source task for a given source to
|
||||
test/debug their configuration irrespective of the schedule task setup.
|
||||
"""
|
||||
view_permission = permission_sources_setup_view
|
||||
|
||||
def get_extra_context(self):
|
||||
return {
|
||||
'object': self.get_object(),
|
||||
'title': _('Trigger check for source "%s"?') % self.get_object(),
|
||||
}
|
||||
|
||||
def get_object(self):
|
||||
return get_object_or_404(Source.objects.select_subclasses(), pk=self.kwargs['pk'])
|
||||
|
||||
def view_action(self):
|
||||
task_check_interval_source.apply_async(
|
||||
kwargs={
|
||||
'source_id': self.get_object().pk
|
||||
}
|
||||
)
|
||||
|
||||
messages.success(self.request, _('Source check queued.'))
|
||||
|
||||
|
||||
class SetupSourceCreateView(SingleObjectCreateView):
|
||||
post_action_redirect = reverse_lazy('sources:setup_source_list')
|
||||
view_permission = permission_sources_setup_create
|
||||
@@ -490,9 +516,6 @@ class SetupSourceEditView(SingleObjectEditView):
|
||||
|
||||
|
||||
class SetupSourceListView(SingleObjectListView):
|
||||
view_permission = permission_sources_setup_view
|
||||
queryset = Source.objects.select_subclasses()
|
||||
|
||||
extra_context = {
|
||||
'extra_columns': (
|
||||
{
|
||||
@@ -509,3 +532,5 @@ class SetupSourceListView(SingleObjectListView):
|
||||
'hide_link': True,
|
||||
'title': _('Sources'),
|
||||
}
|
||||
queryset = Source.objects.select_subclasses()
|
||||
view_permission = permission_sources_setup_view
|
||||
|
||||
Reference in New Issue
Block a user