Skip to content

Commit

Permalink
Remove unused WorkflowStatus view, urlpattern, and workflow-status.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Stormheg authored and laymonage committed Aug 3, 2023
1 parent 801eccc commit 3be4e68
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 105 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Changelog
* Maintenance: Update Eslint, Prettier & Jest npm packages (LB (Ben) Johnston)
* Maintenance: Add npm scripts for TypeScript checks and formatting SCSS files (LB (Ben) Johnston)
* Maintenance: Run tests in parallel in some of the CI setup (Sage Abdullah)
* Maintenance: Remove unused WorkflowStatus view, urlpattern, and workflow-status.js (Storm Heg)


5.1 (01.08.2023)
Expand Down
13 changes: 0 additions & 13 deletions client/src/entrypoints/admin/workflow-status.js

This file was deleted.

1 change: 0 additions & 1 deletion client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ module.exports = function exports(env, argv) {
'userbar',
'wagtailadmin',
'workflow-action',
'workflow-status',
'bulk-actions',
],
'images': [
Expand Down
1 change: 1 addition & 0 deletions docs/releases/5.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ depth: 1
* Update Eslint, Prettier & Jest npm packages (LB (Ben) Johnston)
* Add npm scripts for TypeScript checks and formatting SCSS files (LB (Ben) Johnston)
* Run tests in parallel in some of the CI setup (Sage Abdullah)
* Remove unused WorkflowStatus view, urlpattern, and workflow-status.js (Storm Heg)


## Upgrade considerations - changes affecting all projects
Expand Down
1 change: 0 additions & 1 deletion wagtail/admin/templates/wagtailadmin/pages/_editor_js.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@
<script src="{% versioned_static 'wagtailadmin/js/vendor/xregexp.min.js' %}"></script>
<script src="{% versioned_static 'wagtailadmin/js/vendor/urlify.js' %}"></script>
<script src="{% versioned_static 'wagtailadmin/js/workflow-action.js' %}"></script>
<script src="{% versioned_static 'wagtailadmin/js/workflow-status.js' %}"></script>
{% hook_output 'insert_editor_js' %}
5 changes: 0 additions & 5 deletions wagtail/admin/urls/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@
workflow.PreviewRevisionForTask.as_view(),
name="workflow_preview",
),
path(
"workflow/status/<int:page_id>/",
workflow.WorkflowStatus.as_view(),
name="workflow_status",
),
path(
"moderation/<int:revision_id>/approve/",
moderation.approve_moderation,
Expand Down
36 changes: 0 additions & 36 deletions wagtail/admin/views/generic/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,42 +214,6 @@ def get_context_data(self, **kwargs):
}


class WorkflowStatus(BaseObjectMixin, View):
workflow_history_url_name = None
revisions_compare_url_name = None

def setup(self, request, *args, **kwargs):
super().setup(request, *args, **kwargs)
self.workflow_state = self.object.current_workflow_state

def dispatch(self, request, *args, **kwargs):
if not self.workflow_state:
raise PermissionDenied
return super().dispatch(request, *args, **kwargs)

def get_workflow_history_url(self):
return reverse(self.workflow_history_url_name, args=(quote(self.object.pk),))

def get(self, request, *args, **kwargs):
return render_modal_workflow(
request,
"wagtailadmin/workflows/workflow_status.html",
None,
self.get_context_data(),
)

def get_context_data(self, **kwargs):
return {
"object": self.object,
"workflow_state": self.workflow_state,
"current_task_state": self.workflow_state.current_task_state,
"workflow_tasks": self.workflow_state.all_tasks_with_state(),
"workflow_history_url": self.get_workflow_history_url(),
"revisions_compare_url_name": self.revisions_compare_url_name,
**kwargs,
}


class PreviewRevisionForTask(BaseObjectMixin, View):
def setup(self, request, *args, task_id, **kwargs):
super().setup(request, *args, **kwargs)
Expand Down
8 changes: 0 additions & 8 deletions wagtail/admin/views/pages/workflow.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _

