openlibhums / janeway

A web-based platform for publishing journals, preprints, conference proceedings, and books
https://janeway.systems/
GNU Affero General Public License v3.0
174 stars 65 forks source link

It is possible to remove a WorkflowElement from a journal while articles are still in that workflow stage #766

Closed mdlincoln closed 5 years ago

mdlincoln commented 5 years ago

A bit of an edge-case bug, but it's possible to remove a workflow element while an article is still in that stage of the workflow, and this then causes an error when trying to move any of those articles to the next stage of the workflow.

For example, I tried submitting an article, and then while it was in the Review stage, I removed Review and Copyediting from the workflow. Although I could access the article by going to the "Articles in Review" listing, when I went to hit "Accept Article" I get the following:

Request Method: | POST
-- | --
http://localhost:8000/cmesh/review/article/10/move/accept/
1.11.18
DoesNotExist
WorkflowElement matching query does not exist.
/usr/local/lib/python3.5/site-packages/django/db/models/query.py in get, line 380

The article had been shifted to copyediting even though that was not part of the assigned workflow.

Environment:

Request Method: POST
Request URL: http://localhost:8000/cmesh/review/article/10/move/accept/

Django Version: 1.11.18
Python Version: 3.5.4
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'cms',
 'core',
 'copyediting',
 'cron',
 'events',
 'identifiers',
 'journal',
 'metrics',
 'comms',
 'preprint',
 'press',
 'production',
 'proofing',
 'review',
 'reports',
 'security',
 'submission',
 'transform',
 'utils',
 'install',
 'django_summernote',
 'markdown_deux',
 'hvad',
 'raven.contrib.django.raven_compat',
 'bootstrap4',
 'rest_framework',
 'foundationform',
 'materialize',
 'plugins.archive_plugin',
 'plugins.back_content',
 'plugins.pandoc_plugin',
 'core.homepage_elements.html',
 'core.homepage_elements.about',
 'core.homepage_elements.carousel',
 'core.homepage_elements.journals',
 'core.homepage_elements.news',
 'core.homepage_elements.issue',
 'core.homepage_elements.preprints',
 'core.homepage_elements.featured',
 'snowpenguin.django.recaptcha2']
Installed Middleware:
('raven.contrib.django.middleware.SentryMiddleware',
 'utils.middleware.TimeMonitoring',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'core.middleware.SiteSettingsMiddleware',
 'utils.template_override_middleware.ThemeEngineMiddleware',
 'core.middleware.MaintenanceModeMiddleware',
 'cron.middleware.CronMiddleware',
 'core.middleware.CounterCookieMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'core.middleware.PressMiddleware',
 'core.middleware.GlobalRequestMiddleware',
 'django.middleware.gzip.GZipMiddleware')

Traceback:

File "/usr/local/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py" in _legacy_get_response
  249.             response = self._get_response(request)

File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/vol/janeway/src/security/decorators.py" in wrapper
  130.         return func(request, *args, **kwargs)

File "/vol/janeway/src/security/decorators.py" in wrapper
  53.         return func(request, *args, **kwargs)

File "/vol/janeway/src/security/decorators.py" in wrapper
  96.             return func(request, *args, **kwargs)

File "/vol/janeway/src/review/views.py" in review_decision
  1152.                                                   **workflow_kwargs)

File "/vol/janeway/src/events/logic.py" in raise_event
  241.             event_return = [func(**kwargs) for func in Events._hooks[event_name]]

File "/vol/janeway/src/events/logic.py" in 
  241.             event_return = [func(**kwargs) for func in Events._hooks[event_name]]

File "/vol/janeway/src/core/workflow.py" in workflow_element_complete
  29.     return workflow_next(handshake_url, request, article, switch_stage)

File "/vol/janeway/src/core/workflow.py" in workflow_next
  49.     current_element = workflow.elements.get(handshake_url=handshake_url)

File "/usr/local/lib/python3.5/site-packages/django/db/models/manager.py" in manager_method
  85.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/usr/local/lib/python3.5/site-packages/django/db/models/query.py" in get
  380.                 self.model._meta.object_name

Exception Type: DoesNotExist at /review/article/10/move/accept/
Exception Value: WorkflowElement matching query does not exist.
ajrbyers commented 5 years ago

Cheers @mdlincoln I've added this to 1.3.3 for fixing.

ajrbyers commented 5 years ago

Adding this to Trello, please ignore.