from wagtail.admin import messages
from wagtail.admin.auth import user_has_any_page_permission, user_passes_test
from wagtail.admin.utils import get_latest_str
from wagtail.admin.views.generic import workflow
from wagtail.models import Page
Expand Down Expand Up @@ -42,12 +40,6 @@ class ConfirmWorkflowCancellation(
template_name = "wagtailadmin/pages/confirm_workflow_cancellation.html"


@method_decorator(user_passes_test(user_has_any_page_permission), name="dispatch")
class WorkflowStatus(WorkflowPageViewMixin, workflow.WorkflowStatus):
workflow_history_url_name = "wagtailadmin_pages:workflow_history"
revisions_compare_url_name = "wagtailadmin_pages:revisions_compare"


class PreviewRevisionForTask(WorkflowPageViewMixin, workflow.PreviewRevisionForTask):
def add_error_message(self):
messages.error(
Expand Down
20 changes: 0 additions & 20 deletions wagtail/snippets/tests/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,26 +283,6 @@ def test_get_detail_with_bad_permissions(self):
self.assertRedirects(response, reverse("wagtailadmin_home"))


class TestWorkflowStatus(BaseWorkflowsTestCase):
def setUp(self):
super().setUp()
self.object.text = "Edited!"
self.object.save_revision()
self.workflow_state = self.workflow.start(self.object, self.user)

def test_get_workflow_status(self):
response = self.client.get(self.get_url("workflow_status"))
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/workflows/workflow_status.html")

# Should show link to workflow history page
self.assertContains(response, self.get_url("workflow_history"))

# Should show the currently in progress workflow
self.assertContains(response, "Moderators approval")
self.assertContains(response, "In progress")


class TestConfirmWorkflowCancellation(BaseWorkflowsTestCase):
def setUp(self):
super().setUp()
Expand Down
21 changes: 0 additions & 21 deletions wagtail/snippets/views/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,6 @@ class ConfirmWorkflowCancellationView(workflow.ConfirmWorkflowCancellation):
pass


class WorkflowStatusView(PermissionCheckedMixin, workflow.WorkflowStatus):
permission_required = "change"


class WorkflowPreviewView(workflow.PreviewRevisionForTask):
pass

Expand Down Expand Up @@ -787,9 +783,6 @@ class SnippetViewSet(ModelViewSet):
#: The view class to use for confirming the cancellation of a workflow; must be a subclass of ``wagtail.snippet.views.snippets.ConfirmWorkflowCancellationView``.
confirm_workflow_cancellation_view_class = ConfirmWorkflowCancellationView

#: The view class to use for rendering the workflow status modal; must be a subclass of ``wagtail.snippet.views.snippets.WorkflowStatusView``.
workflow_status_view_class = WorkflowStatusView

#: The view class to use for previewing a revision for a specific task; must be a subclass of ``wagtail.snippet.views.snippets.WorkflowPreviewView``.
workflow_preview_view_class = WorkflowPreviewView

Expand Down Expand Up @@ -1152,15 +1145,6 @@ def collect_workflow_action_data_view(self):
def confirm_workflow_cancellation_view(self):
return self.confirm_workflow_cancellation_view_class.as_view(model=self.model)

@property
def workflow_status_view(self):
return self.workflow_status_view_class.as_view(
model=self.model,
permission_policy=self.permission_policy,
workflow_history_url_name=self.get_url_name("workflow_history"),
revisions_compare_url_name=self.get_url_name("revisions_compare"),
)

@property
def workflow_preview_view(self):
return self.workflow_preview_view_class.as_view(model=self.model)
Expand Down Expand Up @@ -1479,11 +1463,6 @@ def get_urlpatterns(self):
self.confirm_workflow_cancellation_view,
name="confirm_workflow_cancellation",
),
path(
"workflow/status/<str:pk>/",
self.workflow_status_view,
name="workflow_status",
),
path(
"workflow_history/<str:pk>/",
self.workflow_history_view,
Expand Down

0 comments on commit 3be4e68

Please sign in to comment.