From 338e032fb116863e156f3943da4962f3c406543f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= <zebuline@entrouvert.com>
Date: Fri, 19 Mar 2021 14:41:24 +0100
Subject: [PATCH 2/2] misc: apply isort (#52224)

---
 setup.py                                      |   9 +-
 tests/admin_pages/test_all.py                 |   8 +-
 tests/admin_pages/test_api_access.py          |   7 +-
 tests/admin_pages/test_block.py               |  14 +-
 tests/admin_pages/test_card.py                |  13 +-
 tests/admin_pages/test_carddefcategory.py     |   7 +-
 tests/admin_pages/test_category.py            |   7 +-
 tests/admin_pages/test_datasource.py          |  21 ++-
 tests/admin_pages/test_form.py                |  23 +--
 tests/admin_pages/test_logged_errors.py       |   5 +-
 tests/admin_pages/test_role.py                |   7 +-
 tests/admin_pages/test_settings.py            |  28 ++--
 tests/admin_pages/test_user.py                |  14 +-
 tests/admin_pages/test_workflow.py            |  42 +++---
 tests/admin_pages/test_wscall.py              |   5 +-
 tests/api/test_access.py                      |  11 +-
 tests/api/test_all.py                         |   4 +-
 tests/api/test_carddef.py                     |  10 +-
 tests/api/test_category.py                    |   4 +-
 tests/api/test_custom_view.py                 |   4 +-
 tests/api/test_formdata.py                    |   9 +-
 tests/api/test_formdef.py                     |  10 +-
 tests/api/test_user.py                        |   7 +-
 tests/api/test_utils.py                       |   6 +-
 tests/api/test_workflow.py                    |   4 +-
 tests/backoffice_pages/test_all.py            |  56 ++++----
 tests/backoffice_pages/test_carddata.py       |   8 +-
 tests/backoffice_pages/test_custom_view.py    |  16 ++-
 tests/backoffice_pages/test_export.py         |  11 +-
 tests/backoffice_pages/test_submission.py     |  11 +-
 tests/conftest.py                             |   5 +-
 tests/form_pages/test_all.py                  |  63 ++++----
 tests/form_pages/test_block.py                |  16 ++-
 tests/form_pages/test_formdata.py             |  27 ++--
 tests/test_auth_pages.py                      |   5 +-
 tests/test_carddef.py                         |  15 +-
 tests/test_categories.py                      |   7 +-
 tests/test_convert_to_sql.py                  |  13 +-
 tests/test_ctl.py                             |  39 ++---
 tests/test_datasource.py                      |  23 +--
 tests/test_datasource_chrono.py               |  14 +-
 tests/test_ezt.py                             |  22 +--
 tests/test_fc_auth.py                         |  10 +-
 tests/test_fields.py                          |  15 +-
 tests/test_formdata.py                        |  35 +++--
 tests/test_formdef.py                         |  32 +++--
 tests/test_formdef_import.py                  |  14 +-
 tests/test_hobo.py                            |  13 +-
 tests/test_hobo_notify.py                     |  11 +-
 tests/test_mail_templates.py                  |  18 ++-
 tests/test_misc.py                            |  60 ++++----
 tests/test_prefill.py                         |   8 +-
 tests/test_publisher.py                       |  15 +-
 tests/test_register.py                        |   8 +-
 tests/test_role.py                            |   6 +-
 tests/test_rootdirectory.py                   |  16 +--
 tests/test_saml2utils.py                      |   3 +-
 tests/test_saml_auth.py                       |  23 +--
 tests/test_sessions.py                        |  14 +-
 tests/test_snapshots.py                       |  15 +-
 tests/test_sql.py                             |  23 +--
 tests/test_storage.py                         |  12 +-
 tests/test_templates.py                       |  14 +-
 tests/test_texts.py                           |   9 +-
 tests/test_tracking_code.py                   |   4 +-
 tests/test_upload_storage.py                  |  16 ++-
 tests/test_users.py                           |   6 +-
 tests/test_variadic_url.py                    |   6 +-
 tests/test_widgets.py                         |  11 +-
 tests/test_workflow_import.py                 |  55 +++----
 tests/test_workflows.py                       | 136 +++++++++---------
 tests/test_wscall.py                          |   6 +-
 tests/utilities.py                            |  30 ++--
 wcs/__init__.py                               |   6 +-
 wcs/admin/api_access.py                       |  17 ++-
 wcs/admin/blocks.py                           |  28 ++--
 wcs/admin/categories.py                       |  14 +-
 wcs/admin/data_sources.py                     |  37 ++---
 wcs/admin/fields.py                           |  18 +--
 wcs/admin/forms.py                            |  53 ++++---
 wcs/admin/logged_errors.py                    |  20 ++-
 wcs/admin/mail_templates.py                   |  33 +++--
 wcs/admin/roles.py                            |  12 +-
 wcs/admin/root.py                             |   3 +-
 wcs/admin/settings.py                         |  56 ++++----
 wcs/admin/users.py                            |  26 ++--
 wcs/admin/utils.py                            |  10 +-
 wcs/admin/workflows.py                        |  36 ++---
 wcs/admin/wscalls.py                          |  18 ++-
 wcs/api.py                                    |  53 ++++---
 wcs/api_utils.py                              |  22 +--
 wcs/backoffice/cards.py                       |  30 ++--
 wcs/backoffice/data_management.py             |  32 +++--
 wcs/backoffice/management.py                  |  89 ++++++------
 wcs/backoffice/root.py                        |  38 ++---
 wcs/backoffice/snapshots.py                   |  22 ++-
 wcs/backoffice/studio.py                      |   3 +-
 wcs/backoffice/submission.py                  |  26 ++--
 wcs/blocks.py                                 |  18 ++-
 wcs/cache.py                                  |   3 +-
 wcs/carddef.py                                |  19 ++-
 wcs/categories.py                             |   2 +-
 wcs/compat.py                                 |  18 +--
 wcs/conditions.py                             |  10 +-
 wcs/context_processors.py                     |   5 +-
 wcs/ctl/backup.py                             |   5 +-
 wcs/ctl/check_hobos.py                        |  18 ++-
 wcs/ctl/delete_tenant.py                      |   8 +-
 wcs/ctl/hobo_notify.py                        |   8 +-
 wcs/ctl/management/commands/__init__.py       |   3 +-
 wcs/ctl/management/commands/convert_to_sql.py |   7 +-
 wcs/ctl/management/commands/import_site.py    |   2 +-
 wcs/ctl/management/commands/runjob.py         |   3 +-
 wcs/ctl/management/commands/shell.py          |   1 +
 wcs/ctl/management/commands/trigger_jumps.py  |   4 +-
 wcs/ctl/rebuild_indexes.py                    |   3 +-
 wcs/ctl/restore.py                            |   5 +-
 wcs/ctl/runscript.py                          |   5 +-
 wcs/ctl/wipe_data.py                          |   3 +-
 wcs/custom_views.py                           |   5 +-
 wcs/data_sources.py                           |  23 +--
 wcs/fields.py                                 |  54 +++----
 wcs/formdata.py                               |  22 ++-
 wcs/formdef.py                                |  42 +++---
 wcs/forms/actions.py                          |   8 +-
 wcs/forms/backoffice.py                       |  15 +-
 wcs/forms/common.py                           |  27 ++--
 wcs/forms/preview.py                          |   9 +-
 wcs/forms/root.py                             |  46 +++---
 wcs/forms/workflows.py                        |  13 +-
 wcs/logged_errors.py                          |   3 +-
 wcs/mail_templates.py                         |   3 +-
 wcs/middleware.py                             |  10 +-
 wcs/monkeypatch.py                            |   1 -
 wcs/myspace.py                                |   4 +-
 wcs/portfolio.py                              |  28 ++--
 wcs/publisher.py                              |  28 ++--
 wcs/qommon/__init__.py                        |   5 +-
 wcs/qommon/admin/emails.py                    |  10 +-
 wcs/qommon/admin/logger.py                    |  12 +-
 wcs/qommon/admin/menu.py                      |  12 +-
 wcs/qommon/admin/settings.py                  |  11 +-
 wcs/qommon/admin/texts.py                     |  12 +-
 wcs/qommon/afterjobs.py                       |   7 +-
 wcs/qommon/backoffice/listing.py              |   7 +-
 wcs/qommon/backoffice/menu.py                 |  10 +-
 wcs/qommon/backoffice/root.py                 |   3 +-
 wcs/qommon/ctl.py                             |   5 +-
 wcs/qommon/emails.py                          |  15 +-
 wcs/qommon/errors.py                          |   8 +-
 wcs/qommon/evalutils.py                       |   1 +
 wcs/qommon/ezt.py                             |   5 +-
 wcs/qommon/form.py                            |  56 +++++---
 wcs/qommon/http_request.py                    |   6 +-
 wcs/qommon/http_response.py                   |   6 +-
 wcs/qommon/humantime.py                       |   4 +-
 wcs/qommon/ident/franceconnect.py             |  41 +++---
 wcs/qommon/ident/idp.py                       |  37 ++---
 wcs/qommon/ident/password.py                  |  45 +++---
 wcs/qommon/ident/password_accounts.py         |   7 +-
 wcs/qommon/logger.py                          |   4 +-
 .../management/commands/collectstatic.py      |   1 +
 wcs/qommon/management/commands/cron.py        |   9 +-
 wcs/qommon/management/commands/migrate.py     |   3 +-
 wcs/qommon/misc.py                            |  33 +++--
 wcs/qommon/myspace.py                         |  20 ++-
 wcs/qommon/ods.py                             |   7 +-
 wcs/qommon/pages.py                           |   3 +-
 wcs/qommon/publisher.py                       |  52 ++++---
 wcs/qommon/saml2.py                           |  23 +--
 wcs/qommon/saml2utils.py                      |   3 +-
 wcs/qommon/sessions.py                        |  18 +--
 wcs/qommon/sms.py                             |  11 +-
 wcs/qommon/storage.py                         |  12 +-
 wcs/qommon/substitution.py                    |   8 +-
 wcs/qommon/template.py                        |  34 +++--
 wcs/qommon/template_utils.py                  |   8 +-
 wcs/qommon/templatetags/qommon.py             |  18 ++-
 wcs/qommon/tokens.py                          |   2 +-
 wcs/qommon/upload_storage.py                  |   9 +-
 wcs/qommon/vendor/locket.py                   |   2 +-
 wcs/qommon/x509utils.py                       |   4 +-
 wcs/qommon/xml_storage.py                     |   3 +-
 wcs/roles.py                                  |   3 +-
 wcs/root.py                                   |  41 +++---
 wcs/snapshots.py                              |   7 +-
 wcs/sql.py                                    |  39 ++---
 wcs/tracking_code.py                          |   3 +-
 wcs/urls.py                                   |   2 +-
 wcs/users.py                                  |  12 +-
 wcs/utils.py                                  |   3 +-
 wcs/variables.py                              |  21 +--
 wcs/views.py                                  |   6 +-
 wcs/wf/aggregation_email.py                   |  14 +-
 wcs/wf/anonymise.py                           |   3 +-
 wcs/wf/attachment.py                          |  14 +-
 wcs/wf/backoffice_fields.py                   |  19 +--
 wcs/wf/create_carddata.py                     |   8 +-
 wcs/wf/create_formdata.py                     |  34 ++---
 wcs/wf/criticality.py                         |   7 +-
 wcs/wf/dispatch.py                            |  11 +-
 wcs/wf/edit_carddata.py                       |   6 +-
 wcs/wf/export_to_model.py                     |  72 +++++-----
 wcs/wf/external_workflow.py                   |  16 ++-
 wcs/wf/form.py                                |  18 +--
 wcs/wf/geolocate.py                           |  18 ++-
 wcs/wf/jump.py                                |  30 ++--
 wcs/wf/notification.py                        |  12 +-
 wcs/wf/profile.py                             |  30 ++--
 wcs/wf/redirect_to_url.py                     |   7 +-
 wcs/wf/register_comment.py                    |  22 +--
 wcs/wf/remove.py                              |  13 +-
 wcs/wf/resubmit.py                            |  16 ++-
 wcs/wf/roles.py                               |  23 ++-
 wcs/wf/timeout_jump.py                        |   4 +-
 wcs/wf/wscall.py                              |  28 ++--
 wcs/workflows.py                              |  54 ++++---
 wcs/wscalls.py                                |  34 +++--
 218 files changed, 2198 insertions(+), 1531 deletions(-)

diff --git a/setup.py b/setup.py
index e1cf07ed..f4fbefab 100644
--- a/setup.py
+++ b/setup.py
@@ -3,14 +3,15 @@
 import os
 import subprocess
 import sys
-
 from distutils.cmd import Command
-from distutils.errors import CompileError
-from distutils.spawn import find_executable
 from distutils.command.build import build as _build
 from distutils.command.sdist import sdist
+from distutils.errors import CompileError
+from distutils.spawn import find_executable
+
+from setuptools import find_packages
+from setuptools import setup
 from setuptools.command.install_lib import install_lib as _install_lib
-from setuptools import setup, find_packages
 
 local_cfg = None
 if os.path.exists('wcs/wcs_cfg.py'):
diff --git a/tests/admin_pages/test_all.py b/tests/admin_pages/test_all.py
index 70a5213f..600ecc66 100644
--- a/tests/admin_pages/test_all.py
+++ b/tests/admin_pages/test_all.py
@@ -3,11 +3,13 @@
 import os
 
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
-from wcs.qommon.ident.password_accounts import PasswordAccount
 from wcs.qommon.http_request import HTTPRequest
-
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
+from wcs.qommon.ident.password_accounts import PasswordAccount
 
 
 def pytest_generate_tests(metafunc):
diff --git a/tests/admin_pages/test_api_access.py b/tests/admin_pages/test_api_access.py
index e9dce38c..4c577213 100644
--- a/tests/admin_pages/test_api_access.py
+++ b/tests/admin_pages/test_api_access.py
@@ -15,11 +15,14 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
-from wcs.qommon.http_request import HTTPRequest
 from wcs.api_access import ApiAccess
+from wcs.qommon.http_request import HTTPRequest
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
 from .test_all import create_superuser
 
 
diff --git a/tests/admin_pages/test_block.py b/tests/admin_pages/test_block.py
index 7e680bb4..29fe89b6 100644
--- a/tests/admin_pages/test_block.py
+++ b/tests/admin_pages/test_block.py
@@ -8,15 +8,19 @@ except ImportError:
     lasso = None
 
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 from webtest import Upload
 
-from wcs.qommon.http_request import HTTPRequest
-from wcs.formdef import FormDef
-from wcs.blocks import BlockDef
 from wcs import fields
+from wcs.blocks import BlockDef
+from wcs.formdef import FormDef
+from wcs.qommon.http_request import HTTPRequest
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
-from .test_all import create_superuser, create_role
+from .test_all import create_role
+from .test_all import create_superuser
 
 
 def pytest_generate_tests(metafunc):
diff --git a/tests/admin_pages/test_card.py b/tests/admin_pages/test_card.py
index 2f84fc6a..6ab5b2b1 100644
--- a/tests/admin_pages/test_card.py
+++ b/tests/admin_pages/test_card.py
@@ -1,20 +1,25 @@
 # -*- coding: utf-8 -*-
 
-import pytest
 import re
 
+import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
+
 from wcs import fields
 from wcs.admin.settings import UserFieldsFormDef
-from wcs.categories import CardDefCategory
 from wcs.carddef import CardDef
+from wcs.categories import CardDefCategory
 from wcs.formdef import FormDef
 from wcs.qommon.http_request import HTTPRequest
-from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
+from wcs.wf.form import FormWorkflowStatusItem
+from wcs.wf.form import WorkflowFormFieldsFormDef
 from wcs.workflows import Workflow
 from wcs.workflows import WorkflowBackofficeFieldsFormDef
 from wcs.workflows import WorkflowVariablesFieldsFormDef
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
 from .test_all import create_superuser
 
 
diff --git a/tests/admin_pages/test_carddefcategory.py b/tests/admin_pages/test_carddefcategory.py
index 87e077ec..34736099 100644
--- a/tests/admin_pages/test_carddefcategory.py
+++ b/tests/admin_pages/test_carddefcategory.py
@@ -1,12 +1,15 @@
 # -*- coding: utf-8 -*-
 
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
-from wcs.qommon.http_request import HTTPRequest
 from wcs.carddef import CardDef
 from wcs.categories import CardDefCategory
+from wcs.qommon.http_request import HTTPRequest
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
 from .test_all import create_superuser
 
 
diff --git a/tests/admin_pages/test_category.py b/tests/admin_pages/test_category.py
index b14c1477..a6a8cec4 100644
--- a/tests/admin_pages/test_category.py
+++ b/tests/admin_pages/test_category.py
@@ -1,12 +1,15 @@
 # -*- coding: utf-8 -*-
 
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
-from wcs.qommon.http_request import HTTPRequest
 from wcs.categories import Category
 from wcs.formdef import FormDef
+from wcs.qommon.http_request import HTTPRequest
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
 from .test_all import create_superuser
 
 
diff --git a/tests/admin_pages/test_datasource.py b/tests/admin_pages/test_datasource.py
index 63b68d18..6ea09a70 100644
--- a/tests/admin_pages/test_datasource.py
+++ b/tests/admin_pages/test_datasource.py
@@ -2,27 +2,33 @@
 
 import io
 import json
-import mock
 import os
 import xml.etree.ElementTree as ET
 
+import mock
+
 try:
     import lasso
 except ImportError:
     lasso = None
 
 import pytest
+from utilities import HttpRequestsMocking
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 from webtest import Upload
 
-from wcs.qommon.http_request import HTTPRequest
+from wcs import fields
 from wcs.admin.settings import UserFieldsFormDef
+from wcs.carddef import CardDef
 from wcs.data_sources import NamedDataSource
-from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef
 from wcs.formdef import FormDef
-from wcs.carddef import CardDef
-from wcs import fields
+from wcs.qommon.http_request import HTTPRequest
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub, HttpRequestsMocking
 from .test_all import create_superuser
 
 
@@ -341,7 +347,8 @@ def test_data_sources_view(pub):
         fields.ItemField(id='1', type='item', label='item', data_source={'type': data_source.slug})
     )
 
-    from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
+    from wcs.wf.form import FormWorkflowStatusItem
+    from wcs.wf.form import WorkflowFormFieldsFormDef
 
     baz_status = workflow.add_status(name='baz')
     display_form = FormWorkflowStatusItem()
diff --git a/tests/admin_pages/test_form.py b/tests/admin_pages/test_form.py
index fd01b530..9c292034 100644
--- a/tests/admin_pages/test_form.py
+++ b/tests/admin_pages/test_form.py
@@ -2,29 +2,32 @@
 
 import datetime
 import io
-import mock
 import os
 import re
 import tarfile
 import time
 import xml.etree.ElementTree as ET
 
+import mock
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 from webtest import Upload
 
-from wcs.qommon.http_request import HTTPRequest
-from wcs.qommon.errors import ConnectionError
+from wcs import fields
+from wcs.carddef import CardDef
 from wcs.categories import Category
 from wcs.data_sources import NamedDataSource
-from wcs.wscalls import NamedWsCall
-from wcs.workflows import Workflow
 from wcs.formdef import FormDef
-from wcs.carddef import CardDef
-from wcs import fields
-
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
+from wcs.qommon.errors import ConnectionError
+from wcs.qommon.http_request import HTTPRequest
+from wcs.workflows import Workflow
+from wcs.wscalls import NamedWsCall
 
-from .test_all import create_superuser, create_role
+from .test_all import create_role
+from .test_all import create_superuser
 
 
 def pytest_generate_tests(metafunc):
diff --git a/tests/admin_pages/test_logged_errors.py b/tests/admin_pages/test_logged_errors.py
index 838e6ed3..3db1ff56 100644
--- a/tests/admin_pages/test_logged_errors.py
+++ b/tests/admin_pages/test_logged_errors.py
@@ -3,13 +3,16 @@
 import datetime
 
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
 from wcs.carddef import CardDef
 from wcs.formdef import FormDef
 from wcs.qommon.http_request import HTTPRequest
 from wcs.workflows import Workflow
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
 from .test_all import create_superuser
 
 
diff --git a/tests/admin_pages/test_role.py b/tests/admin_pages/test_role.py
index a61e3375..c32e8379 100644
--- a/tests/admin_pages/test_role.py
+++ b/tests/admin_pages/test_role.py
@@ -1,11 +1,14 @@
 # -*- coding: utf-8 -*-
 
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
-from wcs.qommon.http_request import HTTPRequest
 from wcs.formdef import FormDef
+from wcs.qommon.http_request import HTTPRequest
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
 from .test_all import create_superuser
 
 
diff --git a/tests/admin_pages/test_settings.py b/tests/admin_pages/test_settings.py
index c2dcfac2..0ba93829 100644
--- a/tests/admin_pages/test_settings.py
+++ b/tests/admin_pages/test_settings.py
@@ -11,26 +11,30 @@ try:
 except ImportError:
     lasso = None
 
-import pytest
-from webtest import Upload
 import mock
-
+import pytest
 from quixote.http_request import Upload as QuixoteUpload
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
+from webtest import Upload
 
+from wcs import fields
+from wcs.api_access import ApiAccess
+from wcs.carddef import CardDef
+from wcs.categories import CardDefCategory
+from wcs.categories import Category
+from wcs.data_sources import NamedDataSource
+from wcs.formdef import FormDef
 from wcs.qommon.form import UploadedFile
 from wcs.qommon.http_request import HTTPRequest
 from wcs.qommon.template import get_current_theme
-from wcs.api_access import ApiAccess
-from wcs.categories import Category, CardDefCategory
-from wcs.data_sources import NamedDataSource
-from wcs.wscalls import NamedWsCall
-from wcs.workflows import Workflow, CommentableWorkflowStatusItem
 from wcs.wf.export_to_model import ExportToModel
-from wcs.formdef import FormDef
-from wcs.carddef import CardDef
-from wcs import fields
+from wcs.workflows import CommentableWorkflowStatusItem
+from wcs.workflows import Workflow
+from wcs.wscalls import NamedWsCall
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
 from .test_all import create_superuser
 
 
diff --git a/tests/admin_pages/test_user.py b/tests/admin_pages/test_user.py
index efc4f85d..8d73a59d 100644
--- a/tests/admin_pages/test_user.py
+++ b/tests/admin_pages/test_user.py
@@ -1,14 +1,18 @@
 # -*- coding: utf-8 -*-
 
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
-from wcs.qommon.ident.password_accounts import PasswordAccount
-from wcs.qommon.http_request import HTTPRequest
-from wcs.admin.settings import UserFieldsFormDef
 from wcs import fields
+from wcs.admin.settings import UserFieldsFormDef
+from wcs.qommon.http_request import HTTPRequest
+from wcs.qommon.ident.password_accounts import PasswordAccount
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
-from .test_all import create_superuser, create_role
+from .test_all import create_role
+from .test_all import create_superuser
 
 
 def pytest_generate_tests(metafunc):
diff --git a/tests/admin_pages/test_workflow.py b/tests/admin_pages/test_workflow.py
index 948f8915..75daa5bf 100644
--- a/tests/admin_pages/test_workflow.py
+++ b/tests/admin_pages/test_workflow.py
@@ -1,47 +1,51 @@
 # -*- coding: utf-8 -*-
 
 import io
-import mock
 import os
 import re
 
+import mock
+
 try:
     import lasso
 except ImportError:
     lasso = None
 
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 from webtest import Upload
 
-from wcs.qommon.http_request import HTTPRequest
+from wcs import fields
+from wcs.carddef import CardDef
+from wcs.formdef import FormDef
 from wcs.qommon.errors import ConnectionError
-from wcs.workflows import (
-    Workflow,
-    WorkflowCriticalityLevel,
-    DisplayMessageWorkflowStatusItem,
-    WorkflowBackofficeFieldsFormDef,
-    CommentableWorkflowStatusItem,
-    ChoiceWorkflowStatusItem,
-    JumpOnSubmitWorkflowStatusItem,
-    WorkflowVariablesFieldsFormDef,
-    item_classes,
-)
+from wcs.qommon.http_request import HTTPRequest
 from wcs.wf.create_carddata import CreateCarddataWorkflowStatusItem
-from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
+from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem
+from wcs.wf.create_formdata import Mapping
 from wcs.wf.dispatch import DispatchWorkflowStatusItem
 from wcs.wf.edit_carddata import EditCarddataWorkflowStatusItem
 from wcs.wf.export_to_model import ExportToModel
 from wcs.wf.external_workflow import ExternalWorkflowGlobalAction
-from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
+from wcs.wf.form import FormWorkflowStatusItem
+from wcs.wf.form import WorkflowFormFieldsFormDef
 from wcs.wf.jump import JumpWorkflowStatusItem
 from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
 from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
 from wcs.wf.wscall import WebserviceCallStatusItem
-from wcs.carddef import CardDef
-from wcs.formdef import FormDef
-from wcs import fields
+from wcs.workflows import ChoiceWorkflowStatusItem
+from wcs.workflows import CommentableWorkflowStatusItem
+from wcs.workflows import DisplayMessageWorkflowStatusItem
+from wcs.workflows import JumpOnSubmitWorkflowStatusItem
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
+from wcs.workflows import WorkflowCriticalityLevel
+from wcs.workflows import WorkflowVariablesFieldsFormDef
+from wcs.workflows import item_classes
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
 from .test_all import create_superuser
 
 
diff --git a/tests/admin_pages/test_wscall.py b/tests/admin_pages/test_wscall.py
index 5d8236fd..c8002822 100644
--- a/tests/admin_pages/test_wscall.py
+++ b/tests/admin_pages/test_wscall.py
@@ -4,12 +4,15 @@ import io
 import xml.etree.ElementTree as ET
 
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 from webtest import Upload
 
 from wcs.qommon.http_request import HTTPRequest
 from wcs.wscalls import NamedWsCall
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
 from .test_all import create_superuser
 
 
diff --git a/tests/api/test_access.py b/tests/api/test_access.py
index fd0b32c9..2509c56a 100644
--- a/tests/api/test_access.py
+++ b/tests/api/test_access.py
@@ -11,9 +11,14 @@ import urllib.parse
 import pytest
 from django.utils.encoding import force_bytes
 from quixote import get_publisher
-from utilities import clean_temporary_pub, create_temporary_pub, get_app, login
-
-from wcs.api_utils import get_secret_and_orig, is_url_signed, sign_url
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
+
+from wcs.api_utils import get_secret_and_orig
+from wcs.api_utils import is_url_signed
+from wcs.api_utils import sign_url
 from wcs.qommon.errors import AccessForbiddenError
 from wcs.qommon.http_request import HTTPRequest
 from wcs.qommon.ident.password_accounts import PasswordAccount
diff --git a/tests/api/test_all.py b/tests/api/test_all.py
index c9287f5f..6416a60c 100644
--- a/tests/api/test_all.py
+++ b/tests/api/test_all.py
@@ -7,7 +7,9 @@ import os
 import mock
 import pytest
 from quixote import get_publisher
-from utilities import clean_temporary_pub, create_temporary_pub, get_app
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
 
 from wcs.api_utils import sign_url
 from wcs.formdef import FormDef
diff --git a/tests/api/test_carddef.py b/tests/api/test_carddef.py
index 31423b1d..bd29d0e4 100644
--- a/tests/api/test_carddef.py
+++ b/tests/api/test_carddef.py
@@ -11,9 +11,12 @@ import mock
 import pytest
 from django.utils.encoding import force_text
 from quixote import get_publisher
-from utilities import clean_temporary_pub, create_temporary_pub, get_app
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
 
-from wcs import fields, qommon
+from wcs import fields
+from wcs import qommon
 from wcs.api_utils import sign_url
 from wcs.carddef import CardDef
 from wcs.categories import CardDefCategory
@@ -21,7 +24,8 @@ from wcs.data_sources import NamedDataSource
 from wcs.qommon.afterjobs import AfterJob
 from wcs.qommon.form import PicklableUpload
 from wcs.qommon.http_request import HTTPRequest
-from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
 
 from .utils import sign_uri
 
diff --git a/tests/api/test_category.py b/tests/api/test_category.py
index 00d7b4df..e1b024ce 100644
--- a/tests/api/test_category.py
+++ b/tests/api/test_category.py
@@ -4,7 +4,9 @@ import os
 
 import pytest
 from quixote import get_publisher
-from utilities import clean_temporary_pub, create_temporary_pub, get_app
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
 
 from wcs.categories import Category
 from wcs.formdef import FormDef
diff --git a/tests/api/test_custom_view.py b/tests/api/test_custom_view.py
index 1dc91fa1..0c96d80e 100644
--- a/tests/api/test_custom_view.py
+++ b/tests/api/test_custom_view.py
@@ -7,7 +7,9 @@ import zipfile
 
 import pytest
 from quixote import get_publisher
-from utilities import clean_temporary_pub, create_temporary_pub, get_app
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
 
 from wcs import fields
 from wcs.carddef import CardDef
diff --git a/tests/api/test_formdata.py b/tests/api/test_formdata.py
index c125d824..746b0c01 100644
--- a/tests/api/test_formdata.py
+++ b/tests/api/test_formdata.py
@@ -12,7 +12,10 @@ import zipfile
 import pytest
 from django.utils.encoding import force_bytes
 from quixote import get_publisher
-from utilities import clean_temporary_pub, create_temporary_pub, get_app, login
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
 from wcs import fields
 from wcs.blocks import BlockDef
@@ -23,7 +26,9 @@ from wcs.qommon import ods
 from wcs.qommon.form import PicklableUpload
 from wcs.qommon.http_request import HTTPRequest
 from wcs.qommon.ident.password_accounts import PasswordAccount
-from wcs.workflows import EditableWorkflowStatusItem, Workflow, WorkflowBackofficeFieldsFormDef
+from wcs.workflows import EditableWorkflowStatusItem
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
 
 from .utils import sign_uri
 
diff --git a/tests/api/test_formdef.py b/tests/api/test_formdef.py
index 3490c29b..316b2658 100644
--- a/tests/api/test_formdef.py
+++ b/tests/api/test_formdef.py
@@ -12,16 +12,20 @@ import mock
 import pytest
 from django.utils.encoding import force_text
 from quixote import get_publisher
-from utilities import clean_temporary_pub, create_temporary_pub, get_app
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
 
-from wcs import fields, qommon
+from wcs import fields
+from wcs import qommon
 from wcs.api_utils import sign_url
 from wcs.data_sources import NamedDataSource
 from wcs.formdef import FormDef
 from wcs.qommon.form import PicklableUpload
 from wcs.qommon.http_request import HTTPRequest
 from wcs.wf.jump import JumpWorkflowStatusItem
-from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
 
 from .utils import sign_uri
 
diff --git a/tests/api/test_user.py b/tests/api/test_user.py
index e418ee0c..bb8e6079 100644
--- a/tests/api/test_user.py
+++ b/tests/api/test_user.py
@@ -5,14 +5,17 @@ import os
 
 import pytest
 from quixote import get_publisher
-from utilities import clean_temporary_pub, create_temporary_pub, get_app
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
 
 from wcs import fields
 from wcs.formdef import FormDef
 from wcs.qommon.form import PicklableUpload
 from wcs.qommon.http_request import HTTPRequest
 from wcs.qommon.ident.password_accounts import PasswordAccount
-from wcs.workflows import Workflow, WorkflowVariablesFieldsFormDef
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowVariablesFieldsFormDef
 
 from .utils import sign_uri
 
diff --git a/tests/api/test_utils.py b/tests/api/test_utils.py
index 00503a7b..9e32d1a1 100644
--- a/tests/api/test_utils.py
+++ b/tests/api/test_utils.py
@@ -1,6 +1,8 @@
 import pytest
-from quixote import cleanup, get_response
-from utilities import clean_temporary_pub, create_temporary_pub
+from quixote import cleanup
+from quixote import get_response
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
 
 from wcs import sessions
 from wcs.api_utils import get_query_flag
diff --git a/tests/api/test_workflow.py b/tests/api/test_workflow.py
index f431747b..7b67a89d 100644
--- a/tests/api/test_workflow.py
+++ b/tests/api/test_workflow.py
@@ -4,7 +4,9 @@ import os
 
 import pytest
 from quixote import get_publisher
-from utilities import clean_temporary_pub, create_temporary_pub, get_app
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
 
 from wcs import fields
 from wcs.formdef import FormDef
diff --git a/tests/backoffice_pages/test_all.py b/tests/backoffice_pages/test_all.py
index 6e9961f2..d1d9f660 100644
--- a/tests/backoffice_pages/test_all.py
+++ b/tests/backoffice_pages/test_all.py
@@ -4,51 +4,53 @@ import datetime
 import io
 import json
 import os
+import random
 import re
 import time
-import random
 import zipfile
 
 import mock
 import pytest
-
 from quixote import get_publisher
 from quixote.http_request import Upload as QuixoteUpload
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
+
+import wcs.qommon.storage as st
+from wcs import fields
 from wcs.blocks import BlockDef
+from wcs.carddef import CardDef
+from wcs.categories import Category
+from wcs.formdef import FormDef
 from wcs.qommon.form import PicklableUpload
 from wcs.qommon.form import UploadedFile
-from wcs.qommon.ident.password_accounts import PasswordAccount
 from wcs.qommon.http_request import HTTPRequest
-import wcs.qommon.storage as st
+from wcs.qommon.ident.password_accounts import PasswordAccount
 from wcs.roles import logged_users_role
-from wcs.workflows import (
-    Workflow,
-    CommentableWorkflowStatusItem,
-    ChoiceWorkflowStatusItem,
-    EditableWorkflowStatusItem,
-    DisplayMessageWorkflowStatusItem,
-    JumpOnSubmitWorkflowStatusItem,
-    WorkflowCriticalityLevel,
-    WorkflowBackofficeFieldsFormDef,
-)
 from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
+from wcs.wf.create_carddata import CreateCarddataWorkflowStatusItem
+from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem
+from wcs.wf.create_formdata import Mapping
 from wcs.wf.export_to_model import ExportToModel
-from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
+from wcs.wf.form import FormWorkflowStatusItem
+from wcs.wf.form import WorkflowFormFieldsFormDef
 from wcs.wf.jump import JumpWorkflowStatusItem
-from wcs.wf.wscall import WebserviceCallStatusItem
 from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
 from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
 from wcs.wf.resubmit import ResubmitWorkflowStatusItem
-from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
-from wcs.wf.create_carddata import CreateCarddataWorkflowStatusItem
-from wcs.carddef import CardDef
-from wcs.categories import Category
-from wcs.formdef import FormDef
-from wcs import fields
+from wcs.wf.wscall import WebserviceCallStatusItem
+from wcs.workflows import ChoiceWorkflowStatusItem
+from wcs.workflows import CommentableWorkflowStatusItem
+from wcs.workflows import DisplayMessageWorkflowStatusItem
+from wcs.workflows import EditableWorkflowStatusItem
+from wcs.workflows import JumpOnSubmitWorkflowStatusItem
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
+from wcs.workflows import WorkflowCriticalityLevel
 from wcs.wscalls import NamedWsCall
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
-
 
 def pytest_generate_tests(metafunc):
     if 'pub' in metafunc.fixturenames:
@@ -1755,7 +1757,8 @@ def test_backoffice_statistics_with_no_formdefs(pub):
     create_environment(pub)
     FormDef.wipe()
     if pub.is_using_postgresql():
-        from wcs.sql import get_connection_and_cursor, drop_global_views
+        from wcs.sql import drop_global_views
+        from wcs.sql import get_connection_and_cursor
 
         conn, cur = get_connection_and_cursor()
         drop_global_views(conn, cur)
@@ -3144,7 +3147,8 @@ def test_management_views_with_no_formdefs(pub):
     create_environment(pub)
     FormDef.wipe()
 
-    from wcs.sql import get_connection_and_cursor, drop_global_views
+    from wcs.sql import drop_global_views
+    from wcs.sql import get_connection_and_cursor
 
     conn, cur = get_connection_and_cursor()
     drop_global_views(conn, cur)
diff --git a/tests/backoffice_pages/test_carddata.py b/tests/backoffice_pages/test_carddata.py
index b4933a1b..829a5ad1 100644
--- a/tests/backoffice_pages/test_carddata.py
+++ b/tests/backoffice_pages/test_carddata.py
@@ -4,6 +4,10 @@ import os
 import uuid
 
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 from webtest import Upload
 
 from wcs import fields
@@ -13,9 +17,9 @@ from wcs.categories import CardDefCategory
 from wcs.formdef import FormDef
 from wcs.qommon.http_request import HTTPRequest
 from wcs.wf.wscall import WebserviceCallStatusItem
-from wcs.workflows import ChoiceWorkflowStatusItem, Workflow
+from wcs.workflows import ChoiceWorkflowStatusItem
+from wcs.workflows import Workflow
 
-from utilities import clean_temporary_pub, create_temporary_pub, get_app, login
 from .test_all import create_user
 
 
diff --git a/tests/backoffice_pages/test_custom_view.py b/tests/backoffice_pages/test_custom_view.py
index 0cb9bcb5..58a6ea11 100644
--- a/tests/backoffice_pages/test_custom_view.py
+++ b/tests/backoffice_pages/test_custom_view.py
@@ -3,16 +3,20 @@ import os
 import re
 
 import pytest
-
 from quixote import get_publisher
-from wcs.qommon.ident.password_accounts import PasswordAccount
-from wcs.qommon.http_request import HTTPRequest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
+
+from wcs import fields
 from wcs.carddef import CardDef
 from wcs.formdef import FormDef
-from wcs import fields
+from wcs.qommon.http_request import HTTPRequest
+from wcs.qommon.ident.password_accounts import PasswordAccount
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
-from .test_all import create_user, create_superuser
+from .test_all import create_superuser
+from .test_all import create_user
 
 
 def pytest_generate_tests(metafunc):
diff --git a/tests/backoffice_pages/test_export.py b/tests/backoffice_pages/test_export.py
index 16e5d14f..73b33cce 100644
--- a/tests/backoffice_pages/test_export.py
+++ b/tests/backoffice_pages/test_export.py
@@ -9,15 +9,18 @@ import xml.etree.ElementTree as ET
 import zipfile
 
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
-from wcs.qommon import ods
+from wcs import fields
 from wcs.blocks import BlockDef
+from wcs.formdef import FormDef
+from wcs.qommon import ods
 from wcs.qommon.form import PicklableUpload
 from wcs.qommon.http_request import HTTPRequest
-from wcs.formdef import FormDef
-from wcs import fields
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
 from .test_all import create_superuser
 
 
diff --git a/tests/backoffice_pages/test_submission.py b/tests/backoffice_pages/test_submission.py
index 453e2984..57b159b1 100644
--- a/tests/backoffice_pages/test_submission.py
+++ b/tests/backoffice_pages/test_submission.py
@@ -6,7 +6,10 @@ import time
 import urllib.parse
 
 import pytest
-from utilities import clean_temporary_pub, create_temporary_pub, get_app, login
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
 from wcs import fields
 from wcs.api_utils import sign_url
@@ -16,9 +19,11 @@ from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
 from wcs.wf.dispatch import DispatchWorkflowStatusItem
 from wcs.wf.jump import JumpWorkflowStatusItem
 from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
-from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
 
-from .test_all import create_superuser, create_user
+from .test_all import create_superuser
+from .test_all import create_user
 
 
 def pytest_generate_tests(metafunc):
diff --git a/tests/conftest.py b/tests/conftest.py
index cf8548c0..a663d5ac 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -2,8 +2,9 @@ import configparser
 import os
 
 import pytest
-
-from utilities import EmailsMocking, SMSMocking, HttpRequestsMocking
+from utilities import EmailsMocking
+from utilities import HttpRequestsMocking
+from utilities import SMSMocking
 
 
 def site_options(request, pub, section, variable, value):
diff --git a/tests/form_pages/test_all.py b/tests/form_pages/test_all.py
index 26e5a31c..46700121 100644
--- a/tests/form_pages/test_all.py
+++ b/tests/form_pages/test_all.py
@@ -1,58 +1,63 @@
 # -*- coding: utf-8 -*-
 
+import hashlib
 import io
 import json
-import pytest
-import hashlib
 import os
 import re
 import time
 import urllib.parse
+import xml.etree.ElementTree as ET
 import zipfile
 
-from webtest import Upload, Hidden, Radio
 import mock
-import xml.etree.ElementTree as ET
+import pytest
+from webtest import Hidden
+from webtest import Radio
+from webtest import Upload
 
 try:
     from PIL import Image
 except ImportError:
     Image = None
 
-from django.utils.encoding import force_bytes, force_text
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
+from wcs import fields
+from wcs.blocks import BlockDef
+from wcs.carddef import CardDef
+from wcs.categories import Category
+from wcs.data_sources import NamedDataSource
+from wcs.formdef import FormDef
+from wcs.forms.root import PublicFormStatusPage
 from wcs.qommon import force_str
 from wcs.qommon.emails import docutils
 from wcs.qommon.ident.password_accounts import PasswordAccount
 from wcs.qommon.misc import ConnectionError
-from wcs.carddef import CardDef
-from wcs.formdef import FormDef
-from wcs.workflows import (
-    Workflow,
-    EditableWorkflowStatusItem,
-    DisplayMessageWorkflowStatusItem,
-    WorkflowBackofficeFieldsFormDef,
-    ChoiceWorkflowStatusItem,
-    JumpOnSubmitWorkflowStatusItem,
-    CommentableWorkflowStatusItem,
-    WorkflowVariablesFieldsFormDef,
-)
+from wcs.roles import logged_users_role
+from wcs.tracking_code import TrackingCode
 from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
+from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem
+from wcs.wf.create_formdata import Mapping
+from wcs.wf.form import FormWorkflowStatusItem
+from wcs.wf.form import WorkflowFormFieldsFormDef
 from wcs.wf.jump import JumpWorkflowStatusItem
-from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
+from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
 from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
 from wcs.wf.resubmit import ResubmitWorkflowStatusItem
-from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
-from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
-from wcs.blocks import BlockDef
-from wcs.categories import Category
-from wcs.roles import logged_users_role
-from wcs.tracking_code import TrackingCode
-from wcs.data_sources import NamedDataSource
-from wcs import fields
-from wcs.forms.root import PublicFormStatusPage
-
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
+from wcs.workflows import ChoiceWorkflowStatusItem
+from wcs.workflows import CommentableWorkflowStatusItem
+from wcs.workflows import DisplayMessageWorkflowStatusItem
+from wcs.workflows import EditableWorkflowStatusItem
+from wcs.workflows import JumpOnSubmitWorkflowStatusItem
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
+from wcs.workflows import WorkflowVariablesFieldsFormDef
 
 
 def assert_equal_zip(stream1, stream2):
diff --git a/tests/form_pages/test_block.py b/tests/form_pages/test_block.py
index f55ed7b4..36b894c9 100644
--- a/tests/form_pages/test_block.py
+++ b/tests/form_pages/test_block.py
@@ -2,20 +2,24 @@
 
 import io
 import json
-import mock
 
+import mock
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 from webtest import Upload
 
+from wcs import fields
 from wcs.blocks import BlockDef
-from wcs.formdef import FormDef
-from wcs.workflows import Workflow
-from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
 from wcs.categories import Category
 from wcs.data_sources import NamedDataSource
-from wcs import fields
+from wcs.formdef import FormDef
+from wcs.wf.form import FormWorkflowStatusItem
+from wcs.wf.form import WorkflowFormFieldsFormDef
+from wcs.workflows import Workflow
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
 from .test_all import create_user
 
 
diff --git a/tests/form_pages/test_formdata.py b/tests/form_pages/test_formdata.py
index 2c9d9246..8a00dbbf 100644
--- a/tests/form_pages/test_formdata.py
+++ b/tests/form_pages/test_formdata.py
@@ -13,27 +13,32 @@ import mock
 import pytest
 from django.utils.encoding import force_bytes
 from quixote.http_request import Upload as QuixoteUpload
-from webtest import Upload, Hidden
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
+from webtest import Hidden
+from webtest import Upload
 
 from wcs import fields
 from wcs.data_sources import NamedDataSource
 from wcs.formdef import FormDef
 from wcs.qommon.form import UploadedFile
 from wcs.wf.attachment import AddAttachmentWorkflowStatusItem
-from wcs.wf.export_to_model import ExportToModel, transform_to_pdf
-from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
+from wcs.wf.export_to_model import ExportToModel
+from wcs.wf.export_to_model import transform_to_pdf
+from wcs.wf.form import FormWorkflowStatusItem
+from wcs.wf.form import WorkflowFormFieldsFormDef
 from wcs.wf.jump import JumpWorkflowStatusItem
 from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
-from wcs.workflows import (
-    ChoiceWorkflowStatusItem,
-    DisplayMessageWorkflowStatusItem,
-    Workflow,
-    WorkflowBackofficeFieldsFormDef,
-)
+from wcs.workflows import ChoiceWorkflowStatusItem
+from wcs.workflows import DisplayMessageWorkflowStatusItem
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
 from wcs.wscalls import NamedWsCall
 
-from .test_all import create_user, create_user_and_admin
-from utilities import clean_temporary_pub, create_temporary_pub, get_app, login
+from .test_all import create_user
+from .test_all import create_user_and_admin
 
 
 def pytest_generate_tests(metafunc):
diff --git a/tests/test_auth_pages.py b/tests/test_auth_pages.py
index e1197241..4e135075 100644
--- a/tests/test_auth_pages.py
+++ b/tests/test_auth_pages.py
@@ -1,7 +1,10 @@
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
 from wcs.qommon.ident.password_accounts import PasswordAccount
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
 
 
 @pytest.fixture
diff --git a/tests/test_carddef.py b/tests/test_carddef.py
index d9524ab4..e9114cbe 100644
--- a/tests/test_carddef.py
+++ b/tests/test_carddef.py
@@ -1,16 +1,17 @@
 import io
-import pytest
 import xml.etree.ElementTree as ET
 
-from wcs.qommon.http_request import HTTPRequest
-from wcs.qommon.misc import indent_xml as indent
-from wcs.qommon.template import Template
-from wcs.categories import CardDefCategory
+import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+
 from wcs.carddef import CardDef
+from wcs.categories import CardDefCategory
 from wcs.fields import ItemField
 from wcs.fields import StringField
-
-from utilities import create_temporary_pub, clean_temporary_pub
+from wcs.qommon.http_request import HTTPRequest
+from wcs.qommon.misc import indent_xml as indent
+from wcs.qommon.template import Template
 
 
 def pytest_generate_tests(metafunc):
diff --git a/tests/test_categories.py b/tests/test_categories.py
index ed7d3d89..97f9a303 100644
--- a/tests/test_categories.py
+++ b/tests/test_categories.py
@@ -4,13 +4,12 @@ import pickle
 import shutil
 
 import pytest
-
 from quixote import cleanup
-
-from wcs.categories import Category, CardDefCategory
-
 from utilities import create_temporary_pub
 
+from wcs.categories import CardDefCategory
+from wcs.categories import Category
+
 
 def setup_module(module):
     cleanup()
diff --git a/tests/test_convert_to_sql.py b/tests/test_convert_to_sql.py
index c4193584..d87acdf8 100644
--- a/tests/test_convert_to_sql.py
+++ b/tests/test_convert_to_sql.py
@@ -1,22 +1,21 @@
 import collections
 import os
 import random
+
 import psycopg2
 import pytest
-
-from django.core.management import get_commands
 from django.core.management import call_command
+from django.core.management import get_commands
 from django.core.management.base import CommandError
 from quixote import get_publisher
-
-from wcs.sql import cleanup_connection
-from wcs.formdef import FormDef
-from wcs.fields import BoolField
-
 from utilities import clean_temporary_pub
 from utilities import create_temporary_pub
 from utilities import force_connections_close
 
+from wcs.fields import BoolField
+from wcs.formdef import FormDef
+from wcs.sql import cleanup_connection
+
 
 @pytest.fixture
 def formdeffix():
diff --git a/tests/test_ctl.py b/tests/test_ctl.py
index f817f5a1..46055fe0 100644
--- a/tests/test_ctl.py
+++ b/tests/test_ctl.py
@@ -1,32 +1,35 @@
+import collections
 import os
-import pytest
 import sys
-import collections
-from email.mime.text import MIMEText
 from email.mime.multipart import MIMEMultipart
-import psycopg2
+from email.mime.text import MIMEText
 
-from django.core.management import call_command, CommandError
+import psycopg2
+import pytest
+from django.core.management import CommandError
+from django.core.management import call_command
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
 
-from wcs.formdef import FormDef
-from wcs.workflows import Workflow
-from wcs.wf.jump import JumpWorkflowStatusItem
-from wcs.fields import StringField, EmailField
 import wcs.qommon.ctl
+from wcs.ctl.delete_tenant import CmdDeleteTenant
+from wcs.ctl.management.commands.runscript import Command as CmdRunScript
+from wcs.ctl.management.commands.trigger_jumps import select_and_jump_formdata
+from wcs.ctl.rebuild_indexes import rebuild_vhost_indexes
+from wcs.ctl.wipe_data import CmdWipeData
+from wcs.fields import EmailField
+from wcs.fields import StringField
+from wcs.formdef import FormDef
 from wcs.qommon.afterjobs import AfterJob
 from wcs.qommon.management.commands.collectstatic import Command as CmdCollectStatic
+from wcs.qommon.management.commands.makemessages import Command as CmdMakeMessages
 from wcs.qommon.management.commands.migrate import Command as CmdMigrate
 from wcs.qommon.management.commands.migrate_schemas import Command as CmdMigrateSchemas
-from wcs.qommon.management.commands.makemessages import Command as CmdMakeMessages
-from wcs.ctl.rebuild_indexes import rebuild_vhost_indexes
-from wcs.ctl.wipe_data import CmdWipeData
-from wcs.ctl.management.commands.runscript import Command as CmdRunScript
-from wcs.ctl.management.commands.trigger_jumps import select_and_jump_formdata
-from wcs.ctl.delete_tenant import CmdDeleteTenant
+from wcs.sql import cleanup_connection
+from wcs.sql import get_connection_and_cursor
+from wcs.wf.jump import JumpWorkflowStatusItem
+from wcs.workflows import Workflow
 from wcs.workflows import WorkflowStatusItem
-from wcs.sql import get_connection_and_cursor, cleanup_connection
-
-from utilities import create_temporary_pub, clean_temporary_pub
 
 
 @pytest.fixture
diff --git a/tests/test_datasource.py b/tests/test_datasource.py
index b02c072b..21e92aee 100644
--- a/tests/test_datasource.py
+++ b/tests/test_datasource.py
@@ -2,21 +2,26 @@
 
 import codecs
 import io
-import pytest
-import os
 import json
+import os
 import shutil
 import urllib.parse
 
+import mock
+import pytest
 from quixote import cleanup
+from test_widgets import MockHtmlForm
+from test_widgets import mock_form_submission
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+
+from wcs import data_sources
+from wcs import fields
+from wcs.data_sources import NamedDataSource
+from wcs.data_sources import register_data_source_function
+from wcs.qommon.form import Form
+from wcs.qommon.form import get_request
 from wcs.qommon.http_request import HTTPRequest
-from wcs.qommon.form import get_request, Form
-from wcs import fields, data_sources
-from wcs.data_sources import NamedDataSource, register_data_source_function
-
-import mock
-from test_widgets import MockHtmlForm, mock_form_submission
-from utilities import create_temporary_pub, clean_temporary_pub
 
 
 @pytest.fixture
diff --git a/tests/test_datasource_chrono.py b/tests/test_datasource_chrono.py
index 08377544..6f0a1721 100644
--- a/tests/test_datasource_chrono.py
+++ b/tests/test_datasource_chrono.py
@@ -1,19 +1,21 @@
 # -*- coding: utf-8 -*-
 
 import io
-import pytest
 import json
 import shutil
 
+import mock
+import pytest
 from quixote import cleanup
+from utilities import create_temporary_pub
+
 from wcs import fields
-from wcs.data_sources import NamedDataSource, build_agenda_datasources, collect_agenda_data
+from wcs.data_sources import NamedDataSource
+from wcs.data_sources import build_agenda_datasources
+from wcs.data_sources import collect_agenda_data
 from wcs.formdef import FormDef
-from wcs.qommon.misc import ConnectionError
 from wcs.qommon.http_request import HTTPRequest
-
-import mock
-from utilities import create_temporary_pub
+from wcs.qommon.misc import ConnectionError
 
 
 def setup_module(module):
diff --git a/tests/test_ezt.py b/tests/test_ezt.py
index 513436c9..c2bd37c5 100644
--- a/tests/test_ezt.py
+++ b/tests/test_ezt.py
@@ -1,21 +1,21 @@
 import datetime
 import io
-import pytest
 import os
 
+import pytest
 from quixote import cleanup
-from wcs.qommon.ezt import (
-    Template,
-    UnclosedBlocksError,
-    UnmatchedEndError,
-    UnmatchedElseError,
-    ArgCountSyntaxError,
-    _re_parse,
-)
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+
+from wcs.qommon.ezt import ArgCountSyntaxError
+from wcs.qommon.ezt import Template
+from wcs.qommon.ezt import UnclosedBlocksError
+from wcs.qommon.ezt import UnmatchedElseError
+from wcs.qommon.ezt import UnmatchedEndError
+from wcs.qommon.ezt import _re_parse
 from wcs.scripts import ScriptsSubstitutionProxy
 
-from utilities import get_app, create_temporary_pub, clean_temporary_pub
-
 
 def setup_module(module):
     cleanup()
diff --git a/tests/test_fc_auth.py b/tests/test_fc_auth.py
index 655684b0..a715e8c1 100644
--- a/tests/test_fc_auth.py
+++ b/tests/test_fc_auth.py
@@ -2,11 +2,13 @@ import base64
 import json
 import urllib.parse
 
-from django.utils.encoding import force_bytes, force_text
-from quixote import cleanup, get_session_manager
-
-from utilities import get_app, create_temporary_pub
 import mock
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from quixote import cleanup
+from quixote import get_session_manager
+from utilities import create_temporary_pub
+from utilities import get_app
 
 PROFILE = {
     'fields': [
diff --git a/tests/test_fields.py b/tests/test_fields.py
index 659f65a5..d3cb6219 100644
--- a/tests/test_fields.py
+++ b/tests/test_fields.py
@@ -3,20 +3,21 @@
 import re
 import shutil
 
-from bs4 import BeautifulSoup
 import pytest
-
+from bs4 import BeautifulSoup
 from quixote import cleanup
 from quixote.http_request import Upload
-from wcs.qommon.http_request import HTTPRequest
-from wcs.qommon import sessions
+from utilities import MockSubstitutionVariables
+from utilities import create_temporary_pub
+
 from wcs import fields
-from wcs.qommon.form import Form, PicklableUpload
 from wcs.formdef import FormDef
+from wcs.qommon import sessions
+from wcs.qommon.form import Form
+from wcs.qommon.form import PicklableUpload
+from wcs.qommon.http_request import HTTPRequest
 from wcs.variables import LazyFormData
 
-from utilities import create_temporary_pub, MockSubstitutionVariables
-
 
 def setup_module(module):
     cleanup()
diff --git a/tests/test_formdata.py b/tests/test_formdata.py
index 81e38eff..62fa28c1 100644
--- a/tests/test_formdata.py
+++ b/tests/test_formdata.py
@@ -2,36 +2,35 @@
 
 import collections
 import datetime
-import pytest
 import time
 
 import mock
+import pytest
 from quixote import get_publisher
 from quixote.http_request import Upload
-from wcs.qommon import force_str
-from wcs.qommon.template import Template
-from wcs.qommon.form import PicklableUpload
-from wcs.qommon.http_request import HTTPRequest
-from wcs import fields, formdef
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+
+from wcs import fields
+from wcs import formdef
+from wcs import sessions
 from wcs.blocks import BlockDef
 from wcs.carddef import CardDef
 from wcs.categories import Category
 from wcs.conditions import Condition
-from wcs.formdef import FormDef
 from wcs.formdata import Evolution
-from wcs import sessions
+from wcs.formdef import FormDef
+from wcs.qommon import force_str
+from wcs.qommon.form import PicklableUpload
+from wcs.qommon.http_request import HTTPRequest
+from wcs.qommon.template import Template
 from wcs.variables import LazyFormData
-from wcs.workflows import (
-    Workflow,
-    WorkflowStatusItem,
-    WorkflowCriticalityLevel,
-    WorkflowBackofficeFieldsFormDef,
-)
-from wcs.wf.wscall import JournalWsCallErrorPart
-
 from wcs.wf.register_comment import JournalEvolutionPart
-
-from utilities import create_temporary_pub, clean_temporary_pub
+from wcs.wf.wscall import JournalWsCallErrorPart
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
+from wcs.workflows import WorkflowCriticalityLevel
+from wcs.workflows import WorkflowStatusItem
 
 
 def pytest_generate_tests(metafunc):
diff --git a/tests/test_formdef.py b/tests/test_formdef.py
index d4ad2e14..f274d533 100644
--- a/tests/test_formdef.py
+++ b/tests/test_formdef.py
@@ -4,24 +4,32 @@ import io
 import json
 import os
 import pickle
-import sys
 import shutil
+import sys
 import time
 
 import pytest
-
 from django.utils.encoding import force_bytes
 from quixote import cleanup
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+
 from wcs import fields
 from wcs.blocks import BlockDef
-from wcs.formdef import FormDef, get_formdefs_of_all_kinds
-from wcs.qommon.http_request import HTTPRequest
+from wcs.fields import DateField
+from wcs.fields import FileField
+from wcs.fields import ItemField
+from wcs.fields import PageField
+from wcs.fields import StringField
+from wcs.formdef import FormDef
+from wcs.formdef import get_formdefs_of_all_kinds
 from wcs.qommon.form import PicklableUpload
-from wcs.workflows import Workflow, AttachmentEvolutionPart, WorkflowBackofficeFieldsFormDef
-from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
-from wcs.fields import StringField, FileField, DateField, ItemField, PageField
-
-from utilities import create_temporary_pub, clean_temporary_pub
+from wcs.qommon.http_request import HTTPRequest
+from wcs.wf.form import FormWorkflowStatusItem
+from wcs.wf.form import WorkflowFormFieldsFormDef
+from wcs.workflows import AttachmentEvolutionPart
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
 
 
 def pytest_generate_tests(metafunc):
@@ -496,8 +504,10 @@ def test_unused_file_removal_job(pub):
 def test_get_formdefs_of_all_kinds(pub):
     from wcs.admin.settings import UserFieldsFormDef
     from wcs.carddef import CardDef
-    from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
-    from wcs.workflows import WorkflowBackofficeFieldsFormDef, WorkflowVariablesFieldsFormDef
+    from wcs.wf.form import FormWorkflowStatusItem
+    from wcs.wf.form import WorkflowFormFieldsFormDef
+    from wcs.workflows import WorkflowBackofficeFieldsFormDef
+    from wcs.workflows import WorkflowVariablesFieldsFormDef
 
     BlockDef.wipe()
     FormDef.wipe()
diff --git a/tests/test_formdef_import.py b/tests/test_formdef_import.py
index 61abe627..c583e685 100644
--- a/tests/test_formdef_import.py
+++ b/tests/test_formdef_import.py
@@ -1,20 +1,21 @@
 # -*- coding: utf-8 -*-
 
 import io
-import pytest
 import shutil
 import time
 import xml.etree.ElementTree as ET
 
+import pytest
 from quixote import cleanup
+from utilities import create_temporary_pub
 
-from wcs.categories import Category
 from wcs.carddef import CardDef
-from wcs.formdef import FormDef, fields, FormdefImportError
-from wcs.workflows import Workflow
+from wcs.categories import Category
+from wcs.formdef import FormDef
+from wcs.formdef import FormdefImportError
+from wcs.formdef import fields
 from wcs.qommon.misc import indent_xml as indent
-
-from utilities import create_temporary_pub
+from wcs.workflows import Workflow
 
 
 def setup_module(module):
@@ -211,6 +212,7 @@ def test_workflow_options_with_no_values():
 
 def test_workflow_options_with_file():
     from quixote.http_request import Upload
+
     from wcs.qommon.form import UploadedFile
 
     upload = Upload('/foo/bar', content_type='application/vnd.oasis.opendocument.text')
diff --git a/tests/test_hobo.py b/tests/test_hobo.py
index 88e7a1ea..fb076b96 100644
--- a/tests/test_hobo.py
+++ b/tests/test_hobo.py
@@ -4,23 +4,22 @@ import copy
 import json
 import os
 import pickle
-import pytest
 import shutil
 import sys
 import tempfile
 import urllib.parse
 
 import mock
-
-from utilities import create_temporary_pub, clean_temporary_pub
-
+import pytest
 from quixote import cleanup
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
 
-from wcs.qommon import force_str
-from wcs.ctl.check_hobos import CmdCheckHobos
-from wcs.publisher import WcsPublisher
 from wcs import fields
 from wcs import sql
+from wcs.ctl.check_hobos import CmdCheckHobos
+from wcs.publisher import WcsPublisher
+from wcs.qommon import force_str
 
 HOBO_JSON = {
     'services': [
diff --git a/tests/test_hobo_notify.py b/tests/test_hobo_notify.py
index 724516ed..b4d913fe 100644
--- a/tests/test_hobo_notify.py
+++ b/tests/test_hobo_notify.py
@@ -1,14 +1,13 @@
 # -*- coding: utf-8 -*-
 import uuid
 
-from wcs.qommon import force_str
-from wcs.qommon.http_request import HTTPRequest
-from wcs.ctl.hobo_notify import CmdHoboNotify
-from wcs.qommon import storage as st
-
+import pytest
 from utilities import create_temporary_pub
 
-import pytest
+from wcs.ctl.hobo_notify import CmdHoboNotify
+from wcs.qommon import force_str
+from wcs.qommon import storage as st
+from wcs.qommon.http_request import HTTPRequest
 
 
 def pytest_generate_tests(metafunc):
diff --git a/tests/test_mail_templates.py b/tests/test_mail_templates.py
index 220cc34f..5a4bc2f7 100644
--- a/tests/test_mail_templates.py
+++ b/tests/test_mail_templates.py
@@ -3,21 +3,25 @@
 import base64
 import io
 import os
-import pytest
-from webtest import Upload
 import xml.etree.ElementTree as ET
 
+import pytest
 from django.utils.encoding import force_bytes
 from quixote import cleanup
-from wcs.formdef import FormDef
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
+from webtest import Upload
+
 from wcs.fields import FileField
+from wcs.formdef import FormDef
 from wcs.mail_templates import MailTemplate
-from wcs.workflows import Workflow, SendmailWorkflowStatusItem
-from wcs.qommon.http_request import HTTPRequest
 from wcs.qommon.form import PicklableUpload
+from wcs.qommon.http_request import HTTPRequest
 from wcs.qommon.ident.password_accounts import PasswordAccount
-
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
+from wcs.workflows import SendmailWorkflowStatusItem
+from wcs.workflows import Workflow
 
 
 def setup_module(module):
diff --git a/tests/test_misc.py b/tests/test_misc.py
index 62b78ec1..b4addf6c 100644
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -1,49 +1,49 @@
 # -*- coding: utf-8 -*-
 
+import base64
+import datetime
 import json
-import mock
-import pytest
 import os
 import pickle
 import pwd
-import socket
 import re
+import socket
 import time
-import datetime
-import base64
 
+import mock
+import pytest
+from django.core.cache import cache
 from django.utils import translation
-
 from quixote import cleanup
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
 
 import wcs.api  # workaround against circular dependencies :/
-from wcs.qommon.form import FileSizeWidget, PicklableUpload
-from wcs.qommon.humantime import humanduration2seconds, seconds2humanduration
-from wcs.qommon.misc import (
-    simplify,
-    json_loads,
-    parse_isotime,
-    format_time,
-    date_format,
-    get_as_datetime,
-    normalize_geolocation,
-    ellipsize,
-)
+import wcs.qommon.storage
 from wcs.admin.settings import FileTypesDirectory
-from wcs.scripts import Script
-from wcs.qommon import force_str, evalutils
-from wcs.qommon.http_request import HTTPRequest
-from wcs.qommon.backoffice.listing import pagination_links
-from wcs.qommon.emails import email as send_email, docutils
 from wcs.fields import StringField
-from wcs.workflows import Workflow
+from wcs.qommon import evalutils
+from wcs.qommon import force_str
+from wcs.qommon.backoffice.listing import pagination_links
+from wcs.qommon.emails import docutils
+from wcs.qommon.emails import email as send_email
+from wcs.qommon.form import FileSizeWidget
+from wcs.qommon.form import PicklableUpload
+from wcs.qommon.http_request import HTTPRequest
+from wcs.qommon.humantime import humanduration2seconds
+from wcs.qommon.humantime import seconds2humanduration
+from wcs.qommon.misc import date_format
+from wcs.qommon.misc import ellipsize
+from wcs.qommon.misc import format_time
+from wcs.qommon.misc import get_as_datetime
+from wcs.qommon.misc import json_loads
+from wcs.qommon.misc import normalize_geolocation
+from wcs.qommon.misc import parse_isotime
+from wcs.qommon.misc import simplify
+from wcs.scripts import Script
 from wcs.wf.jump import JumpWorkflowStatusItem
-import wcs.qommon.storage
-
-from django.core.cache import cache
-
-
-from utilities import get_app, create_temporary_pub, clean_temporary_pub
+from wcs.workflows import Workflow
 
 
 def setup_module(module):
diff --git a/tests/test_prefill.py b/tests/test_prefill.py
index 3d7288bb..a23e3476 100644
--- a/tests/test_prefill.py
+++ b/tests/test_prefill.py
@@ -2,13 +2,13 @@ import datetime
 import shutil
 
 import pytest
+from quixote import cleanup
+from quixote import get_request
+from utilities import create_temporary_pub
 
-from quixote import cleanup, get_request
-from wcs.qommon.http_request import HTTPRequest
 from wcs import fields
 from wcs.carddef import CardDef
-
-from utilities import create_temporary_pub
+from wcs.qommon.http_request import HTTPRequest
 
 
 def setup_module(module):
diff --git a/tests/test_publisher.py b/tests/test_publisher.py
index 955d4872..5fd80dc8 100644
--- a/tests/test_publisher.py
+++ b/tests/test_publisher.py
@@ -1,18 +1,17 @@
 import io
 import json
+import os
+import pickle
 import re
+import shutil
 import stat
 import sys
-import time
-import pickle
-import shutil
 import tempfile
-import os
+import time
 import zipfile
 
 import mock
 import pytest
-
 from django.conf import settings
 from django.core.management import call_command
 from django.core.management.base import CommandError
@@ -20,12 +19,12 @@ from django.http import Http404
 from django.test import override_settings
 from django.utils.encoding import force_text
 from quixote import cleanup
+from utilities import create_temporary_pub
+
 from wcs.qommon import get_publisher_class
 from wcs.qommon.afterjobs import AfterJob
-from wcs.qommon.http_request import HTTPRequest
 from wcs.qommon.cron import CronJob
-
-from utilities import create_temporary_pub
+from wcs.qommon.http_request import HTTPRequest
 
 
 def setup_module(module):
diff --git a/tests/test_register.py b/tests/test_register.py
index 14e23875..f7f57b1f 100644
--- a/tests/test_register.py
+++ b/tests/test_register.py
@@ -1,17 +1,19 @@
 # -*- coding: utf-8 -*-
 
-import pytest
 import hashlib
 import re
 import shutil
+
+import pytest
 from quixote import cleanup
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
 
 from wcs.qommon import force_str
 from wcs.qommon.http_request import HTTPRequest
 from wcs.qommon.ident.password_accounts import PasswordAccount
 
-from utilities import get_app, create_temporary_pub, clean_temporary_pub
-
 
 def pytest_generate_tests(metafunc):
     if 'pub' in metafunc.fixturenames:
diff --git a/tests/test_role.py b/tests/test_role.py
index cabc4d51..3a93921f 100644
--- a/tests/test_role.py
+++ b/tests/test_role.py
@@ -2,12 +2,12 @@
 
 import pickle
 
-from utilities import create_temporary_pub, clean_temporary_pub
+from quixote import get_publisher
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
 
 from wcs.roles import get_user_roles
 
-from quixote import get_publisher
-
 
 def setup_module(module):
     pub = create_temporary_pub()
diff --git a/tests/test_rootdirectory.py b/tests/test_rootdirectory.py
index ed4da92f..ed27938f 100644
--- a/tests/test_rootdirectory.py
+++ b/tests/test_rootdirectory.py
@@ -1,18 +1,18 @@
 import os
-import sys
 import shutil
+import sys
 
 import pytest
-
 from quixote import cleanup
-from wcs.qommon import sessions
+from utilities import create_temporary_pub
+from utilities import get_app
+
+import wcs.forms.root
 from wcs import formdef
-from wcs.qommon.http_request import HTTPRequest
-from wcs.formdef import FormDef
 from wcs.categories import Category
-import wcs.forms.root
-
-from utilities import get_app, create_temporary_pub
+from wcs.formdef import FormDef
+from wcs.qommon import sessions
+from wcs.qommon.http_request import HTTPRequest
 
 
 def setup_module(module):
diff --git a/tests/test_saml2utils.py b/tests/test_saml2utils.py
index eea6f897..9ca5bd8a 100644
--- a/tests/test_saml2utils.py
+++ b/tests/test_saml2utils.py
@@ -1,12 +1,11 @@
 import shutil
 
 from quixote import cleanup
+from utilities import create_temporary_pub
 
 from wcs.qommon import x509utils
 from wcs.qommon.saml2utils import Metadata
 
-from utilities import create_temporary_pub
-
 
 def setup_module(module):
     cleanup()
diff --git a/tests/test_saml_auth.py b/tests/test_saml_auth.py
index 393c2093..f1751880 100644
--- a/tests/test_saml_auth.py
+++ b/tests/test_saml_auth.py
@@ -1,8 +1,8 @@
 import datetime
 import os
 import shutil
-import uuid
 import urllib.parse
+import uuid
 
 try:
     import lasso
@@ -10,19 +10,22 @@ except ImportError:
     lasso = None
 
 import pytest
-
 from quixote import cleanup
-from quixote import get_session, get_session_manager
+from quixote import get_session
+from quixote import get_session_manager
+from test_hobo_notify import PROFILE
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+
+from wcs.qommon import sessions
+from wcs.qommon import x509utils
+from wcs.qommon.errors import RequestError
 from wcs.qommon.http_request import HTTPRequest
+from wcs.qommon.ident.idp import AdminIDPDir
+from wcs.qommon.ident.idp import MethodAdminDirectory
 from wcs.qommon.misc import get_lasso_server
 from wcs.qommon.saml2 import Saml2Directory
-from wcs.qommon.ident.idp import MethodAdminDirectory, AdminIDPDir
-from wcs.qommon import sessions, x509utils
-from wcs.qommon.errors import RequestError
-
-from utilities import get_app, create_temporary_pub, clean_temporary_pub
-
-from test_hobo_notify import PROFILE
 
 pytestmark = pytest.mark.skipif('lasso is None')
 
diff --git a/tests/test_sessions.py b/tests/test_sessions.py
index b6d6d02f..133f52c6 100644
--- a/tests/test_sessions.py
+++ b/tests/test_sessions.py
@@ -2,16 +2,18 @@ import datetime
 import os
 import shutil
 import time
-import pytest
 
+import pytest
 from quixote import cleanup
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
-from wcs.qommon.ident.password_accounts import PasswordAccount
-from wcs.qommon.http_request import HTTPRequest
-from wcs.formdef import FormDef
 from wcs import fields
-
-from utilities import create_temporary_pub, clean_temporary_pub, get_app, login
+from wcs.formdef import FormDef
+from wcs.qommon.http_request import HTTPRequest
+from wcs.qommon.ident.password_accounts import PasswordAccount
 
 
 def setup_module():
diff --git a/tests/test_snapshots.py b/tests/test_snapshots.py
index 465ddc07..6350bd0c 100644
--- a/tests/test_snapshots.py
+++ b/tests/test_snapshots.py
@@ -4,8 +4,13 @@ import shutil
 import xml.etree.ElementTree as ET
 
 import pytest
-
+from admin_pages.test_all import create_role
+from admin_pages.test_all import create_superuser
 from quixote.http_request import Upload
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 
 from wcs.blocks import BlockDef
 from wcs.carddef import CardDef
@@ -14,14 +19,12 @@ from wcs.fields import ItemField
 from wcs.formdef import FormDef
 from wcs.qommon.form import UploadedFile
 from wcs.qommon.misc import localstrftime
-from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
-from wcs.workflows import Workflow
+from wcs.wf.form import FormWorkflowStatusItem
+from wcs.wf.form import WorkflowFormFieldsFormDef
 from wcs.workflows import ExportToModel
+from wcs.workflows import Workflow
 from wcs.wscalls import NamedWsCall
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
-from admin_pages.test_all import create_superuser, create_role
-
 
 @pytest.fixture
 def pub(request, emails):
diff --git a/tests/test_sql.py b/tests/test_sql.py
index f5d50e39..9fd60907 100644
--- a/tests/test_sql.py
+++ b/tests/test_sql.py
@@ -10,23 +10,24 @@ import string
 import sys
 import time
 
+import pytest
 from django.core.management import call_command
-
 from quixote import cleanup
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
 
-from wcs.qommon import force_str
-from wcs import publisher, fields
-from wcs.formdef import FormDef
+import wcs.qommon.storage as st
+from wcs import fields
+from wcs import publisher
+from wcs import sql
 from wcs.formdata import Evolution
-from wcs.workflows import Workflow, CommentableWorkflowStatusItem, WorkflowCriticalityLevel
+from wcs.formdef import FormDef
+from wcs.qommon import force_str
 from wcs.wf.jump import JumpWorkflowStatusItem
 from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
-from wcs import sql
-import wcs.qommon.storage as st
-
-from utilities import create_temporary_pub, clean_temporary_pub
-
-import pytest
+from wcs.workflows import CommentableWorkflowStatusItem
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowCriticalityLevel
 
 postgresql = pytest.mark.postgresql
 
diff --git a/tests/test_storage.py b/tests/test_storage.py
index ec1d08cf..9bdcceaf 100644
--- a/tests/test_storage.py
+++ b/tests/test_storage.py
@@ -1,18 +1,18 @@
 import datetime
 import os
+import random
 import shutil
 import time
-import random
 
 import pytest
-
 from quixote import cleanup
+from utilities import create_temporary_pub
+
+import wcs.qommon.storage as st
 from wcs.carddef import CardDef
 from wcs.formdef import FormDef
-from wcs.qommon.storage import StorableObject, cache_umask
-import wcs.qommon.storage as st
-
-from utilities import create_temporary_pub
+from wcs.qommon.storage import StorableObject
+from wcs.qommon.storage import cache_umask
 
 
 def setup_module(module):
diff --git a/tests/test_templates.py b/tests/test_templates.py
index 7392335b..8d73cc4f 100644
--- a/tests/test_templates.py
+++ b/tests/test_templates.py
@@ -2,9 +2,10 @@
 
 import datetime
 import os
-import pytest
 import string
 
+import pytest
+
 try:
     import langdetect
 except ImportError:
@@ -12,15 +13,16 @@ except ImportError:
 
 from django.test import override_settings
 from django.utils.timezone import now
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
 
+from wcs import fields
+from wcs.formdef import FormDef
 from wcs.qommon.http_request import HTTPRequest
 from wcs.qommon.substitution import CompatibilityNamesDict
-from wcs.qommon.template import Template, TemplateError
+from wcs.qommon.template import Template
+from wcs.qommon.template import TemplateError
 from wcs.variables import LazyFormData
-from wcs.formdef import FormDef
-from wcs import fields
-
-from utilities import create_temporary_pub, clean_temporary_pub
 
 
 @pytest.fixture
diff --git a/tests/test_texts.py b/tests/test_texts.py
index 3ea1e050..186acce7 100644
--- a/tests/test_texts.py
+++ b/tests/test_texts.py
@@ -1,11 +1,12 @@
-import sys
 import shutil
+import sys
 
 from quixote import cleanup
-from wcs.qommon.http_request import HTTPRequest
-from wcs.qommon.admin.texts import TextsDirectory
+from utilities import MockSubstitutionVariables
+from utilities import create_temporary_pub
 
-from utilities import create_temporary_pub, MockSubstitutionVariables
+from wcs.qommon.admin.texts import TextsDirectory
+from wcs.qommon.http_request import HTTPRequest
 
 
 def setup_module(module):
diff --git a/tests/test_tracking_code.py b/tests/test_tracking_code.py
index 84a15d0b..75402c7c 100644
--- a/tests/test_tracking_code.py
+++ b/tests/test_tracking_code.py
@@ -1,9 +1,9 @@
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
 
 from wcs.formdef import FormDef
 
-from utilities import create_temporary_pub, clean_temporary_pub
-
 
 def pytest_generate_tests(metafunc):
     if 'pub' in metafunc.fixturenames:
diff --git a/tests/test_upload_storage.py b/tests/test_upload_storage.py
index 3b5eb2fd..6c6f77a6 100644
--- a/tests/test_upload_storage.py
+++ b/tests/test_upload_storage.py
@@ -1,20 +1,22 @@
 # -*- coding: utf-8 -*-
 
-import os
 import json
+import os
+
 import mock
 import pytest
-
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
+from utilities import login
 from webtest import Upload
 
-from wcs.qommon.ident.password_accounts import PasswordAccount
-from wcs.formdef import FormDef
-from wcs.categories import Category
 from wcs import fields
+from wcs.categories import Category
+from wcs.formdef import FormDef
+from wcs.qommon.ident.password_accounts import PasswordAccount
 from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
 
-from utilities import get_app, login, create_temporary_pub, clean_temporary_pub
-
 
 def pytest_generate_tests(metafunc):
     if 'pub' in metafunc.fixturenames:
diff --git a/tests/test_users.py b/tests/test_users.py
index 94583f93..65b55c30 100644
--- a/tests/test_users.py
+++ b/tests/test_users.py
@@ -6,15 +6,13 @@ import sys
 import time
 
 import pytest
-
 from quixote import cleanup
+from utilities import create_temporary_pub
 
-from wcs import publisher
 from wcs import fields
+from wcs import publisher
 from wcs.variables import LazyUser
 
-from utilities import create_temporary_pub
-
 
 def setup_module(module):
     cleanup()
diff --git a/tests/test_variadic_url.py b/tests/test_variadic_url.py
index e7774bc8..c6d8391b 100644
--- a/tests/test_variadic_url.py
+++ b/tests/test_variadic_url.py
@@ -1,9 +1,9 @@
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
 
-from wcs.qommon.misc import get_variadic_url
 from wcs.qommon.ezt import EZTException
-
-from utilities import create_temporary_pub, clean_temporary_pub
+from wcs.qommon.misc import get_variadic_url
 
 
 @pytest.fixture
diff --git a/tests/test_widgets.py b/tests/test_widgets.py
index c260f858..470e05c2 100644
--- a/tests/test_widgets.py
+++ b/tests/test_widgets.py
@@ -1,22 +1,21 @@
 # -*- coding: utf-8 -*-
 
+import copy
 import datetime
 import shutil
-import copy
 
-from quixote import cleanup, get_response
-from quixote.http_request import parse_query
 import mechanize
-
 import pytest
+from quixote import cleanup
+from quixote import get_response
+from quixote.http_request import parse_query
+from utilities import create_temporary_pub
 
 from wcs.qommon import sessions
 from wcs.qommon.form import *
 from wcs.qommon.http_request import HTTPRequest
 from wcs.wf.profile import ProfileUpdateRowWidget
 
-from utilities import create_temporary_pub
-
 
 def setup_module(module):
     cleanup()
diff --git a/tests/test_workflow_import.py b/tests/test_workflow_import.py
index 67ca3a07..2ca68170 100644
--- a/tests/test_workflow_import.py
+++ b/tests/test_workflow_import.py
@@ -1,44 +1,45 @@
 # -*- coding: utf-8 -*-
 
 import io
-import pytest
 import xml.etree.ElementTree as ET
 
+import pytest
 from quixote.http_request import Upload
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
 
 from wcs.carddef import CardDef
+from wcs.fields import FileField
+from wcs.fields import StringField
 from wcs.formdef import FormDef
 from wcs.mail_templates import MailTemplate
-from wcs.workflows import (
-    Workflow,
-    CommentableWorkflowStatusItem,
-    WorkflowCriticalityLevel,
-    WorkflowBackofficeFieldsFormDef,
-    SendmailWorkflowStatusItem,
-    SendSMSWorkflowStatusItem,
-    WorkflowImportError,
-    ChoiceWorkflowStatusItem,
-    JumpOnSubmitWorkflowStatusItem,
-)
+from wcs.qommon.form import UploadedFile
+from wcs.qommon.misc import indent_xml as indent
 from wcs.wf.attachment import AddAttachmentWorkflowStatusItem
-from wcs.wf.wscall import WebserviceCallStatusItem
-from wcs.wf.dispatch import DispatchWorkflowStatusItem
-from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
-from wcs.wf.profile import UpdateUserProfileStatusItem
 from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
-from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
-from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
+from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem
+from wcs.wf.create_formdata import Mapping
+from wcs.wf.dispatch import DispatchWorkflowStatusItem
 from wcs.wf.external_workflow import ExternalWorkflowGlobalAction
-from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
+from wcs.wf.form import FormWorkflowStatusItem
+from wcs.wf.form import WorkflowFormFieldsFormDef
 from wcs.wf.jump import JumpWorkflowStatusItem
-from wcs.fields import StringField, FileField
-from wcs.qommon.form import UploadedFile
-from wcs.workflows import ExportToModel, WorkflowVariablesFieldsFormDef, DisplayMessageWorkflowStatusItem
-
-
-from wcs.qommon.misc import indent_xml as indent
-
-from utilities import create_temporary_pub, clean_temporary_pub
+from wcs.wf.profile import UpdateUserProfileStatusItem
+from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
+from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
+from wcs.wf.wscall import WebserviceCallStatusItem
+from wcs.workflows import ChoiceWorkflowStatusItem
+from wcs.workflows import CommentableWorkflowStatusItem
+from wcs.workflows import DisplayMessageWorkflowStatusItem
+from wcs.workflows import ExportToModel
+from wcs.workflows import JumpOnSubmitWorkflowStatusItem
+from wcs.workflows import SendmailWorkflowStatusItem
+from wcs.workflows import SendSMSWorkflowStatusItem
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
+from wcs.workflows import WorkflowCriticalityLevel
+from wcs.workflows import WorkflowImportError
+from wcs.workflows import WorkflowVariablesFieldsFormDef
 
 
 @pytest.fixture
diff --git a/tests/test_workflows.py b/tests/test_workflows.py
index 12419b4d..7d1e5bc6 100644
--- a/tests/test_workflows.py
+++ b/tests/test_workflows.py
@@ -1,95 +1,99 @@
 import base64
+import datetime
 import io
 import json
-import datetime
 import os
-import pytest
 import shutil
 import time
 import urllib.parse
 import zipfile
 
 import mock
+import pytest
 
 try:
     from PIL import Image
 except ImportError:
     Image = None
 
-from django.utils.encoding import force_bytes, force_text
-
-from quixote import cleanup, get_response
-from wcs.qommon.errors import ConnectionError
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from quixote import cleanup
+from quixote import get_response
 from quixote.http_request import Upload as QuixoteUpload
-from wcs.qommon.http_request import HTTPRequest
-from wcs.qommon.form import PicklableUpload
-from wcs.qommon.form import *
+from utilities import MockSubstitutionVariables
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
 
+from wcs import sessions
 from wcs.blocks import BlockDef
-from wcs.formdef import FormDef
 from wcs.carddef import CardDef
-from wcs import sessions
-from wcs.fields import (
-    StringField,
-    DateField,
-    MapField,
-    FileField,
-    ItemField,
-    ItemsField,
-    CommentField,
-    EmailField,
-    PageField,
-    TitleField,
-    SubtitleField,
-    TextField,
-    BoolField,
-    TableField,
-    BlockField,
-)
+from wcs.fields import BlockField
+from wcs.fields import BoolField
+from wcs.fields import CommentField
+from wcs.fields import DateField
+from wcs.fields import EmailField
+from wcs.fields import FileField
+from wcs.fields import ItemField
+from wcs.fields import ItemsField
+from wcs.fields import MapField
+from wcs.fields import PageField
+from wcs.fields import StringField
+from wcs.fields import SubtitleField
+from wcs.fields import TableField
+from wcs.fields import TextField
+from wcs.fields import TitleField
 from wcs.formdata import Evolution
-from wcs.workflows import (
-    Workflow,
-    WorkflowStatusItem,
-    SendmailWorkflowStatusItem,
-    SendSMSWorkflowStatusItem,
-    CommentableWorkflowStatusItem,
-    ChoiceWorkflowStatusItem,
-    DisplayMessageWorkflowStatusItem,
-    AbortActionException,
-    WorkflowCriticalityLevel,
-    AttachmentEvolutionPart,
-    WorkflowBackofficeFieldsFormDef,
-    WorkflowVariablesFieldsFormDef,
-    perform_items,
-)
-from wcs.wf.aggregation_email import (
-    AggregationEmailWorkflowStatusItem,
-    AggregationEmail,
-    send_aggregation_emails,
-)
+from wcs.formdef import FormDef
+from wcs.qommon.errors import ConnectionError
+from wcs.qommon.form import PicklableUpload
+from wcs.qommon.form import *
+from wcs.qommon.http_request import HTTPRequest
+from wcs.wf.aggregation_email import AggregationEmail
+from wcs.wf.aggregation_email import AggregationEmailWorkflowStatusItem
+from wcs.wf.aggregation_email import send_aggregation_emails
 from wcs.wf.anonymise import AnonymiseWorkflowStatusItem
-from wcs.wf.criticality import ModifyCriticalityWorkflowStatusItem, MODE_INC, MODE_DEC, MODE_SET
-from wcs.wf.dispatch import DispatchWorkflowStatusItem
-from wcs.wf.form import FormWorkflowStatusItem, WorkflowFormFieldsFormDef
-from wcs.wf.jump import JumpWorkflowStatusItem, _apply_timeouts
-from wcs.wf.timeout_jump import TimeoutWorkflowStatusItem
-from wcs.wf.profile import UpdateUserProfileStatusItem
-from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem, JournalEvolutionPart
-from wcs.wf.remove import RemoveWorkflowStatusItem
-from wcs.wf.roles import AddRoleWorkflowStatusItem, RemoveRoleWorkflowStatusItem
-from wcs.wf.wscall import WebserviceCallStatusItem
-from wcs.wf.export_to_model import ExportToModel, transform_to_pdf
-from wcs.wf.geolocate import GeolocateWorkflowStatusItem
 from wcs.wf.backoffice_fields import SetBackofficeFieldsWorkflowStatusItem
-from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
-from wcs.wf.notification import SendNotificationWorkflowStatusItem
-from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, Mapping
 from wcs.wf.create_carddata import CreateCarddataWorkflowStatusItem
+from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem
+from wcs.wf.create_formdata import Mapping
+from wcs.wf.criticality import MODE_DEC
+from wcs.wf.criticality import MODE_INC
+from wcs.wf.criticality import MODE_SET
+from wcs.wf.criticality import ModifyCriticalityWorkflowStatusItem
+from wcs.wf.dispatch import DispatchWorkflowStatusItem
 from wcs.wf.edit_carddata import EditCarddataWorkflowStatusItem
+from wcs.wf.export_to_model import ExportToModel
+from wcs.wf.export_to_model import transform_to_pdf
 from wcs.wf.external_workflow import ExternalWorkflowGlobalAction
-
-
-from utilities import create_temporary_pub, MockSubstitutionVariables, clean_temporary_pub
+from wcs.wf.form import FormWorkflowStatusItem
+from wcs.wf.form import WorkflowFormFieldsFormDef
+from wcs.wf.geolocate import GeolocateWorkflowStatusItem
+from wcs.wf.jump import JumpWorkflowStatusItem
+from wcs.wf.jump import _apply_timeouts
+from wcs.wf.notification import SendNotificationWorkflowStatusItem
+from wcs.wf.profile import UpdateUserProfileStatusItem
+from wcs.wf.redirect_to_url import RedirectToUrlWorkflowStatusItem
+from wcs.wf.register_comment import JournalEvolutionPart
+from wcs.wf.register_comment import RegisterCommenterWorkflowStatusItem
+from wcs.wf.remove import RemoveWorkflowStatusItem
+from wcs.wf.roles import AddRoleWorkflowStatusItem
+from wcs.wf.roles import RemoveRoleWorkflowStatusItem
+from wcs.wf.timeout_jump import TimeoutWorkflowStatusItem
+from wcs.wf.wscall import WebserviceCallStatusItem
+from wcs.workflows import AbortActionException
+from wcs.workflows import AttachmentEvolutionPart
+from wcs.workflows import ChoiceWorkflowStatusItem
+from wcs.workflows import CommentableWorkflowStatusItem
+from wcs.workflows import DisplayMessageWorkflowStatusItem
+from wcs.workflows import SendmailWorkflowStatusItem
+from wcs.workflows import SendSMSWorkflowStatusItem
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
+from wcs.workflows import WorkflowCriticalityLevel
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import WorkflowVariablesFieldsFormDef
+from wcs.workflows import perform_items
 
 
 def setup_module(module):
diff --git a/tests/test_wscall.py b/tests/test_wscall.py
index 95a73f4e..c4b5266c 100644
--- a/tests/test_wscall.py
+++ b/tests/test_wscall.py
@@ -1,5 +1,9 @@
 import json
+
 import pytest
+from utilities import clean_temporary_pub
+from utilities import create_temporary_pub
+from utilities import get_app
 
 from wcs import fields
 from wcs.formdef import FormDef
@@ -7,8 +11,6 @@ from wcs.qommon.http_request import HTTPRequest
 from wcs.qommon.template import Template
 from wcs.wscalls import NamedWsCall
 
-from utilities import get_app, create_temporary_pub, clean_temporary_pub
-
 
 @pytest.fixture
 def pub():
diff --git a/tests/utilities.py b/tests/utilities.py
index a409ba58..cc4b1d84 100644
--- a/tests/utilities.py
+++ b/tests/utilities.py
@@ -2,32 +2,34 @@ import email.header
 import email.parser
 import json
 import os
-import tempfile
 import random
-import psycopg2
 import shutil
 import sys
+import tempfile
 import urllib.parse
 
-from wcs import sql, sessions, custom_views
-
-from webtest import TestApp
-from quixote import cleanup, get_publisher
+import psycopg2
 from django.conf import settings
-from django.utils.encoding import force_bytes, force_text
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from quixote import cleanup
+from quixote import get_publisher
+from webtest import TestApp
 
-from wcs.qommon import force_str
 import wcs
+import wcs.middleware
+import wcs.qommon.emails
+import wcs.qommon.sms
 import wcs.wsgi
 from wcs import compat
+from wcs import custom_views
+from wcs import sessions
+from wcs import sql
+from wcs.qommon import force_str
+from wcs.qommon.errors import ConnectionError
 from wcs.roles import Role
-from wcs.users import User
 from wcs.tracking_code import TrackingCode
-import wcs.qommon.emails
-import wcs.qommon.sms
-from wcs.qommon.errors import ConnectionError
-
-import wcs.middleware
+from wcs.users import User
 
 wcs.middleware.AfterJobsMiddleware.ASYNC = False
 
diff --git a/wcs/__init__.py b/wcs/__init__.py
index c1e9ffbf..1faa4ac4 100644
--- a/wcs/__init__.py
+++ b/wcs/__init__.py
@@ -14,10 +14,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-import sys
 import os
+import sys
 
 sys.path.insert(0, os.path.dirname(__file__))
 
-from . import monkeypatch
-from . import compat
+from . import monkeypatch  # isort: skip
+from . import compat  # isort: skip
diff --git a/wcs/admin/api_access.py b/wcs/admin/api_access.py
index 4e5a7436..e5e5e58a 100644
--- a/wcs/admin/api_access.py
+++ b/wcs/admin/api_access.py
@@ -16,14 +16,21 @@
 
 import uuid
 
-from quixote import get_response, redirect
+from quixote import get_response
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from wcs.qommon import _, errors, template
-from wcs.qommon.form import Form, StringWidget, TextWidget, HtmlWidget
-from wcs.qommon.backoffice.menu import html_top
 from wcs.api_access import ApiAccess
+from wcs.qommon import _
+from wcs.qommon import errors
+from wcs.qommon import template
+from wcs.qommon.backoffice.menu import html_top
+from wcs.qommon.form import Form
+from wcs.qommon.form import HtmlWidget
+from wcs.qommon.form import StringWidget
+from wcs.qommon.form import TextWidget
 
 
 class ApiAccessUI(object):
diff --git a/wcs/admin/blocks.py b/wcs/admin/blocks.py
index a8ee8947..93e760b3 100644
--- a/wcs/admin/blocks.py
+++ b/wcs/admin/blocks.py
@@ -16,19 +16,29 @@
 
 import xml.etree.ElementTree as ET
 
-from quixote import get_publisher, get_response, get_session, redirect
+from quixote import get_publisher
+from quixote import get_response
+from quixote import get_session
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from wcs.blocks import BlockDef, BlockdefImportError
-
-from wcs.qommon.form import Form, StringWidget, HtmlWidget, FileWidget
-from wcs.qommon import _, N_, misc, template
-from wcs.qommon.backoffice.menu import html_top
-
-from wcs.admin.fields import FieldDefPage, FieldsDirectory
 from wcs.admin import utils
+from wcs.admin.fields import FieldDefPage
+from wcs.admin.fields import FieldsDirectory
 from wcs.backoffice.snapshots import SnapshotsDirectory
+from wcs.blocks import BlockDef
+from wcs.blocks import BlockdefImportError
+from wcs.qommon import N_
+from wcs.qommon import _
+from wcs.qommon import misc
+from wcs.qommon import template
+from wcs.qommon.backoffice.menu import html_top
+from wcs.qommon.form import FileWidget
+from wcs.qommon.form import Form
+from wcs.qommon.form import HtmlWidget
+from wcs.qommon.form import StringWidget
 
 
 class BlockFieldDefPage(FieldDefPage):
diff --git a/wcs/admin/categories.py b/wcs/admin/categories.py
index 9f543243..1998e647 100644
--- a/wcs/admin/categories.py
+++ b/wcs/admin/categories.py
@@ -16,15 +16,17 @@
 
 from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
-
-from wcs.qommon import _, N_
-from wcs.categories import Category, CardDefCategory
-from wcs.qommon.form import *
-from wcs.qommon.backoffice.menu import html_top
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
 from wcs.carddef import CardDef
+from wcs.categories import CardDefCategory
+from wcs.categories import Category
 from wcs.formdef import FormDef
+from wcs.qommon import N_
+from wcs.qommon import _
+from wcs.qommon.backoffice.menu import html_top
+from wcs.qommon.form import *
 
 
 class CategoryUI(object):
diff --git a/wcs/admin/data_sources.py b/wcs/admin/data_sources.py
index 1cf854c8..6fdf31db 100644
--- a/wcs/admin/data_sources.py
+++ b/wcs/admin/data_sources.py
@@ -16,31 +16,34 @@
 
 import xml.etree.ElementTree as ET
 
-from quixote import get_publisher, redirect
+from quixote import get_publisher
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
 from wcs.admin import utils
-from wcs.qommon import _, force_str
-from wcs.qommon import errors, template
-from wcs.qommon.form import *
+from wcs.backoffice.snapshots import SnapshotsDirectory
+from wcs.carddef import CardDef
+from wcs.data_sources import DataSourceSelectionWidget
+from wcs.data_sources import NamedDataSource
+from wcs.data_sources import RefreshAgendas
+from wcs.data_sources import get_structured_items
+from wcs.data_sources import has_chrono
+from wcs.formdef import FormDef
+from wcs.formdef import get_formdefs_of_all_kinds
+from wcs.qommon import _
+from wcs.qommon import errors
+from wcs.qommon import force_str
+from wcs.qommon import misc
+from wcs.qommon import template
+from wcs.qommon.backoffice.menu import html_top
 from wcs.qommon.form import FileWidget
 from wcs.qommon.form import Form
 from wcs.qommon.form import UrlWidget
+from wcs.qommon.form import *
 from wcs.qommon.form import get_response
 from wcs.qommon.form import get_session
-from wcs.qommon import misc
-from wcs.qommon.backoffice.menu import html_top
-from wcs.carddef import CardDef
-from wcs.data_sources import (
-    NamedDataSource,
-    DataSourceSelectionWidget,
-    get_structured_items,
-    has_chrono,
-    RefreshAgendas,
-)
-from wcs.formdef import FormDef, get_formdefs_of_all_kinds
-from wcs.backoffice.snapshots import SnapshotsDirectory
 
 
 class NamedDataSourceUI(object):
diff --git a/wcs/admin/fields.py b/wcs/admin/fields.py
index c0325a75..588cceb4 100644
--- a/wcs/admin/fields.py
+++ b/wcs/admin/fields.py
@@ -21,19 +21,21 @@ import json
 
 from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext, htmlescape
+from quixote.html import TemplateIO
+from quixote.html import htmlescape
+from quixote.html import htmltext
 
+from wcs import fields
 from wcs.admin import utils
+from wcs.fields import get_field_options
+from wcs.formdef import FormDef
 from wcs.qommon import _
-from wcs.qommon.form import *
-from wcs.qommon import errors, misc
+from wcs.qommon import errors
 from wcs.qommon import get_cfg
-from wcs.qommon.backoffice.menu import html_top
+from wcs.qommon import misc
 from wcs.qommon.admin.menu import command_icon
-
-from wcs import fields
-from wcs.formdef import FormDef
-from wcs.fields import get_field_options
+from wcs.qommon.backoffice.menu import html_top
+from wcs.qommon.form import *
 
 
 class FieldDefPage(Directory):
diff --git a/wcs/admin/forms.py b/wcs/admin/forms.py
index 430e9b7c..9ecab250 100644
--- a/wcs/admin/forms.py
+++ b/wcs/admin/forms.py
@@ -16,44 +16,55 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-import io
-import xml.etree.ElementTree as ET
 import datetime
 import difflib
+import io
 import tarfile
 import time
+import xml.etree.ElementTree as ET
 
-from quixote import get_publisher, get_response, redirect
-from quixote.directory import Directory, AccessControlled
-from quixote.html import TemplateIO, htmltext
+from quixote import get_publisher
+from quixote import get_response
+from quixote import redirect
+from quixote.directory import AccessControlled
+from quixote.directory import Directory
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from wcs.qommon import _, N_, force_str
-from wcs.qommon import misc, template
+from wcs.backoffice.snapshots import SnapshotsDirectory
+from wcs.carddef import CardDef
+from wcs.categories import Category
+from wcs.formdef import DRAFTS_DEFAULT_LIFESPAN
+from wcs.formdef import FormDef
+from wcs.formdef import FormdefImportError
+from wcs.formdef import FormdefImportRecoverableError
+from wcs.forms.root import qrcode
+from wcs.qommon import N_
+from wcs.qommon import _
+from wcs.qommon import force_str
+from wcs.qommon import get_logger
+from wcs.qommon import misc
+from wcs.qommon import template
+from wcs.qommon.afterjobs import AfterJob
+from wcs.qommon.backoffice.menu import html_top
 from wcs.qommon.errors import TraversalError
 from wcs.qommon.form import *
-from wcs.qommon.storage import Equal, NotEqual, Null
-from wcs.qommon.backoffice.menu import html_top
-from wcs.qommon import get_logger
 from wcs.qommon.misc import C_
-
-from wcs.qommon.afterjobs import AfterJob
-
-from wcs.formdef import FormDef, FormdefImportError, FormdefImportRecoverableError, DRAFTS_DEFAULT_LIFESPAN
-from wcs.carddef import CardDef
-from wcs.categories import Category
-from wcs.roles import logged_users_role, get_user_roles
+from wcs.qommon.storage import Equal
+from wcs.qommon.storage import NotEqual
+from wcs.qommon.storage import Null
+from wcs.roles import get_user_roles
+from wcs.roles import logged_users_role
 from wcs.workflows import Workflow
-from wcs.forms.root import qrcode
 
 from . import utils
 from .blocks import BlocksDirectory
-from .fields import FieldDefPage, FieldsDirectory
 from .categories import CategoriesDirectory
 from .data_sources import NamedDataSourcesDirectory
+from .fields import FieldDefPage
+from .fields import FieldsDirectory
 from .logged_errors import LoggedErrorsDirectory
 
-from wcs.backoffice.snapshots import SnapshotsDirectory
-
 
 def get_categories(category_class):
     t = sorted([(misc.simplify(x.name), x.id, x.name, x.id) for x in category_class.select()])
diff --git a/wcs/admin/logged_errors.py b/wcs/admin/logged_errors.py
index 96c5672c..0d01b0bf 100644
--- a/wcs/admin/logged_errors.py
+++ b/wcs/admin/logged_errors.py
@@ -17,14 +17,26 @@
 import re
 
 from django.utils.text import Truncator
-from quixote import get_response, get_publisher, redirect, get_request
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
-from wcs.qommon import _, ngettext, N_, template
+from quixote.html import TemplateIO
+from quixote.html import htmltext
+
+from wcs.qommon import N_
+from wcs.qommon import _
 from wcs.qommon import errors
 from wcs.qommon import misc
+from wcs.qommon import ngettext
+from wcs.qommon import template
 from wcs.qommon.backoffice.listing import pagination_links
-from wcs.qommon.storage import Or, Equal, NotEqual, Null, NotNull
+from wcs.qommon.storage import Equal
+from wcs.qommon.storage import NotEqual
+from wcs.qommon.storage import NotNull
+from wcs.qommon.storage import Null
+from wcs.qommon.storage import Or
 
 
 class LoggedErrorDirectory(Directory):
diff --git a/wcs/admin/mail_templates.py b/wcs/admin/mail_templates.py
index 8189a936..ffed6a21 100644
--- a/wcs/admin/mail_templates.py
+++ b/wcs/admin/mail_templates.py
@@ -16,23 +16,28 @@
 
 import xml.etree.ElementTree as ET
 
-from quixote import get_publisher, get_response, redirect
+from quixote import get_publisher
+from quixote import get_response
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from wcs.qommon import _, errors, force_str, misc, template
-from wcs.qommon.backoffice.menu import html_top
-from wcs.qommon.form import (
-    Form,
-    HtmlWidget,
-    StringWidget,
-    TextWidget,
-    ComputedExpressionWidget,
-    WidgetList,
-    FileWidget,
-    get_session,
-)
 from wcs.mail_templates import MailTemplate
+from wcs.qommon import _
+from wcs.qommon import errors
+from wcs.qommon import force_str
+from wcs.qommon import misc
+from wcs.qommon import template
+from wcs.qommon.backoffice.menu import html_top
+from wcs.qommon.form import ComputedExpressionWidget
+from wcs.qommon.form import FileWidget
+from wcs.qommon.form import Form
+from wcs.qommon.form import HtmlWidget
+from wcs.qommon.form import StringWidget
+from wcs.qommon.form import TextWidget
+from wcs.qommon.form import WidgetList
+from wcs.qommon.form import get_session
 
 
 class MailTemplatesDirectory(Directory):
diff --git a/wcs/admin/roles.py b/wcs/admin/roles.py
index 656c6658..24494de9 100644
--- a/wcs/admin/roles.py
+++ b/wcs/admin/roles.py
@@ -16,16 +16,16 @@
 
 from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from wcs.qommon import _, get_cfg
+from wcs.formdef import FormDef
+from wcs.qommon import _
 from wcs.qommon import errors
-from wcs.qommon.form import *
-
+from wcs.qommon import get_cfg
 from wcs.qommon.backoffice.menu import html_top
-
+from wcs.qommon.form import *
 from wcs.roles import get_user_roles
-from wcs.formdef import FormDef
 
 
 class RoleUI(object):
diff --git a/wcs/admin/root.py b/wcs/admin/root.py
index f4de3559..89a99c54 100644
--- a/wcs/admin/root.py
+++ b/wcs/admin/root.py
@@ -14,7 +14,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_request, redirect
+from quixote import get_request
+from quixote import redirect
 from quixote.directory import Directory
 
 
diff --git a/wcs/admin/settings.py b/wcs/admin/settings.py
index 038332e4..ac31b084 100644
--- a/wcs/admin/settings.py
+++ b/wcs/admin/settings.py
@@ -24,46 +24,49 @@ try:
     import lasso
 except ImportError:
     lasso = None
-import zipfile
 import shutil
-
 import xml.etree.ElementTree as ET
+import zipfile
 
 from django.utils.encoding import force_bytes
-
-from quixote import get_publisher, get_request, get_response, redirect
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from wcs.qommon import _, N_
-from wcs.qommon import get_cfg
+from wcs.backoffice.studio import StudioDirectory
+from wcs.blocks import BlockDef
+from wcs.carddef import CardDef
+from wcs.data_sources import NamedDataSource
+from wcs.formdef import FormDef
+from wcs.qommon import N_
+from wcs.qommon import _
 from wcs.qommon import errors
+from wcs.qommon import get_cfg
+from wcs.qommon import ident
 from wcs.qommon import misc
 from wcs.qommon import template
-from wcs.qommon.form import *
-from wcs.qommon.sms import SMS
-
-from wcs.qommon.afterjobs import AfterJob
-from wcs.qommon.backoffice.menu import html_top
-from wcs.qommon.admin.menu import error_page
 from wcs.qommon.admin.cfg import cfg_submit
 from wcs.qommon.admin.emails import EmailsDirectory
-from wcs.qommon.admin.texts import TextsDirectory
-from wcs.qommon.admin.settings import SettingsDirectory as QommonSettingsDirectory
 from wcs.qommon.admin.logger import LoggerDirectory
-from wcs.qommon import ident
-
-from wcs.blocks import BlockDef
-from wcs.carddef import CardDef
-from wcs.data_sources import NamedDataSource
-from wcs.formdef import FormDef
-from wcs.workflows import Workflow, WorkflowImportError
+from wcs.qommon.admin.menu import error_page
+from wcs.qommon.admin.settings import SettingsDirectory as QommonSettingsDirectory
+from wcs.qommon.admin.texts import TextsDirectory
+from wcs.qommon.afterjobs import AfterJob
+from wcs.qommon.backoffice.menu import html_top
+from wcs.qommon.form import *
+from wcs.qommon.sms import SMS
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowImportError
 
-from wcs.backoffice.studio import StudioDirectory
-from .fields import FieldDefPage, FieldsDirectory
+from .api_access import ApiAccessDirectory
 from .data_sources import NamedDataSourcesDirectory
+from .fields import FieldDefPage
+from .fields import FieldsDirectory
 from .wscalls import NamedWsCallsDirectory
-from .api_access import ApiAccessDirectory
 
 
 class UserFormDirectory(Directory):
@@ -935,7 +938,8 @@ class SettingsDirectory(QommonSettingsDirectory):
         return r.getvalue()
 
     def template_submit(self, form=None):
-        from wcs.qommon.template import DEFAULT_TEMPLATE_EZT, get_default_ezt_template
+        from wcs.qommon.template import DEFAULT_TEMPLATE_EZT
+        from wcs.qommon.template import get_default_ezt_template
 
         theme_default_template_ezt = get_default_ezt_template()
 
diff --git a/wcs/admin/users.py b/wcs/admin/users.py
index 7b0931a3..8b115340 100644
--- a/wcs/admin/users.py
+++ b/wcs/admin/users.py
@@ -14,22 +14,30 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_publisher, get_response, get_request, get_session, redirect
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from wcs.qommon import _, N_, force_str
 import wcs.qommon.storage as st
+from wcs.qommon import N_
+from wcs.qommon import _
 from wcs.qommon import errors
-from wcs.qommon import misc, get_cfg
-from wcs.qommon.backoffice.listing import pagination_links
-
+from wcs.qommon import force_str
+from wcs.qommon import get_cfg
 from wcs.qommon import ident
-from wcs.qommon.ident.idp import is_idp_managing_user_attributes, is_idp_managing_user_roles
-from wcs.qommon.form import *
+from wcs.qommon import misc
 from wcs.qommon.admin.emails import EmailsDirectory
-from wcs.qommon.backoffice.menu import html_top
 from wcs.qommon.admin.menu import error_page
+from wcs.qommon.backoffice.listing import pagination_links
+from wcs.qommon.backoffice.menu import html_top
+from wcs.qommon.form import *
+from wcs.qommon.ident.idp import is_idp_managing_user_attributes
+from wcs.qommon.ident.idp import is_idp_managing_user_roles
 
 
 class UserUI(object):
diff --git a/wcs/admin/utils.py b/wcs/admin/utils.py
index a1ff2611..feb2bf57 100644
--- a/wcs/admin/utils.py
+++ b/wcs/admin/utils.py
@@ -18,10 +18,12 @@
 
 import time
 
-from quixote import get_publisher, get_request
-from quixote.html import TemplateIO, htmltext
-
-from qommon import _, misc
+from qommon import _
+from qommon import misc
+from quixote import get_publisher
+from quixote import get_request
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
 
 def last_modification_block(obj):
diff --git a/wcs/admin/workflows.py b/wcs/admin/workflows.py
index 0aa695d3..08a88c7a 100644
--- a/wcs/admin/workflows.py
+++ b/wcs/admin/workflows.py
@@ -19,37 +19,41 @@
 from __future__ import print_function
 
 import io
-import time
-from subprocess import Popen, PIPE
 import textwrap
+import time
 import xml.etree.ElementTree as ET
+from subprocess import PIPE
+from subprocess import Popen
 
 from django.utils.encoding import force_bytes
-
-from quixote import redirect, get_publisher, get_response
+from quixote import get_publisher
+from quixote import get_response
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from wcs.qommon import _, force_str
+from wcs.backoffice.snapshots import SnapshotsDirectory
+from wcs.backoffice.studio import StudioDirectory
+from wcs.carddef import CardDef
+from wcs.formdata import Evolution
+from wcs.formdef import FormDef
+from wcs.qommon import _
 from wcs.qommon import errors
+from wcs.qommon import force_str
+from wcs.qommon import get_logger
 from wcs.qommon import misc
-from wcs.qommon.form import *
-from wcs.qommon.backoffice.menu import html_top
 from wcs.qommon.admin.menu import command_icon
-from wcs.qommon import get_logger
-
+from wcs.qommon.backoffice.menu import html_top
+from wcs.qommon.form import *
 from wcs.workflows import *
-from wcs.carddef import CardDef
-from wcs.formdef import FormDef
-from wcs.formdata import Evolution
 
 from . import utils
-from .fields import FieldDefPage, FieldsDirectory
 from .data_sources import NamedDataSourcesDirectory
+from .fields import FieldDefPage
+from .fields import FieldsDirectory
 from .logged_errors import LoggedErrorsDirectory
 from .mail_templates import MailTemplatesDirectory
-from wcs.backoffice.snapshots import SnapshotsDirectory
-from wcs.backoffice.studio import StudioDirectory
 
 
 def svg(tag):
diff --git a/wcs/admin/wscalls.py b/wcs/admin/wscalls.py
index 8244cb4e..a788c51b 100644
--- a/wcs/admin/wscalls.py
+++ b/wcs/admin/wscalls.py
@@ -16,17 +16,23 @@
 
 import xml.etree.ElementTree as ET
 
-from quixote import get_publisher, get_response, redirect
+from quixote import get_publisher
+from quixote import get_response
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
 from wcs.admin import utils
-from wcs.qommon import _, errors, template
+from wcs.backoffice.snapshots import SnapshotsDirectory
+from wcs.qommon import _
+from wcs.qommon import errors
 from wcs.qommon import misc
-from wcs.qommon.form import *
+from wcs.qommon import template
 from wcs.qommon.backoffice.menu import html_top
-from wcs.wscalls import NamedWsCall, WsCallRequestWidget
-from wcs.backoffice.snapshots import SnapshotsDirectory
+from wcs.qommon.form import *
+from wcs.wscalls import NamedWsCall
+from wcs.wscalls import WsCallRequestWidget
 
 
 class NamedWsCallUI(object):
diff --git a/wcs/api.py b/wcs/api.py
index 2e81315f..093d2d7b 100644
--- a/wcs/api.py
+++ b/wcs/api.py
@@ -21,40 +21,46 @@ import sys
 import time
 import urllib.parse
 
-from quixote import get_request, get_publisher, get_response, get_session
-from quixote.errors import MethodNotAllowedError
-from quixote.directory import Directory
-
+from django.http import HttpResponse
+from django.http import HttpResponseBadRequest
+from django.http import JsonResponse
 from django.utils.encoding import force_text
-from django.http import HttpResponse, HttpResponseBadRequest, JsonResponse
-
-from .qommon import _
-from .qommon import misc
-from .qommon.errors import (
-    AccessForbiddenError,
-    TraversalError,
-    UnknownNameIdAccessForbiddenError,
-    ConnectionError,
-)
-from .qommon.form import ComputedExpressionWidget
-from .qommon.storage import Equal, NotEqual
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
+from quixote.directory import Directory
+from quixote.errors import MethodNotAllowedError
 
-from wcs.categories import Category
-from wcs.conditions import Condition, ValidationError
+import wcs.qommon.storage as st
+from wcs.api_utils import get_query_flag
+from wcs.api_utils import get_user_from_api_query_string
+from wcs.api_utils import is_url_signed
+from wcs.api_utils import sign_url_auto_orig
 from wcs.carddef import CardDef
-from wcs.formdef import FormDef
+from wcs.categories import Category
+from wcs.conditions import Condition
+from wcs.conditions import ValidationError
 from wcs.data_sources import NamedDataSource
 from wcs.data_sources import get_object as get_data_source_object
-from wcs.roles import logged_users_role
+from wcs.formdef import FormDef
 from wcs.forms.common import FormStatusPage
 from wcs.qommon.afterjobs import AfterJob
-import wcs.qommon.storage as st
-from wcs.api_utils import sign_url_auto_orig, is_url_signed, get_user_from_api_query_string, get_query_flag
+from wcs.roles import logged_users_role
 
+from .backoffice.data_management import CardPage as BackofficeCardPage
 from .backoffice.management import FormPage as BackofficeFormPage
 from .backoffice.management import ManagementDirectory
-from .backoffice.data_management import CardPage as BackofficeCardPage
 from .backoffice.submission import SubmissionDirectory
+from .qommon import _
+from .qommon import misc
+from .qommon.errors import AccessForbiddenError
+from .qommon.errors import ConnectionError
+from .qommon.errors import TraversalError
+from .qommon.errors import UnknownNameIdAccessForbiddenError
+from .qommon.form import ComputedExpressionWidget
+from .qommon.storage import Equal
+from .qommon.storage import NotEqual
 
 
 def posted_json_data_to_formdata_data(formdef, data):
@@ -848,6 +854,7 @@ class ApiUserDirectory(Directory):
 
         if get_publisher().is_using_postgresql() and not get_request().form.get('full') == 'on':
             from wcs import sql
+
             from .qommon.storage import Equal
 
             order_by = 'receipt_time'
diff --git a/wcs/api_utils.py b/wcs/api_utils.py
index ab253fc7..696cadc6 100644
--- a/wcs/api_utils.py
+++ b/wcs/api_utils.py
@@ -15,21 +15,25 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 import base64
-import hmac
-import hashlib
+import calendar
 import datetime
-import random
+import errno
+import hashlib
+import hmac
 import os
+import random
 import urllib.parse
-import errno
-import calendar
 
-from django.utils.encoding import force_bytes, force_text
+import qommon.misc
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from quixote import get_publisher
+from quixote import get_request
 
-from quixote import get_request, get_publisher
 from .api_access import ApiAccess
-from .qommon.errors import AccessForbiddenError, HttpResponse401Error, UnknownNameIdAccessForbiddenError
-import qommon.misc
+from .qommon.errors import AccessForbiddenError
+from .qommon.errors import HttpResponse401Error
+from .qommon.errors import UnknownNameIdAccessForbiddenError
 
 DEFAULT_DURATION = 30
 
diff --git a/wcs/backoffice/cards.py b/wcs/backoffice/cards.py
index 46f90c1b..bb7f92df 100644
--- a/wcs/backoffice/cards.py
+++ b/wcs/backoffice/cards.py
@@ -16,21 +16,31 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_publisher, get_response, get_session, redirect
+from quixote import get_publisher
+from quixote import get_response
+from quixote import get_session
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
-
-from ..qommon import _, N_
-from ..qommon.misc import C_
-from ..qommon.storage import NotEqual, Null
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
+from wcs.admin import utils
+from wcs.admin.categories import CardDefCategoriesDirectory
+from wcs.admin.forms import FormDefPage
+from wcs.admin.forms import FormDefUI
+from wcs.admin.forms import FormsDirectory
+from wcs.admin.forms import OptionsDirectory
+from wcs.admin.forms import html_top
+from wcs.admin.logged_errors import LoggedErrorsDirectory
 from wcs.carddef import CardDef
 from wcs.categories import CardDefCategory
 from wcs.workflows import Workflow
-from wcs.admin.categories import CardDefCategoriesDirectory
-from wcs.admin.forms import FormsDirectory, FormDefPage, FormDefUI, html_top, OptionsDirectory
-from wcs.admin.logged_errors import LoggedErrorsDirectory
-from wcs.admin import utils
+
+from ..qommon import N_
+from ..qommon import _
+from ..qommon.misc import C_
+from ..qommon.storage import NotEqual
+from ..qommon.storage import Null
 
 
 class CardDefUI(FormDefUI):
diff --git a/wcs/backoffice/data_management.py b/wcs/backoffice/data_management.py
index 40d99e7f..e8fd2c86 100644
--- a/wcs/backoffice/data_management.py
+++ b/wcs/backoffice/data_management.py
@@ -18,25 +18,31 @@ import csv
 import datetime
 import io
 
-from quixote import get_publisher, get_request, get_response, redirect
-from quixote.html import TemplateIO, htmltext, htmlescape
-
 from django.utils.encoding import force_text
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import redirect
+from quixote.html import TemplateIO
+from quixote.html import htmlescape
+from quixote.html import htmltext
 
+from wcs import fields
+from wcs.carddef import CardDef
+from wcs.categories import CardDefCategory
 
-from ..qommon import _, N_
+from ..qommon import N_
+from ..qommon import _
 from ..qommon import errors
 from ..qommon import template
-from ..qommon.form import Form, FileWidget
-from ..qommon.backoffice.menu import html_top
-from ..qommon import template
 from ..qommon.afterjobs import AfterJob
-
-from wcs.carddef import CardDef
-from wcs.categories import CardDefCategory
-from wcs import fields
-
-from .management import ManagementDirectory, FormPage, FormFillPage, FormBackOfficeStatusPage
+from ..qommon.backoffice.menu import html_top
+from ..qommon.form import FileWidget
+from ..qommon.form import Form
+from .management import FormBackOfficeStatusPage
+from .management import FormFillPage
+from .management import FormPage
+from .management import ManagementDirectory
 
 
 class DataManagementDirectory(ManagementDirectory):
diff --git a/wcs/backoffice/management.py b/wcs/backoffice/management.py
index c3601b82..4d685bba 100644
--- a/wcs/backoffice/management.py
+++ b/wcs/backoffice/management.py
@@ -22,60 +22,69 @@ import re
 import time
 import types
 import urllib.parse
-import vobject
 import zipfile
 
+import vobject
 from django.conf import settings
 from django.utils.encoding import force_text
-
-from quixote import get_session, get_publisher, get_request, get_response, redirect
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext, htmlescape
-
-from ..qommon import _, ngettext, N_, ezt, force_str
-from ..qommon.admin.emails import EmailsDirectory
-from ..qommon.admin.menu import command_icon
-from ..qommon.backoffice.menu import html_top
-from ..qommon.backoffice.listing import pagination_links
-from ..qommon import misc, get_logger
-from ..qommon.evalutils import make_datetime
-from ..qommon.misc import C_, ellipsize
-from ..qommon.afterjobs import AfterJob
-from ..qommon.substitution import CompatibilityNamesDict
-from ..qommon import emails
-from ..qommon import sms
-from ..qommon import errors
-from ..qommon import ods
-from ..qommon.form import *
-from ..qommon.form import PicklableUpload
-from ..qommon.storage import (
-    Equal,
-    NotEqual,
-    LessOrEqual,
-    GreaterOrEqual,
-    Or,
-    Intersects,
-    ILike,
-    FtsMatch,
-    Contains,
-    Null,
-    NotNull,
-)
-from ..qommon.template import Template
+from quixote.html import TemplateIO
+from quixote.html import htmlescape
+from quixote.html import htmltext
 
+from wcs.admin.settings import UserFieldsFormDef
 from wcs.api_utils import get_user_from_api_query_string
 from wcs.carddef import CardDef
-from wcs.conditions import Condition
-from wcs.forms.backoffice import FormDefUI
-from wcs.forms.common import FormStatusPage
-from wcs.admin.settings import UserFieldsFormDef
 from wcs.categories import Category
+from wcs.conditions import Condition
 from wcs.formdata import FormData
 from wcs.formdef import FormDef
+from wcs.forms.backoffice import FormDefUI
+from wcs.forms.common import FormStatusPage
 from wcs.roles import logged_users_role
 from wcs.variables import LazyFieldVar
-from wcs.workflows import template_on_formdata, WorkflowStatusItem
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import template_on_formdata
 
+from ..qommon import N_
+from ..qommon import _
+from ..qommon import emails
+from ..qommon import errors
+from ..qommon import ezt
+from ..qommon import force_str
+from ..qommon import get_logger
+from ..qommon import misc
+from ..qommon import ngettext
+from ..qommon import ods
+from ..qommon import sms
+from ..qommon.admin.emails import EmailsDirectory
+from ..qommon.admin.menu import command_icon
+from ..qommon.afterjobs import AfterJob
+from ..qommon.backoffice.listing import pagination_links
+from ..qommon.backoffice.menu import html_top
+from ..qommon.evalutils import make_datetime
+from ..qommon.form import PicklableUpload
+from ..qommon.form import *
+from ..qommon.misc import C_
+from ..qommon.misc import ellipsize
+from ..qommon.storage import Contains
+from ..qommon.storage import Equal
+from ..qommon.storage import FtsMatch
+from ..qommon.storage import GreaterOrEqual
+from ..qommon.storage import ILike
+from ..qommon.storage import Intersects
+from ..qommon.storage import LessOrEqual
+from ..qommon.storage import NotEqual
+from ..qommon.storage import NotNull
+from ..qommon.storage import Null
+from ..qommon.storage import Or
+from ..qommon.substitution import CompatibilityNamesDict
+from ..qommon.template import Template
 from .submission import FormFillPage
 
 
diff --git a/wcs/backoffice/root.py b/wcs/backoffice/root.py
index b78d3687..057574a7 100644
--- a/wcs/backoffice/root.py
+++ b/wcs/backoffice/root.py
@@ -15,21 +15,12 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 from django.utils.translation import pgettext
-
-from quixote import get_publisher, get_request, get_response, redirect
-from quixote.html import TemplateIO, htmltext
-
-from ..qommon import _, N_
-from ..qommon.backoffice import BackofficeRootDirectory
-from ..qommon.backoffice.menu import html_top
-
-from ..qommon import misc, get_cfg
-from ..qommon import errors
-from ..qommon import template
-from ..qommon.afterjobs import AfterJob
-from ..qommon.form import *
-
-from wcs.formdef import FormDef
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import redirect
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
 import wcs.admin.categories
 import wcs.admin.forms
@@ -37,12 +28,23 @@ import wcs.admin.roles
 import wcs.admin.settings
 import wcs.admin.users
 import wcs.admin.workflows
+from wcs.formdef import FormDef
 
-from . import studio
+from ..qommon import N_
+from ..qommon import _
+from ..qommon import errors
+from ..qommon import get_cfg
+from ..qommon import misc
+from ..qommon import template
+from ..qommon.afterjobs import AfterJob
+from ..qommon.backoffice import BackofficeRootDirectory
+from ..qommon.backoffice.menu import html_top
+from ..qommon.form import *
 from . import cards
-from . import submission
-from . import management
 from . import data_management
+from . import management
+from . import studio
+from . import submission
 
 
 class RootDirectory(BackofficeRootDirectory):
diff --git a/wcs/backoffice/snapshots.py b/wcs/backoffice/snapshots.py
index b4a78ae7..5806a9da 100644
--- a/wcs/backoffice/snapshots.py
+++ b/wcs/backoffice/snapshots.py
@@ -14,19 +14,29 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_publisher, get_response, redirect, get_session
+from quixote import get_publisher
+from quixote import get_response
+from quixote import get_session
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
 from wcs.blocks import BlockDef
 from wcs.carddef import CardDef
 from wcs.data_sources import NamedDataSource
-from wcs.formdef import FormDef, FormdefImportError
+from wcs.formdef import FormDef
+from wcs.formdef import FormdefImportError
+from wcs.qommon import _
+from wcs.qommon import errors
+from wcs.qommon import misc
+from wcs.qommon import template
+from wcs.qommon.backoffice.menu import html_top
+from wcs.qommon.form import Form
+from wcs.qommon.form import RadiobuttonsWidget
+from wcs.qommon.form import StringWidget
 from wcs.workflows import Workflow
 from wcs.wscalls import NamedWsCall
-from wcs.qommon import _, errors, misc, template
-from wcs.qommon.backoffice.menu import html_top
-from wcs.qommon.form import Form, RadiobuttonsWidget, StringWidget
 
 
 class SnapshotsDirectory(Directory):
diff --git a/wcs/backoffice/studio.py b/wcs/backoffice/studio.py
index 3b0819c5..faf3c941 100644
--- a/wcs/backoffice/studio.py
+++ b/wcs/backoffice/studio.py
@@ -16,7 +16,8 @@
 
 from quixote import get_publisher
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
 from wcs.admin.logged_errors import LoggedErrorsDirectory
 from wcs.qommon import _
diff --git a/wcs/backoffice/submission.py b/wcs/backoffice/submission.py
index e2ab2902..7ad8173e 100644
--- a/wcs/backoffice/submission.py
+++ b/wcs/backoffice/submission.py
@@ -17,23 +17,29 @@
 import time
 
 from django.utils.safestring import mark_safe
-
-from quixote import get_publisher, get_request, get_response, get_session, redirect
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
-
-from ..qommon import _
-from ..qommon.backoffice.menu import html_top
-from ..qommon.form import *
-from ..qommon.storage import Equal, NotEqual
-from ..qommon import errors, misc
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
+from wcs.categories import Category
 from wcs.formdata import FormData
 from wcs.formdef import FormDef
-from wcs.categories import Category
 from wcs.forms.common import FormStatusPage
 from wcs.forms.root import FormPage as PublicFormFillPage
 
+from ..qommon import _
+from ..qommon import errors
+from ..qommon import misc
+from ..qommon.backoffice.menu import html_top
+from ..qommon.form import *
+from ..qommon.storage import Equal
+from ..qommon.storage import NotEqual
+
 
 class RemoveDraftDirectory(Directory):
     def __init__(self, parent_directory):
diff --git a/wcs/blocks.py b/wcs/blocks.py
index 2325b8f3..7a347e5f 100644
--- a/wcs/blocks.py
+++ b/wcs/blocks.py
@@ -17,16 +17,20 @@
 import uuid
 import xml.etree.ElementTree as ET
 
-from quixote import get_request, get_publisher
-from quixote.html import htmltag, htmltext
-
-from .qommon import _, N_, misc
-from .qommon.form import CompositeWidget, WidgetList
-from .qommon.storage import StorableObject
-from .qommon.template import Template
+from quixote import get_publisher
+from quixote import get_request
+from quixote.html import htmltag
+from quixote.html import htmltext
 
 from . import data_sources
 from . import fields
+from .qommon import N_
+from .qommon import _
+from .qommon import misc
+from .qommon.form import CompositeWidget
+from .qommon.form import WidgetList
+from .qommon.storage import StorableObject
+from .qommon.template import Template
 
 
 class BlockdefImportError(Exception):
diff --git a/wcs/cache.py b/wcs/cache.py
index b5caca36..ff9be2c2 100644
--- a/wcs/cache.py
+++ b/wcs/cache.py
@@ -14,10 +14,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from django.core.cache.backends.base import InvalidCacheBackendError
 from django.core.exceptions import ImproperlyConfigured
 from django.utils.module_loading import import_string
-from django.core.cache.backends.base import InvalidCacheBackendError
-
 from quixote import get_publisher
 
 
diff --git a/wcs/carddef.py b/wcs/carddef.py
index 7a01a174..8f0a33e4 100644
--- a/wcs/carddef.py
+++ b/wcs/carddef.py
@@ -18,13 +18,20 @@ import sys
 import types
 
 from quixote import get_publisher
-from .qommon import _, N_, misc
-from .qommon.storage import Contains, Equal, NotEqual, ILike
-from .qommon.template import Template
 
 from wcs.carddata import CardData
 from wcs.categories import CardDefCategory
-from wcs.formdef import FormDef, get_formdefs_of_all_kinds
+from wcs.formdef import FormDef
+from wcs.formdef import get_formdefs_of_all_kinds
+
+from .qommon import N_
+from .qommon import _
+from .qommon import misc
+from .qommon.storage import Contains
+from .qommon.storage import Equal
+from .qommon.storage import ILike
+from .qommon.storage import NotEqual
+from .qommon.template import Template
 
 if not hasattr(types, 'ClassType'):
     types.ClassType = type
@@ -89,8 +96,10 @@ class CardDef(FormDef):
 
     @classmethod
     def get_default_workflow(cls):
-        from wcs.workflows import EditableWorkflowStatusItem, ChoiceWorkflowStatusItem, Workflow
         from wcs.wf.remove import RemoveWorkflowStatusItem
+        from wcs.workflows import ChoiceWorkflowStatusItem
+        from wcs.workflows import EditableWorkflowStatusItem
+        from wcs.workflows import Workflow
 
         workflow = Workflow(name=_('Default (cards)'))
         workflow.id = '_carddef_default'
diff --git a/wcs/categories.py b/wcs/categories.py
index 2f7e887e..05abe96d 100644
--- a/wcs/categories.py
+++ b/wcs/categories.py
@@ -18,8 +18,8 @@ from quixote import get_publisher
 from quixote.html import htmltext
 
 from .qommon import N_
-from .qommon.storage import StorableObject
 from .qommon.misc import simplify
+from .qommon.storage import StorableObject
 from .qommon.substitution import Substitutions
 from .qommon.xml_storage import XmlStorableObject
 
diff --git a/wcs/compat.py b/wcs/compat.py
index 0e251264..5266d68e 100644
--- a/wcs/compat.py
+++ b/wcs/compat.py
@@ -15,13 +15,12 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 import os
-
-from threading import Lock
 from contextlib import contextmanager
+from threading import Lock
 
 from django.utils.deprecation import MiddlewareMixin
-
-from quixote import get_publisher, get_request
+from quixote import get_publisher
+from quixote import get_request
 from quixote.errors import PublishError
 from quixote.http_request import Upload
 
@@ -30,16 +29,19 @@ try:
 except ImportError:
     sentry_sdk = None
 
-from django.http import HttpResponse
 from django.conf import settings
-from django.template import loader, TemplateDoesNotExist
+from django.http import HttpResponse
+from django.template import TemplateDoesNotExist
+from django.template import loader
 from django.template.response import TemplateResponse
 from django.views.generic.base import TemplateView
 
-from .qommon import force_str, template
-from .qommon.publisher import get_cfg, set_publisher_class
 from .publisher import WcsPublisher
+from .qommon import force_str
+from .qommon import template
 from .qommon.http_request import HTTPRequest
+from .qommon.publisher import get_cfg
+from .qommon.publisher import set_publisher_class
 
 
 def can_sentry():
diff --git a/wcs/conditions.py b/wcs/conditions.py
index 64c397f7..4a76723e 100644
--- a/wcs/conditions.py
+++ b/wcs/conditions.py
@@ -14,12 +14,16 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_publisher
-from django.template import Context, Template, TemplateSyntaxError
 import django.template.smartif
+from django.template import Context
+from django.template import Template
+from django.template import TemplateSyntaxError
 from django.utils.encoding import force_text
+from quixote import get_publisher
 
-from .qommon import _, get_logger, force_str
+from .qommon import _
+from .qommon import force_str
+from .qommon import get_logger
 
 
 class ValidationError(ValueError):
diff --git a/wcs/context_processors.py b/wcs/context_processors.py
index 8704455c..ba96e790 100644
--- a/wcs/context_processors.py
+++ b/wcs/context_processors.py
@@ -14,7 +14,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_publisher, get_response, get_request, get_session
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
 
 
 def get_global_context():
diff --git a/wcs/ctl/backup.py b/wcs/ctl/backup.py
index ae3e882f..214b8a44 100644
--- a/wcs/ctl/backup.py
+++ b/wcs/ctl/backup.py
@@ -14,11 +14,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+import os
 import tarfile
 import time
-import os
 
-from ..qommon.ctl import Command, make_option
+from ..qommon.ctl import Command
+from ..qommon.ctl import make_option
 
 
 class CmdBackup(Command):
diff --git a/wcs/ctl/check_hobos.py b/wcs/ctl/check_hobos.py
index 31b35129..a0600570 100644
--- a/wcs/ctl/check_hobos.py
+++ b/wcs/ctl/check_hobos.py
@@ -17,25 +17,29 @@
 from __future__ import print_function
 
 import configparser
+import hashlib
 import json
 import os
 import random
 import sys
 import tempfile
-import hashlib
 import urllib.parse
 
-from django.utils.encoding import force_bytes, force_text
-
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
 from quixote import cleanup
+
+from wcs.admin.settings import UserFieldsFormDef
+from wcs.fields import DateField
+from wcs.fields import EmailField
+from wcs.fields import StringField
 from wcs.qommon import force_str
+
 from ..qommon import misc
-from ..qommon.ctl import Command, make_option
+from ..qommon.ctl import Command
+from ..qommon.ctl import make_option
 from ..qommon.storage import atomic_write
 
-from wcs.admin.settings import UserFieldsFormDef
-from wcs.fields import StringField, EmailField, DateField
-
 
 class NoChange(Exception):
     pass
diff --git a/wcs/ctl/delete_tenant.py b/wcs/ctl/delete_tenant.py
index ca2d9fae..1eb3fa70 100644
--- a/wcs/ctl/delete_tenant.py
+++ b/wcs/ctl/delete_tenant.py
@@ -18,12 +18,14 @@ from __future__ import print_function
 
 import os
 import sys
-import psycopg2
-import psycopg2.errorcodes
 from datetime import datetime
 from shutil import rmtree
 
-from ..qommon.ctl import Command, make_option
+import psycopg2
+import psycopg2.errorcodes
+
+from ..qommon.ctl import Command
+from ..qommon.ctl import make_option
 
 
 class CmdDeleteTenant(Command):
diff --git a/wcs/ctl/hobo_notify.py b/wcs/ctl/hobo_notify.py
index d3b584dd..d4237c8c 100644
--- a/wcs/ctl/hobo_notify.py
+++ b/wcs/ctl/hobo_notify.py
@@ -14,17 +14,19 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+import json
 import os
 import sys
-import json
 
 from quixote import get_publisher
-from ..qommon.ctl import Command
-from ..qommon.publisher import get_cfg
+
 from wcs.admin.settings import UserFieldsFormDef
 from wcs.qommon import force_str
 from wcs.qommon.misc import json_encode_helper
 
+from ..qommon.ctl import Command
+from ..qommon.publisher import get_cfg
+
 
 class CmdHoboNotify(Command):
     name = 'hobo_notify'
diff --git a/wcs/ctl/management/commands/__init__.py b/wcs/ctl/management/commands/__init__.py
index 8a056a30..6040e1e9 100644
--- a/wcs/ctl/management/commands/__init__.py
+++ b/wcs/ctl/management/commands/__init__.py
@@ -16,7 +16,8 @@
 
 import os
 
-from django.core.management.base import BaseCommand, CommandError
+from django.core.management.base import BaseCommand
+from django.core.management.base import CommandError
 
 from wcs.qommon.publisher import get_publisher_class
 
diff --git a/wcs/ctl/management/commands/convert_to_sql.py b/wcs/ctl/management/commands/convert_to_sql.py
index d5088243..88cba87a 100644
--- a/wcs/ctl/management/commands/convert_to_sql.py
+++ b/wcs/ctl/management/commands/convert_to_sql.py
@@ -17,18 +17,17 @@
 import io
 import os
 import sys
-import psycopg2
 import traceback
 
-from django.utils.encoding import force_bytes
+import psycopg2
 from django.core.management.base import BaseCommand
 from django.core.management.base import CommandError
-
-from wcs.qommon.publisher import get_publisher_class
+from django.utils.encoding import force_bytes
 
 from wcs import sql
 from wcs.formdef import FormDef
 from wcs.qommon.misc import localstrftime
+from wcs.qommon.publisher import get_publisher_class
 from wcs.qommon.storage import atomic_write
 from wcs.users import User
 
diff --git a/wcs/ctl/management/commands/import_site.py b/wcs/ctl/management/commands/import_site.py
index 29e32f56..1788d27b 100644
--- a/wcs/ctl/management/commands/import_site.py
+++ b/wcs/ctl/management/commands/import_site.py
@@ -18,8 +18,8 @@ import os
 
 from django.core.management.base import CommandError
 
-from wcs.formdef import FormDef
 from wcs.categories import Category
+from wcs.formdef import FormDef
 from wcs.workflows import Workflow
 
 from . import TenantCommand
diff --git a/wcs/ctl/management/commands/runjob.py b/wcs/ctl/management/commands/runjob.py
index 81ef472e..24f2321b 100644
--- a/wcs/ctl/management/commands/runjob.py
+++ b/wcs/ctl/management/commands/runjob.py
@@ -16,10 +16,11 @@
 
 import sys
 
-from quixote import get_publisher
 from django.core.management import CommandError
+from quixote import get_publisher
 
 from wcs.qommon.http_response import AfterJob
+
 from . import TenantCommand
 
 
diff --git a/wcs/ctl/management/commands/shell.py b/wcs/ctl/management/commands/shell.py
index 76bc0b29..27d68470 100644
--- a/wcs/ctl/management/commands/shell.py
+++ b/wcs/ctl/management/commands/shell.py
@@ -15,6 +15,7 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 from django.core.management.commands import shell
+
 from . import TenantCommand
 
 
diff --git a/wcs/ctl/management/commands/trigger_jumps.py b/wcs/ctl/management/commands/trigger_jumps.py
index 31130263..d5a22271 100644
--- a/wcs/ctl/management/commands/trigger_jumps.py
+++ b/wcs/ctl/management/commands/trigger_jumps.py
@@ -17,12 +17,12 @@
 import json
 
 from django.core.management.base import CommandError
-
 from quixote import get_publisher
 
 from wcs.formdef import FormDef
+from wcs.wf.jump import JumpWorkflowStatusItem
+from wcs.wf.jump import jump_and_perform as wcs_jump_and_perform
 from wcs.workflows import Workflow
-from wcs.wf.jump import JumpWorkflowStatusItem, jump_and_perform as wcs_jump_and_perform
 
 from . import TenantCommand
 
diff --git a/wcs/ctl/rebuild_indexes.py b/wcs/ctl/rebuild_indexes.py
index 83e1bd0b..f6189cf3 100644
--- a/wcs/ctl/rebuild_indexes.py
+++ b/wcs/ctl/rebuild_indexes.py
@@ -16,7 +16,8 @@
 
 import os
 
-from ..qommon.ctl import Command, make_option
+from ..qommon.ctl import Command
+from ..qommon.ctl import make_option
 
 
 def rebuild_vhost_indexes(pub, destroy=False):
diff --git a/wcs/ctl/restore.py b/wcs/ctl/restore.py
index 694017c7..11c9d6d1 100644
--- a/wcs/ctl/restore.py
+++ b/wcs/ctl/restore.py
@@ -16,11 +16,12 @@
 
 from __future__ import print_function
 
+import os
 import sys
 import tarfile
-import os
 
-from ..qommon.ctl import Command, make_option
+from ..qommon.ctl import Command
+from ..qommon.ctl import make_option
 
 
 class CmdRestore(Command):
diff --git a/wcs/ctl/runscript.py b/wcs/ctl/runscript.py
index 52aaa761..d747679e 100644
--- a/wcs/ctl/runscript.py
+++ b/wcs/ctl/runscript.py
@@ -16,10 +16,11 @@
 
 import os.path
 import runpy
-import warnings
 import sys
+import warnings
 
-from ..qommon.ctl import Command, make_option
+from ..qommon.ctl import Command
+from ..qommon.ctl import make_option
 
 
 class CmdRunScript(Command):
diff --git a/wcs/ctl/wipe_data.py b/wcs/ctl/wipe_data.py
index 782e06c2..f32d9dfd 100644
--- a/wcs/ctl/wipe_data.py
+++ b/wcs/ctl/wipe_data.py
@@ -19,7 +19,8 @@ from __future__ import print_function
 import os
 import sys
 
-from ..qommon.ctl import Command, make_option
+from ..qommon.ctl import Command
+from ..qommon.ctl import make_option
 
 
 class CmdWipeData(Command):
diff --git a/wcs/custom_views.py b/wcs/custom_views.py
index 715a82d1..c78d44cc 100644
--- a/wcs/custom_views.py
+++ b/wcs/custom_views.py
@@ -22,8 +22,11 @@ from quixote import get_publisher
 
 from wcs.carddef import CardDef
 from wcs.formdef import FormDef
-from wcs.qommon.storage import StorableObject, Equal, Contains
 from wcs.qommon.misc import simplify
+from wcs.qommon.storage import Contains
+from wcs.qommon.storage import Equal
+from wcs.qommon.storage import StorableObject
+
 from .qommon.misc import xml_node_text
 
 
diff --git a/wcs/data_sources.py b/wcs/data_sources.py
index 8e9ffa23..05ef365e 100644
--- a/wcs/data_sources.py
+++ b/wcs/data_sources.py
@@ -20,28 +20,31 @@ import sys
 import urllib.parse
 import xml.etree.ElementTree as ET
 
-from django.template import TemplateSyntaxError, VariableDoesNotExist
-from django.utils.encoding import force_text, force_bytes
-
-from quixote import get_publisher, get_request, get_session
+from django.template import TemplateSyntaxError
+from django.template import VariableDoesNotExist
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_session
 from quixote.html import TemplateIO
 
-from .qommon import _, N_, force_str
-from .qommon import misc
+from .api_utils import sign_url_auto_orig
+from .qommon import N_
+from .qommon import _
+from .qommon import force_str
 from .qommon import get_logger
+from .qommon import misc
+from .qommon.afterjobs import AfterJob
 from .qommon.cron import CronJob
 from .qommon.form import *
 from .qommon.humantime import seconds2humanduration
 from .qommon.misc import get_variadic_url
 from .qommon.publisher import get_publisher_class
-from .qommon.afterjobs import AfterJob
 from .qommon.storage import StorableObject
 from .qommon.template import Template
 from .qommon.xml_storage import XmlStorableObject
 
-from .api_utils import sign_url_auto_orig
-
-
 data_source_functions = {}
 
 
diff --git a/wcs/fields.py b/wcs/fields.py
index c7f91bfd..780b457e 100644
--- a/wcs/fields.py
+++ b/wcs/fields.py
@@ -16,45 +16,51 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+import base64
+import collections
 import copy
 import datetime
 import html
 import os
-import time
 import random
 import re
 import sys
-import base64
+import time
 import xml.etree.ElementTree as ET
-import collections
-
-from quixote import get_request, get_publisher
-from quixote.html import htmltag, htmltext, TemplateIO
 
-from django.utils.encoding import force_bytes, force_text, smart_text
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from django.utils.encoding import smart_text
 from django.utils.formats import date_format as django_date_format
 from django.utils.html import urlize
-
-from .qommon import _, N_, force_str
-from .qommon import evalutils
-from .qommon.form import *
-from .qommon.misc import (
-    strftime,
-    date_format,
-    ellipsize,
-    xml_node_text,
-    get_as_datetime,
-    get_document_types,
-    get_document_type_value_options,
-)
-from .qommon.ods import NS as OD_NS, clean_text as od_clean_text
-from .qommon.template import Template, TemplateError
-from .qommon import get_cfg
+from quixote import get_publisher
+from quixote import get_request
+from quixote.html import TemplateIO
+from quixote.html import htmltag
+from quixote.html import htmltext
 
 from . import data_sources
 from . import portfolio
+from .blocks import BlockDef
+from .blocks import BlockWidget
 from .conditions import Condition
-from .blocks import BlockDef, BlockWidget
+from .qommon import N_
+from .qommon import _
+from .qommon import evalutils
+from .qommon import force_str
+from .qommon import get_cfg
+from .qommon.form import *
+from .qommon.misc import date_format
+from .qommon.misc import ellipsize
+from .qommon.misc import get_as_datetime
+from .qommon.misc import get_document_type_value_options
+from .qommon.misc import get_document_types
+from .qommon.misc import strftime
+from .qommon.misc import xml_node_text
+from .qommon.ods import NS as OD_NS
+from .qommon.ods import clean_text as od_clean_text
+from .qommon.template import Template
+from .qommon.template import TemplateError
 
 
 class PrefillSelectionWidget(CompositeWidget):
diff --git a/wcs/formdata.py b/wcs/formdata.py
index 8be798d6..aecb18b8 100644
--- a/wcs/formdata.py
+++ b/wcs/formdata.py
@@ -22,19 +22,25 @@ import re
 import sys
 import time
 
-from quixote import get_request, get_publisher, get_session
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_session
 from quixote.http_request import Upload
 
-from .qommon import _, N_
-from .qommon.storage import StorableObject, Intersects, Contains, Null
+from .fields import FileField
+from .qommon import N_
+from .qommon import _
 from .qommon import misc
 from .qommon.evalutils import make_datetime
 from .qommon.publisher import get_cfg
-from .qommon.substitution import Substitutions, invalidate_substitution_cache
+from .qommon.storage import Contains
+from .qommon.storage import Intersects
+from .qommon.storage import Null
+from .qommon.storage import StorableObject
+from .qommon.substitution import Substitutions
+from .qommon.substitution import invalidate_substitution_cache
 from .qommon.template import Template
 
-from .fields import FileField
-
 
 def get_dict_with_varnames(fields, data, formdata=None, varnames_only=False):
     new_data = {}
@@ -910,9 +916,10 @@ class FormData(StorableObject):
         return LazyFormData(self)
 
     def get_substitution_variables(self, minimal=False):
-        from .qommon.substitution import CompatibilityNamesDict
         from wcs.workflows import AttachmentsSubstitutionProxy
 
+        from .qommon.substitution import CompatibilityNamesDict
+
         variables = CompatibilityNamesDict(
             {
                 'form': self.get_as_lazy(),
@@ -1296,6 +1303,7 @@ class FormData(StorableObject):
     def iter_target_datas(self, objectdef=None, object_type=None, status_item=None):
         # objectdef, object_type and status_item are provided when called from a workflow action
         from wcs.wf.create_formdata import LinkedFormdataEvolutionPart
+
         from .carddef import CardDef
         from .formdef import FormDef
 
diff --git a/wcs/formdef.py b/wcs/formdef.py
index b4d126bb..e83d7cb3 100644
--- a/wcs/formdef.py
+++ b/wcs/formdef.py
@@ -16,35 +16,42 @@
 
 import base64
 import copy
+import datetime
 import glob
 import itertools
+import json
 import pickle
 import sys
 import time
 import types
-import json
 import xml.etree.ElementTree as ET
-import datetime
-
-from django.utils.encoding import force_bytes, force_text
 
-from quixote import get_request, get_publisher
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from quixote import get_publisher
+from quixote import get_request
 from quixote.http_request import Upload
 
-from .qommon import _, N_, force_str, PICKLE_KWARGS
-from .qommon.storage import StorableObject, fix_key, Equal
+from . import data_sources
+from . import fields
+from .categories import Category
+from .formdata import FormData
+from .qommon import N_
+from .qommon import PICKLE_KWARGS
+from .qommon import _
+from .qommon import force_str
+from .qommon import get_cfg
 from .qommon.cron import CronJob
 from .qommon.form import *
-from .qommon.misc import simplify, get_as_datetime, xml_node_text
-from .qommon import get_cfg
-from .qommon.substitution import Substitutions
+from .qommon.misc import get_as_datetime
+from .qommon.misc import simplify
+from .qommon.misc import xml_node_text
 from .qommon.publisher import get_publisher_class
-
-from .formdata import FormData
+from .qommon.storage import Equal
+from .qommon.storage import StorableObject
+from .qommon.storage import fix_key
+from .qommon.substitution import Substitutions
 from .roles import logged_users_role
-from .categories import Category
-from . import fields
-from . import data_sources
 
 DRAFTS_DEFAULT_LIFESPAN = 100  # days
 
@@ -1358,9 +1365,10 @@ class FormDef(StorableObject):
         return d
 
     def get_substitution_variables(self, minimal=False):
-        from .qommon.substitution import CompatibilityNamesDict
         from wcs.variables import LazyFormDef
 
+        from .qommon.substitution import CompatibilityNamesDict
+
         return CompatibilityNamesDict({'form': LazyFormDef(self)})
 
     def get_detailed_evolution(self, formdata):
@@ -1764,10 +1772,10 @@ def clean_unused_files(publisher):
 
 
 def get_formdefs_of_all_kinds():
+    from wcs.admin.settings import UserFieldsFormDef
     from wcs.blocks import BlockDef
     from wcs.carddef import CardDef
     from wcs.wf.form import FormWorkflowStatusItem
-    from wcs.admin.settings import UserFieldsFormDef
     from wcs.workflows import Workflow
 
     kwargs = {
diff --git a/wcs/forms/actions.py b/wcs/forms/actions.py
index fe62da3a..7c66b1b1 100644
--- a/wcs/forms/actions.py
+++ b/wcs/forms/actions.py
@@ -17,6 +17,10 @@
 from quixote import redirect
 from quixote.directory import Directory
 
+from wcs.formdef import FormDef
+from wcs.forms.common import FormTemplateMixin
+from wcs.wf.jump import jump_and_perform
+
 from ..qommon import N_
 from ..qommon import errors
 from ..qommon import misc
@@ -24,10 +28,6 @@ from ..qommon import template
 from ..qommon import tokens
 from ..qommon.form import Form
 
-from wcs.formdef import FormDef
-from wcs.forms.common import FormTemplateMixin
-from wcs.wf.jump import jump_and_perform
-
 
 class MissingOrExpiredToken(errors.PublishError):
     status_code = 404
diff --git a/wcs/forms/backoffice.py b/wcs/forms/backoffice.py
index 28489bcc..4421d03e 100644
--- a/wcs/forms/backoffice.py
+++ b/wcs/forms/backoffice.py
@@ -16,15 +16,20 @@
 
 import urllib.parse
 
-from quixote import get_request, get_publisher, get_session, redirect
-from quixote.html import htmltext, TemplateIO
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_session
+from quixote import redirect
+from quixote.html import TemplateIO
+from quixote.html import htmltext
+
+from wcs.qommon.storage import Null
+from wcs.roles import logged_users_role
 
 from ..qommon import _
 from ..qommon import misc
-from ..qommon.form import *
 from ..qommon.backoffice.listing import pagination_links
-from wcs.qommon.storage import Null
-from wcs.roles import logged_users_role
+from ..qommon.form import *
 
 
 class FormDefUI(object):
diff --git a/wcs/forms/common.py b/wcs/forms/common.py
index a9b9ff74..b8e57ab7 100644
--- a/wcs/forms/common.py
+++ b/wcs/forms/common.py
@@ -17,27 +17,34 @@
 import time
 import urllib.parse
 
-from quixote import get_publisher, get_request, get_response, get_session, redirect
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 from quixote.util import randbytes
 
 from wcs import data_sources
-from wcs.blocks import BlockWidget, BlockSubWidget
-from wcs.api_utils import get_user_from_api_query_string, is_url_signed, sign_url_auto_orig
-from wcs.fields import WidgetField, FileField
+from wcs.api_utils import get_user_from_api_query_string
+from wcs.api_utils import is_url_signed
+from wcs.api_utils import sign_url_auto_orig
+from wcs.blocks import BlockSubWidget
+from wcs.blocks import BlockWidget
+from wcs.fields import FileField
+from wcs.fields import WidgetField
+from wcs.qommon.admin.texts import TextsDirectory
 from wcs.workflows import EditableWorkflowStatusItem
 
 from ..qommon import _
+from ..qommon import errors
+from ..qommon import get_logger
 from ..qommon import misc
 from ..qommon import template
-from ..qommon import get_logger
 from ..qommon.form import *
 
-from wcs.qommon.admin.texts import TextsDirectory
-
-from ..qommon import errors
-
 
 class FileDirectory(Directory):
     _q_exports = []
diff --git a/wcs/forms/preview.py b/wcs/forms/preview.py
index 9377f8ab..a9097e40 100644
--- a/wcs/forms/preview.py
+++ b/wcs/forms/preview.py
@@ -15,10 +15,13 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 from quixote import get_publisher
-from quixote.directory import Directory, AccessControlled
-from quixote.html import htmltext, TemplateIO
-from ..qommon import errors, _
+from quixote.directory import AccessControlled
+from quixote.directory import Directory
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
+from ..qommon import _
+from ..qommon import errors
 from .root import FormPage
 
 
diff --git a/wcs/forms/root.py b/wcs/forms/root.py
index dcb182de..29364643 100644
--- a/wcs/forms/root.py
+++ b/wcs/forms/root.py
@@ -24,34 +24,42 @@ try:
 except ImportError:
     qrcode = None
 
+import ratelimit.utils
 from django.utils.http import quote
 from django.utils.safestring import mark_safe
-
-import ratelimit.utils
-
-from quixote import get_publisher, get_request, get_response, get_session, get_session_manager, redirect
-from quixote.directory import Directory, AccessControlled
-from quixote.util import randbytes
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
+from quixote import get_session_manager
+from quixote import redirect
+from quixote.directory import AccessControlled
+from quixote.directory import Directory
 from quixote.form.widget import *
-from quixote.html import TemplateIO, htmltext
-
-from ..qommon import _, N_
-from ..qommon.admin.emails import EmailsDirectory
-from ..qommon import errors, get_cfg
-from ..qommon import misc, get_logger
-from ..qommon import template
-from ..qommon.form import *
-from ..qommon import emails
+from quixote.html import TemplateIO
+from quixote.html import htmltext
+from quixote.util import randbytes
 
 from wcs.categories import Category
-from wcs.formdef import FormDef
 from wcs.formdata import FormData
+from wcs.formdef import FormDef
 from wcs.forms.common import FormTemplateMixin
-from wcs.variables import LazyFormDef
+from wcs.qommon.admin.texts import TextsDirectory
 from wcs.roles import logged_users_role
-from wcs.workflows import Workflow, WorkflowBackofficeFieldsFormDef
+from wcs.variables import LazyFormDef
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowBackofficeFieldsFormDef
 
-from wcs.qommon.admin.texts import TextsDirectory
+from ..qommon import N_
+from ..qommon import _
+from ..qommon import emails
+from ..qommon import errors
+from ..qommon import get_cfg
+from ..qommon import get_logger
+from ..qommon import misc
+from ..qommon import template
+from ..qommon.admin.emails import EmailsDirectory
+from ..qommon.form import *
 
 
 class SubmittedDraftException(Exception):
diff --git a/wcs/forms/workflows.py b/wcs/forms/workflows.py
index 187ff976..d9bdae53 100644
--- a/wcs/forms/workflows.py
+++ b/wcs/forms/workflows.py
@@ -16,14 +16,17 @@
 
 import json
 
-from quixote import get_request, get_response
+from quixote import get_request
+from quixote import get_response
 from quixote.directory import Directory
 
-from ..qommon import errors
-
-from wcs.api import get_user_from_api_query_string, is_url_signed
+from wcs.api import get_user_from_api_query_string
+from wcs.api import is_url_signed
 from wcs.roles import logged_users_role
-from wcs.workflows import WorkflowGlobalActionWebserviceTrigger, perform_items
+from wcs.workflows import WorkflowGlobalActionWebserviceTrigger
+from wcs.workflows import perform_items
+
+from ..qommon import errors
 
 
 class HookDirectory(Directory):
diff --git a/wcs/logged_errors.py b/wcs/logged_errors.py
index da9f0a54..92087be0 100644
--- a/wcs/logged_errors.py
+++ b/wcs/logged_errors.py
@@ -16,11 +16,12 @@
 
 import datetime
 
-from .qommon.misc import simplify
 from wcs.carddef import CardDef
 from wcs.formdef import FormDef
 from wcs.workflows import Workflow
 
+from .qommon.misc import simplify
+
 
 class LoggedError(object):
     _names = 'logged-errors'
diff --git a/wcs/mail_templates.py b/wcs/mail_templates.py
index 632153fe..6071c6a5 100644
--- a/wcs/mail_templates.py
+++ b/wcs/mail_templates.py
@@ -14,7 +14,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from wcs.qommon import misc, get_logger
+from wcs.qommon import get_logger
+from wcs.qommon import misc
 from wcs.qommon.xml_storage import XmlStorableObject
 
 
diff --git a/wcs/middleware.py b/wcs/middleware.py
index fe8c4459..ed07a3c5 100644
--- a/wcs/middleware.py
+++ b/wcs/middleware.py
@@ -19,14 +19,16 @@ import threading
 import time
 import urllib.parse
 
-from django.http import HttpResponseBadRequest, HttpResponseRedirect
+from django.http import HttpResponseBadRequest
+from django.http import HttpResponseRedirect
 from django.utils.deprecation import MiddlewareMixin
-
 from quixote import get_publisher
 from quixote.errors import RequestError
-from .qommon.publisher import ImmediateRedirectException
+
+from .compat import CompatHTTPRequest
+from .compat import CompatWcsPublisher
 from .qommon.http_response import HTTPResponse
-from .compat import CompatHTTPRequest, CompatWcsPublisher
+from .qommon.publisher import ImmediateRedirectException
 
 
 class PublisherInitialisationMiddleware(MiddlewareMixin):
diff --git a/wcs/monkeypatch.py b/wcs/monkeypatch.py
index c88f3a48..b547a523 100644
--- a/wcs/monkeypatch.py
+++ b/wcs/monkeypatch.py
@@ -20,7 +20,6 @@ import urllib.parse
 
 import django.template.base
 import django.template.defaulttags
-
 import quixote
 import quixote.publish
 
diff --git a/wcs/myspace.py b/wcs/myspace.py
index cdfc571b..92b1737b 100644
--- a/wcs/myspace.py
+++ b/wcs/myspace.py
@@ -14,7 +14,9 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_request, redirect
+from quixote import get_request
+from quixote import redirect
+
 from .qommon import myspace
 
 
diff --git a/wcs/portfolio.py b/wcs/portfolio.py
index f02a7622..e545a51d 100644
--- a/wcs/portfolio.py
+++ b/wcs/portfolio.py
@@ -14,20 +14,30 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-import json
-import hashlib
 import base64
+import hashlib
+import json
 import urllib.parse
 
 from django.utils.encoding import force_text
-
-from .qommon import N_, get_logger
-from .qommon.misc import http_get_page, json_loads, http_post_request, urlopen
-from quixote import get_publisher, get_request, get_response, redirect, get_session
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import TemplateIO, htmltext
-
-from wcs.api_utils import get_secret_and_orig, sign_url
+from quixote.html import TemplateIO
+from quixote.html import htmltext
+
+from wcs.api_utils import get_secret_and_orig
+from wcs.api_utils import sign_url
+
+from .qommon import N_
+from .qommon import get_logger
+from .qommon.misc import http_get_page
+from .qommon.misc import http_post_request
+from .qommon.misc import json_loads
+from .qommon.misc import urlopen
 
 
 def has_portfolio():
diff --git a/wcs/publisher.py b/wcs/publisher.py
index b41a2182..9bbd0822 100644
--- a/wcs/publisher.py
+++ b/wcs/publisher.py
@@ -14,7 +14,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from contextlib import contextmanager
 import decimal
 import json
 import os
@@ -25,6 +24,7 @@ import socket
 import sys
 import traceback
 import zipfile
+from contextlib import contextmanager
 
 from django.utils.encoding import force_text
 from django.utils.formats import localize
@@ -37,7 +37,11 @@ except ImportError:
     pass
 
 from wcs.qommon import force_str
-from .qommon.publisher import set_publisher_class, QommonPublisher, get_request
+
+from .qommon.publisher import QommonPublisher
+from .qommon.publisher import get_request
+from .qommon.publisher import set_publisher_class
+
 
 # this is terribly ugly but import RootDirectory will import a bunch of things,
 # and some of them need a publisher to be set
@@ -48,18 +52,17 @@ class StubWcsPublisher(QommonPublisher):
 set_publisher_class(StubWcsPublisher)
 
 
-from .root import RootDirectory
-from .backoffice import RootDirectory as BackofficeRootDirectory
-from .admin import RootDirectory as AdminRootDirectory
+import pickle
+
 from . import custom_views
 from . import sessions
+from .admin import RootDirectory as AdminRootDirectory
+from .backoffice import RootDirectory as BackofficeRootDirectory
 from .qommon.cron import CronJob
-
 from .roles import Role
-from .users import User
+from .root import RootDirectory
 from .tracking_code import TrackingCode
-
-import pickle
+from .users import User
 
 
 class UnpicklerClass(pickle.Unpickler):
@@ -276,8 +279,8 @@ class WcsPublisher(StubWcsPublisher):
                 results['workflows'] += 1
 
         # fourth pass, forms and cards
-        from wcs.formdef import FormDef
         from wcs.carddef import CardDef
+        from wcs.formdef import FormDef
 
         formdefs = []
         carddefs = []
@@ -357,8 +360,8 @@ class WcsPublisher(StubWcsPublisher):
         sql.do_snapshots_table()
         sql.do_loggederrors_table()
         sql.do_meta_table()
-        from .formdef import FormDef
         from .carddef import CardDef
+        from .formdef import FormDef
 
         conn, cur = sql.get_connection_and_cursor()
         sql.drop_views(None, conn, cur)
@@ -404,7 +407,8 @@ class WcsPublisher(StubWcsPublisher):
             self.loggederror_class.record(*args, **kwargs)
 
     def apply_global_action_timeouts(self):
-        from wcs.workflows import Workflow, WorkflowGlobalActionTimeoutTrigger
+        from wcs.workflows import Workflow
+        from wcs.workflows import WorkflowGlobalActionTimeoutTrigger
 
         for workflow in Workflow.select():
             WorkflowGlobalActionTimeoutTrigger.apply(workflow)
diff --git a/wcs/qommon/__init__.py b/wcs/qommon/__init__.py
index 3e938eac..bb8d1e98 100644
--- a/wcs/qommon/__init__.py
+++ b/wcs/qommon/__init__.py
@@ -21,7 +21,6 @@ import threading
 import django.apps
 from django.conf import settings
 from django.utils.encoding import force_text
-
 from quixote import get_publisher
 
 try:
@@ -56,8 +55,10 @@ def N_(x):
     return x
 
 
-from .publisher import get_cfg, get_logger, get_publisher_class
 from . import publisher
+from .publisher import get_cfg
+from .publisher import get_logger
+from .publisher import get_publisher_class
 
 publisher._ = _
 
diff --git a/wcs/qommon/admin/emails.py b/wcs/qommon/admin/emails.py
index 5a6d9280..3da58c1e 100644
--- a/wcs/qommon/admin/emails.py
+++ b/wcs/qommon/admin/emails.py
@@ -16,13 +16,15 @@
 
 from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import htmltext, TemplateIO
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
 from .. import _
-from ..form import *
-from .. import misc, get_cfg
-from ..backoffice.menu import html_top
+from .. import get_cfg
+from .. import misc
 from ..admin.cfg import cfg_submit
+from ..backoffice.menu import html_top
+from ..form import *
 
 
 class EmailsDirectory(Directory):
diff --git a/wcs/qommon/admin/logger.py b/wcs/qommon/admin/logger.py
index 59f16db9..65093821 100644
--- a/wcs/qommon/admin/logger.py
+++ b/wcs/qommon/admin/logger.py
@@ -17,14 +17,18 @@
 import os
 import random
 
-from quixote import get_publisher, get_request, get_response
-from quixote.html import htmltext, TemplateIO
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
 from quixote.directory import Directory
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
 from .. import _
-from .. import logger, errors
-from ..backoffice.menu import html_top
+from .. import errors
+from .. import logger
 from ..admin.menu import error_page
+from ..backoffice.menu import html_top
 
 
 class ByUserDirectory(Directory):
diff --git a/wcs/qommon/admin/menu.py b/wcs/qommon/admin/menu.py
index 12954e37..8bd85be7 100644
--- a/wcs/qommon/admin/menu.py
+++ b/wcs/qommon/admin/menu.py
@@ -14,12 +14,16 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_publisher, get_request
-from quixote.html import TemplateIO, htmltext
+import re
+
+from quixote import get_publisher
+from quixote import get_request
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from .. import _, N_
+from .. import N_
+from .. import _
 from ..backoffice.menu import html_top
-import re
 
 
 def _find_vc_version():
diff --git a/wcs/qommon/admin/settings.py b/wcs/qommon/admin/settings.py
index 223e828d..1f093c47 100644
--- a/wcs/qommon/admin/settings.py
+++ b/wcs/qommon/admin/settings.py
@@ -15,13 +15,16 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 from quixote import redirect
-from quixote.directory import Directory, AccessControlled
-from quixote.html import TemplateIO, htmltext
+from quixote.directory import AccessControlled
+from quixote.directory import Directory
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from .. import _, N_
-from ..form import *
+from .. import N_
+from .. import _
 from ..admin.cfg import cfg_submit
 from ..backoffice.menu import html_top
+from ..form import *
 
 
 class SettingsDirectory(AccessControlled, Directory):
diff --git a/wcs/qommon/admin/texts.py b/wcs/qommon/admin/texts.py
index c9e6eb8a..a991d96e 100644
--- a/wcs/qommon/admin/texts.py
+++ b/wcs/qommon/admin/texts.py
@@ -16,14 +16,18 @@
 
 import os
 
-from quixote import redirect, get_publisher
-from quixote.html import TemplateIO, htmltext
+from quixote import get_publisher
+from quixote import redirect
 from quixote.directory import Directory
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
 from wcs.qommon import _
-from wcs.qommon.form import *
-from wcs.qommon import misc, get_cfg, ezt
+from wcs.qommon import ezt
+from wcs.qommon import get_cfg
+from wcs.qommon import misc
 from wcs.qommon.backoffice.menu import html_top
+from wcs.qommon.form import *
 from wcs.qommon.template import Template
 
 
diff --git a/wcs/qommon/afterjobs.py b/wcs/qommon/afterjobs.py
index 15bb387f..213d76c4 100644
--- a/wcs/qommon/afterjobs.py
+++ b/wcs/qommon/afterjobs.py
@@ -19,10 +19,13 @@ import time
 import traceback
 import uuid
 
-from quixote import get_publisher, get_response
+from quixote import get_publisher
+from quixote import get_response
 from quixote.directory import Directory
 
-from . import _, N_, errors
+from . import N_
+from . import _
+from . import errors
 from .storage import StorableObject
 
 
diff --git a/wcs/qommon/backoffice/listing.py b/wcs/qommon/backoffice/listing.py
index ad482f11..7bba4e86 100644
--- a/wcs/qommon/backoffice/listing.py
+++ b/wcs/qommon/backoffice/listing.py
@@ -16,8 +16,11 @@
 
 import urllib.parse
 
-from quixote.html import htmltext, TemplateIO
-from quixote import get_request, get_response, get_publisher
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
 from .. import _
 
diff --git a/wcs/qommon/backoffice/menu.py b/wcs/qommon/backoffice/menu.py
index a408fda9..c8fcd480 100644
--- a/wcs/qommon/backoffice/menu.py
+++ b/wcs/qommon/backoffice/menu.py
@@ -14,11 +14,15 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_response, get_request, get_publisher, get_session
-from quixote.html import htmltext, TemplateIO
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from .. import get_cfg
 from .. import _
+from .. import get_cfg
 
 
 def generate_header_menu(selected=None):
diff --git a/wcs/qommon/backoffice/root.py b/wcs/qommon/backoffice/root.py
index eee967f6..b148b8cf 100644
--- a/wcs/qommon/backoffice/root.py
+++ b/wcs/qommon/backoffice/root.py
@@ -14,7 +14,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote.directory import Directory, AccessControlled
+from quixote.directory import AccessControlled
+from quixote.directory import Directory
 
 
 class BackofficeRootDirectory(AccessControlled, Directory):
diff --git a/wcs/qommon/ctl.py b/wcs/qommon/ctl.py
index 838f8912..f1b32989 100644
--- a/wcs/qommon/ctl.py
+++ b/wcs/qommon/ctl.py
@@ -18,15 +18,16 @@ from __future__ import print_function
 
 import configparser
 import optparse
-from optparse import make_option
-import sys
 import os
+import sys
+from optparse import make_option
 
 __all__ = [
     'Command',
 ]
 
 from wcs import qommon
+
 from . import _
 
 qommon._commands = {}
diff --git a/wcs/qommon/emails.py b/wcs/qommon/emails.py
index 8c2068a7..c91bb631 100644
--- a/wcs/qommon/emails.py
+++ b/wcs/qommon/emails.py
@@ -17,7 +17,8 @@
 import os
 import pwd
 import re
-
+import smtplib
+import socket
 from email import encoders
 from email.header import Header
 from email.mime.application import MIMEApplication
@@ -28,8 +29,6 @@ from email.mime.multipart import MIMEMultipart
 from email.mime.nonmultipart import MIMENonMultipart
 from email.mime.text import MIMEText
 from email.utils import formataddr
-import smtplib
-import socket
 
 try:
     import docutils
@@ -42,13 +41,15 @@ except ImportError:
 
 from django.template.loader import render_to_string
 from django.utils.safestring import mark_safe
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
 
-from quixote import get_request, get_response, get_publisher
-
-from .publisher import get_cfg, get_logger
-from . import force_str
 from . import errors
+from . import force_str
 from .admin.emails import EmailsDirectory
+from .publisher import get_cfg
+from .publisher import get_logger
 from .template import Template
 
 try:
diff --git a/wcs/qommon/errors.py b/wcs/qommon/errors.py
index 0773d358..bf30d3ea 100644
--- a/wcs/qommon/errors.py
+++ b/wcs/qommon/errors.py
@@ -16,12 +16,14 @@
 
 import urllib.parse
 
-from quixote import get_publisher
 import quixote
+from quixote import get_publisher
 from quixote.errors import *
-from quixote.html import TemplateIO, htmltext
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from . import N_, template
+from . import N_
+from . import template
 
 
 class AccessForbiddenError(AccessError):
diff --git a/wcs/qommon/evalutils.py b/wcs/qommon/evalutils.py
index 044b7482..d54b6f72 100644
--- a/wcs/qommon/evalutils.py
+++ b/wcs/qommon/evalutils.py
@@ -28,6 +28,7 @@ from django.utils.encoding import force_bytes
 
 from wcs.qommon import force_str
 from wcs.qommon.upload_storage import UploadStorage
+
 from .misc import get_as_datetime
 
 try:
diff --git a/wcs/qommon/ezt.py b/wcs/qommon/ezt.py
index 4f661582..d98afb31 100644
--- a/wcs/qommon/ezt.py
+++ b/wcs/qommon/ezt.py
@@ -226,8 +226,8 @@ Directives
 import datetime
 import html
 import io
-import re
 import os
+import re
 
 #
 # Formatting types
@@ -734,7 +734,8 @@ def _write_value(valrefs, fp, ctx, format=lambda s: s):
 
         fp.write(localstrftime(value))
     elif isinstance(value, datetime.date):
-        from .misc import strftime, date_format
+        from .misc import date_format
+        from .misc import strftime
 
         fp.write(strftime(date_format(), value))
     # plain old value, write to output
diff --git a/wcs/qommon/form.py b/wcs/qommon/form.py
index 509157de..bb1b0c16 100644
--- a/wcs/qommon/form.py
+++ b/wcs/qommon/form.py
@@ -17,20 +17,20 @@
 import base64
 import collections
 import copy
+import datetime
 import fnmatch
+import hashlib
 import html
+import itertools
+import json
 import mimetypes
 import os
+import random
 import re
 import socket
 import sys
 import tempfile
 import time
-import random
-import datetime
-import itertools
-import hashlib
-import json
 
 try:
     from PIL import Image
@@ -56,30 +56,46 @@ except ImportError:
 
 import quixote
 import quixote.form.widget
-
-from quixote import get_publisher, get_request, get_response, get_session
+from django.conf import settings
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from django.utils.safestring import mark_safe
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
 from quixote.form import *
-from quixote.html import htmltext, htmltag, htmlescape, TemplateIO, stringify
+from quixote.html import TemplateIO
+from quixote.html import htmlescape
+from quixote.html import htmltag
+from quixote.html import htmltext
+from quixote.html import stringify
 from quixote.http_request import Upload
 from quixote.util import randbytes
 
-from django.utils.encoding import force_bytes, force_text
+from wcs.conditions import Condition
+from wcs.conditions import ValidationError
 
-from django.conf import settings
-from django.utils.safestring import mark_safe
-
-from .template import render as render_template, Template, TemplateError
 from ..portfolio import has_portfolio
-from wcs.conditions import Condition, ValidationError
-
-from . import _, ngettext, N_, force_str
+from . import N_
+from . import _
+from . import force_str
 from . import misc
-from .humantime import humanduration2seconds, seconds2humanduration, timewords
-from .misc import strftime, C_, HAS_PDFTOPPM, json_loads
+from . import ngettext
+from .humantime import humanduration2seconds
+from .humantime import seconds2humanduration
+from .humantime import timewords
+from .misc import C_
+from .misc import HAS_PDFTOPPM
+from .misc import json_loads
+from .misc import strftime
 from .publisher import get_cfg
+from .template import Template
+from .template import TemplateError
+from .template import render as render_template
 from .template_utils import render_block_to_string
-from .upload_storage import PicklableUpload, UploadStorageError
-
+from .upload_storage import PicklableUpload
+from .upload_storage import UploadStorageError
 
 QuixoteForm = Form
 
diff --git a/wcs/qommon/http_request.py b/wcs/qommon/http_request.py
index d037bcbe..b99e686b 100644
--- a/wcs/qommon/http_request.py
+++ b/wcs/qommon/http_request.py
@@ -19,9 +19,11 @@ import copy
 import re
 import time
 
-from django.utils.encoding import force_bytes, force_text
-from quixote import get_session, get_publisher
 import quixote.http_request
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from quixote import get_publisher
+from quixote import get_session
 from quixote.errors import RequestError
 
 from .http_response import HTTPResponse
diff --git a/wcs/qommon/http_response.py b/wcs/qommon/http_response.py
index 2dbab989..41c378af 100644
--- a/wcs/qommon/http_response.py
+++ b/wcs/qommon/http_response.py
@@ -15,14 +15,14 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 import hashlib
+import sys
 import time
 import traceback
-import sys
 
+import quixote.http_response
 from django.utils.encoding import force_bytes
 from quixote import get_publisher
-import quixote.http_response
-from quixote import get_publisher, get_request
+from quixote import get_request
 
 from . import N_
 from .afterjobs import AfterJob
diff --git a/wcs/qommon/humantime.py b/wcs/qommon/humantime.py
index 68c5be1e..a06b70fe 100644
--- a/wcs/qommon/humantime.py
+++ b/wcs/qommon/humantime.py
@@ -16,7 +16,9 @@
 
 import re
 
-from . import _, ngettext, N_
+from . import N_
+from . import _
+from . import ngettext
 
 _minute = 60
 _hour = 60 * 60
diff --git a/wcs/qommon/ident/franceconnect.py b/wcs/qommon/ident/franceconnect.py
index d30475db..6b47577b 100644
--- a/wcs/qommon/ident/franceconnect.py
+++ b/wcs/qommon/ident/franceconnect.py
@@ -21,31 +21,36 @@ import urllib.parse
 import uuid
 
 from django.utils.encoding import force_bytes
-
-from quixote import redirect, get_session, get_publisher, get_request, get_session_manager
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_session
+from quixote import get_session_manager
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import htmltext, TemplateIO
 from quixote.errors import QueryError
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from .. import _, N_
-from ..backoffice.menu import html_top
-from .. import template, get_cfg, get_logger
-from ..form import (
-    Form,
-    StringWidget,
-    CompositeWidget,
-    ComputedExpressionWidget,
-    SingleSelectWidget,
-    WidgetListAsTable,
-)
-from ..misc import http_post_request, http_get_page, json_loads
-
-from wcs.workflows import WorkflowStatusItem
 from wcs.formdata import flatten_dict
+from wcs.workflows import WorkflowStatusItem
 
+from .. import N_
+from .. import _
+from .. import get_cfg
+from .. import get_logger
+from .. import template
+from ..backoffice.menu import html_top
+from ..form import CompositeWidget
+from ..form import ComputedExpressionWidget
+from ..form import Form
+from ..form import SingleSelectWidget
+from ..form import StringWidget
+from ..form import WidgetListAsTable
+from ..misc import http_get_page
+from ..misc import http_post_request
+from ..misc import json_loads
 from .base import AuthMethod
 
-
 ADMIN_TITLE = N_('FranceConnect')
 
 # XXX: make an OIDC auth method that FranceConnect would inherit from
diff --git a/wcs/qommon/ident/idp.py b/wcs/qommon/ident/idp.py
index fbc340f3..30ac1e11 100644
--- a/wcs/qommon/ident/idp.py
+++ b/wcs/qommon/ident/idp.py
@@ -22,28 +22,31 @@ try:
 except ImportError:
     lasso = None
 
-from django.utils.encoding import force_bytes, force_text
-
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from quixote import get_publisher
+from quixote import get_response
+from quixote import get_session
+from quixote import redirect
 from quixote.directory import Directory
-from quixote import redirect, get_session, get_response, get_publisher
-from quixote.html import htmltext, TemplateIO
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from .. import _, N_
-from .. import misc, get_cfg, get_logger
-from ..form import *
-from ..tokens import Token
-
-from .. import template
+from .. import N_
+from .. import _
 from .. import errors
-
-from ..backoffice.menu import html_top
+from .. import get_cfg
+from .. import get_logger
+from .. import misc
+from .. import saml2utils
+from .. import template
+from .. import x509utils
 from ..admin.menu import command_icon
-
-from .base import AuthMethod
+from ..backoffice.menu import html_top
+from ..form import *
 from ..storage import atomic_write
-
-from .. import x509utils
-from .. import saml2utils
+from ..tokens import Token
+from .base import AuthMethod
 
 ADMIN_TITLE = N_('SAML2')
 
diff --git a/wcs/qommon/ident/password.py b/wcs/qommon/ident/password.py
index 9bab5bbf..f5d9e5a5 100644
--- a/wcs/qommon/ident/password.py
+++ b/wcs/qommon/ident/password.py
@@ -14,38 +14,41 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+import csv
 import random
 import time
-import csv
-
-from .base import AuthMethod, NoSuchMethodForUserError
 
-from quixote import redirect, get_publisher
-from quixote.directory import AccessControlled, Directory
-from quixote.html import TemplateIO, htmltext
+from quixote import get_publisher
+from quixote import redirect
+from quixote.directory import AccessControlled
+from quixote.directory import Directory
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from .. import _, ngettext, N_
-from ..form import *
+from wcs.qommon.admin.texts import TextsDirectory
 
-from ..publisher import get_publisher_class
-from .. import misc, get_cfg, get_logger
+from .. import N_
+from .. import _
 from .. import emails
+from .. import errors
+from .. import get_cfg
+from .. import get_logger
+from .. import misc
+from .. import ngettext
+from .. import storage as st
 from .. import template
 from .. import tokens
-from .. import errors
-
+from ..admin.emails import EmailsDirectory
 from ..admin.menu import command_icon
-
+from ..afterjobs import AfterJob
 from ..backoffice.menu import html_top
-
-from ..admin.emails import EmailsDirectory
-from wcs.qommon.admin.texts import TextsDirectory
-
 from ..cron import CronJob
-from ..afterjobs import AfterJob
-from .. import storage as st
-
-from .password_accounts import PasswordAccount, HASHING_ALGOS
+from ..form import *
+from ..publisher import get_publisher_class
+from .base import AuthMethod
+from .base import NoSuchMethodForUserError
+from .password_accounts import HASHING_ALGOS
+from .password_accounts import PasswordAccount
 
 
 def notify_admins_user_registered(account):
diff --git a/wcs/qommon/ident/password_accounts.py b/wcs/qommon/ident/password_accounts.py
index 249da12a..d0d9f268 100644
--- a/wcs/qommon/ident/password_accounts.py
+++ b/wcs/qommon/ident/password_accounts.py
@@ -16,11 +16,14 @@
 
 import hashlib
 
-from django.contrib.auth.hashers import check_password, make_password
-from django.utils.encoding import force_bytes, force_text
+from django.contrib.auth.hashers import check_password
+from django.contrib.auth.hashers import make_password
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
 from quixote import get_publisher
 
 from wcs.qommon import force_str
+
 from ..storage import StorableObject
 
 HASHING_ALGOS = {
diff --git a/wcs/qommon/logger.py b/wcs/qommon/logger.py
index 2b38f52f..1b2e112a 100644
--- a/wcs/qommon/logger.py
+++ b/wcs/qommon/logger.py
@@ -17,7 +17,9 @@
 import logging
 import os
 
-from quixote import get_publisher, get_session, get_request
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_session
 from quixote.logger import DefaultLogger
 
 
diff --git a/wcs/qommon/management/commands/collectstatic.py b/wcs/qommon/management/commands/collectstatic.py
index 7cb5f3a9..a34feba3 100644
--- a/wcs/qommon/management/commands/collectstatic.py
+++ b/wcs/qommon/management/commands/collectstatic.py
@@ -18,6 +18,7 @@ import os
 import shutil
 
 from django.core.management.base import BaseCommand
+
 from wcs.qommon.publisher import get_publisher_class
 
 
diff --git a/wcs/qommon/management/commands/cron.py b/wcs/qommon/management/commands/cron.py
index ab30fbe2..b92f3d40 100644
--- a/wcs/qommon/management/commands/cron.py
+++ b/wcs/qommon/management/commands/cron.py
@@ -16,16 +16,17 @@
 
 from __future__ import print_function
 
+import os
 import tempfile
 import time
-import os
 
 from django.conf import settings
-from django.core.management.base import BaseCommand, CommandError
-from wcs.qommon.publisher import get_publisher_class
+from django.core.management.base import BaseCommand
+from django.core.management.base import CommandError
 
-from wcs.qommon.vendor import locket
 from wcs.qommon.cron import cron_worker
+from wcs.qommon.publisher import get_publisher_class
+from wcs.qommon.vendor import locket
 from wcs.wf.jump import JUMP_TIMEOUT_INTERVAL
 
 
diff --git a/wcs/qommon/management/commands/migrate.py b/wcs/qommon/management/commands/migrate.py
index da053a21..00eda525 100644
--- a/wcs/qommon/management/commands/migrate.py
+++ b/wcs/qommon/management/commands/migrate.py
@@ -15,9 +15,10 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 import os
-import quixote
 
+import quixote
 from django.core.management.base import BaseCommand
+
 from wcs.qommon.publisher import get_publisher_class
 
 
diff --git a/wcs/qommon/misc.py b/wcs/qommon/misc.py
index ec59ee90..a59921c7 100644
--- a/wcs/qommon/misc.py
+++ b/wcs/qommon/misc.py
@@ -14,20 +14,20 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+import base64
+import calendar
 import datetime
 import decimal
-import calendar
+import hashlib
 import html
 import io
-import re
-import os
-import time
-import urllib.parse
-import base64
 import json
+import os
+import re
 import subprocess
+import time
 import unicodedata
-import hashlib
+import urllib.parse
 
 import requests
 from requests.adapters import HTTPAdapter
@@ -38,19 +38,26 @@ except ImportError:
     Image = None
 
 from django.conf import settings
+from django.template import TemplateSyntaxError
+from django.template import VariableDoesNotExist
 from django.utils import datetime_safe
 from django.utils.encoding import force_text
 from django.utils.formats import localize
 from django.utils.html import strip_tags
-from django.template import TemplateSyntaxError, VariableDoesNotExist
 from django.utils.text import Truncator
-
-from quixote import get_publisher, get_response, get_request, redirect
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import redirect
 from quixote.html import htmltext
 
-from . import _, force_str
-from . import get_cfg, get_logger, ezt
-from .errors import ConnectionError, RequestError
+from . import _
+from . import ezt
+from . import force_str
+from . import get_cfg
+from . import get_logger
+from .errors import ConnectionError
+from .errors import RequestError
 from .template import Template
 
 try:
diff --git a/wcs/qommon/myspace.py b/wcs/qommon/myspace.py
index 6367e3b5..c3a420fd 100644
--- a/wcs/qommon/myspace.py
+++ b/wcs/qommon/myspace.py
@@ -14,19 +14,25 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_publisher, get_request, redirect, get_response, get_session_manager
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session_manager
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import htmltext, TemplateIO
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
-from . import _, N_
+from wcs.qommon.admin.texts import TextsDirectory
+
+from . import N_
+from . import _
+from . import errors
+from . import get_cfg
 from . import template
 from .form import *
-from . import get_cfg
-from . import errors
-
 from .ident.password_accounts import PasswordAccount
 
-from wcs.qommon.admin.texts import TextsDirectory
 
 # This module depends upon the following protocol from the user class:
 #
diff --git a/wcs/qommon/ods.py b/wcs/qommon/ods.py
index dae8d271..b4315bc3 100644
--- a/wcs/qommon/ods.py
+++ b/wcs/qommon/ods.py
@@ -22,8 +22,11 @@ import zipfile
 
 from django.utils.encoding import force_text
 
-from .misc import date_format, datetime_format, strftime
-from .evalutils import make_date, make_datetime
+from .evalutils import make_date
+from .evalutils import make_datetime
+from .misc import date_format
+from .misc import datetime_format
+from .misc import strftime
 
 NS = {
     'fo': 'urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0',
diff --git a/wcs/qommon/pages.py b/wcs/qommon/pages.py
index 5b4764e6..a46fac29 100644
--- a/wcs/qommon/pages.py
+++ b/wcs/qommon/pages.py
@@ -16,7 +16,8 @@
 
 import os
 
-from quixote import get_publisher, redirect
+from quixote import get_publisher
+from quixote import redirect
 from quixote.directory import Directory
 from quixote.util import StaticDirectory
 
diff --git a/wcs/qommon/publisher.py b/wcs/qommon/publisher.py
index 2efb240a..a07c3d25 100644
--- a/wcs/qommon/publisher.py
+++ b/wcs/qommon/publisher.py
@@ -16,51 +16,56 @@
 
 from __future__ import print_function
 
+import builtins
 import codecs
 import collections
-import builtins
 import configparser
-import pickle
-import urllib.parse
 import datetime
-from decimal import Decimal
+import fcntl
+import hashlib
 import importlib
 import inspect
 import io
-import os
-import fcntl
-import hashlib
 import json
+import linecache
 import locale
+import logging
+import logging.handlers
+import os
+import pickle
 import random
 import re
 import socket
 import sys
 import time
 import traceback
-
-import linecache
+import urllib.parse
 import xml.etree.ElementTree as ET
+from decimal import Decimal
 
 from django.conf import settings
 from django.http import Http404
 from django.utils import translation
-from django.utils.encoding import force_text, force_bytes
-
-from quixote.publish import Publisher, get_request, get_response, get_publisher, redirect
-from .http_request import HTTPRequest
-from .http_response import HTTPResponse, AfterJob
-
-from .cron import CronJob
-from .substitution import Substitutions, CompatibilityNamesDict
-
-from . import N_, force_str
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from quixote.publish import Publisher
+from quixote.publish import get_publisher
+from quixote.publish import get_request
+from quixote.publish import get_response
+from quixote.publish import redirect
+
+from . import N_
 from . import errors
-from . import template
-import logging
-import logging.handlers
+from . import force_str
 from . import logger
 from . import storage
+from . import template
+from .cron import CronJob
+from .http_request import HTTPRequest
+from .http_response import AfterJob
+from .http_response import HTTPResponse
+from .substitution import CompatibilityNamesDict
+from .substitution import Substitutions
 from .vendor import locket
 
 
@@ -892,9 +897,10 @@ class QommonPublisher(Publisher, object):
         return valid_known_domains
 
     def get_substitution_variables(self):
-        from . import misc
         from wcs.variables import LazyDateObject
 
+        from . import misc
+
         d = {
             'site_name': get_cfg('misc', {}).get('sitename', None),
             'site_theme': get_cfg('branding', {}).get('theme', self.default_theme),
diff --git a/wcs/qommon/saml2.py b/wcs/qommon/saml2.py
index 4d9c72e0..78690c3a 100644
--- a/wcs/qommon/saml2.py
+++ b/wcs/qommon/saml2.py
@@ -15,9 +15,9 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 import os
+import sys
 import time
 import urllib.parse
-import sys
 from xml.sax.saxutils import escape
 
 try:
@@ -26,19 +26,24 @@ except ImportError:
     lasso = None
 
 from django.utils.encoding import force_text
-
-from quixote import get_request, get_response, redirect, get_field, get_publisher
-from quixote.http_request import parse_header
+from quixote import get_field
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
+from quixote import get_session_manager
+from quixote import redirect
 from quixote.directory import Directory
-from quixote import get_session, get_session_manager
+from quixote.http_request import parse_header
 
+from . import _
+from . import errors
+from . import force_str
 from . import misc
-from .publisher import get_cfg, get_logger
-from . import _, force_str
+from .publisher import get_cfg
+from .publisher import get_logger
 from .template import error_page
 
-from . import errors
-
 
 class SOAPException(Exception):
     url = None
diff --git a/wcs/qommon/saml2utils.py b/wcs/qommon/saml2utils.py
index 5efbc8d0..737a5628 100644
--- a/wcs/qommon/saml2utils.py
+++ b/wcs/qommon/saml2utils.py
@@ -16,7 +16,8 @@
 
 import os
 
-from . import force_str, x509utils
+from . import force_str
+from . import x509utils
 
 
 def bool2xs(boolean):
diff --git a/wcs/qommon/sessions.py b/wcs/qommon/sessions.py
index 477e9af1..2d00d48b 100644
--- a/wcs/qommon/sessions.py
+++ b/wcs/qommon/sessions.py
@@ -15,26 +15,28 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 import copy
-import json
 import hashlib
+import json
 import os
 import time
 
+from django.conf import settings
+from django.core.signing import BadSignature
+from django.core.signing import Signer
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
 from quixote import get_publisher
-
+from quixote.publish import get_request
+from quixote.publish import get_session
+from quixote.publish import get_session_manager
 from quixote.session import Session as QuixoteSession
 from quixote.session import SessionManager as QuixoteSessionManager
 from quixote.util import randbytes
 
-from django.conf import settings
-from django.utils.encoding import force_bytes, force_text
-from django.core.signing import Signer, BadSignature
-
 from . import misc
-from .storage import StorableObject
 from .publisher import get_cfg
+from .storage import StorableObject
 from .upload_storage import get_storage_object
-from quixote.publish import get_session, get_session_manager, get_request
 
 
 class QommonSession(QuixoteSession):
diff --git a/wcs/qommon/sms.py b/wcs/qommon/sms.py
index 1416190a..7b47ca83 100644
--- a/wcs/qommon/sms.py
+++ b/wcs/qommon/sms.py
@@ -17,11 +17,16 @@
 import re
 import urllib.parse
 
-from . import N_, errors, misc
-from . import get_cfg, get_logger
-from .form import StringWidget, PasswordWidget
 from wcs.wscalls import call_webservice
 
+from . import N_
+from . import errors
+from . import get_cfg
+from . import get_logger
+from . import misc
+from .form import PasswordWidget
+from .form import StringWidget
+
 
 class PasserelleSMS(object):
     TIMEOUT = 10
diff --git a/wcs/qommon/storage.py b/wcs/qommon/storage.py
index c0af2fb0..1d7430ba 100644
--- a/wcs/qommon/storage.py
+++ b/wcs/qommon/storage.py
@@ -14,26 +14,26 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+import _thread
 import builtins
 import copyreg
 import errno
 import operator
 import os
-import time
-import pickle
 import os.path
+import pickle
 import shutil
 import sys
 import tempfile
-import _thread
+import time
 
 from django.utils.encoding import force_bytes
+from quixote import get_publisher
 
+from . import PICKLE_KWARGS
+from . import force_str
 from .vendor import locket
 
-from quixote import get_publisher
-from . import PICKLE_KWARGS, force_str
-
 # add compatibility names in case those were stored in pickles
 sys.modules['copy_reg'] = copyreg
 sys.modules['__builtin__'] = builtins
diff --git a/wcs/qommon/substitution.py b/wcs/qommon/substitution.py
index 45a0ba37..47f348dd 100644
--- a/wcs/qommon/substitution.py
+++ b/wcs/qommon/substitution.py
@@ -17,7 +17,8 @@
 from contextlib import contextmanager
 
 from quixote import get_publisher
-from quixote.html import htmltext, TemplateIO
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 
 
 def invalidate_substitution_cache(func):
@@ -42,9 +43,10 @@ class Substitutions(object):
 
     def set_empty(self):
         from wcs.data_sources import NamedDataSource
-        from wcs.variables import CardsSource, FormsSource
-        from wcs.wscalls import NamedWsCall
         from wcs.scripts import Script
+        from wcs.variables import CardsSource
+        from wcs.variables import FormsSource
+        from wcs.wscalls import NamedWsCall
 
         self.sources = [NamedDataSource, NamedWsCall, CardsSource, FormsSource, Script]
 
diff --git a/wcs/qommon/template.py b/wcs/qommon/template.py
index 5d279bfb..e6e739c5 100644
--- a/wcs/qommon/template.py
+++ b/wcs/qommon/template.py
@@ -14,28 +14,34 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+import glob
 import io
 import os
-import glob
 import re
 import xml.etree.ElementTree as ET
 
 import django.template
-from django.template import (
-    engines,
-    TemplateSyntaxError as DjangoTemplateSyntaxError,
-    VariableDoesNotExist as DjangoVariableDoesNotExist,
-)
+from django.template import TemplateSyntaxError as DjangoTemplateSyntaxError
+from django.template import VariableDoesNotExist as DjangoVariableDoesNotExist
+from django.template import engines
 from django.template.loader import render_to_string
-from django.utils.encoding import force_text, smart_text
-from django.utils.safestring import SafeString, SafeText
-
-from quixote import get_session, get_request, get_response, get_publisher
+from django.utils.encoding import force_text
+from django.utils.encoding import smart_text
+from django.utils.safestring import SafeString
+from django.utils.safestring import SafeText
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
 from quixote.directory import Directory
-from quixote.util import StaticDirectory, StaticFile
-from quixote.html import htmltext, htmlescape, TemplateIO
-
-from . import ezt, force_str
+from quixote.html import TemplateIO
+from quixote.html import htmlescape
+from quixote.html import htmltext
+from quixote.util import StaticDirectory
+from quixote.util import StaticFile
+
+from . import ezt
+from . import force_str
 
 
 def get_template_from_script(filename):
diff --git a/wcs/qommon/template_utils.py b/wcs/qommon/template_utils.py
index 89bb724e..fa24c06e 100644
--- a/wcs/qommon/template_utils.py
+++ b/wcs/qommon/template_utils.py
@@ -21,9 +21,13 @@
 
 from __future__ import absolute_import
 
-from django.template import loader, Context
+from django.template import Context
+from django.template import loader
 from django.template.base import TextNode
-from django.template.loader_tags import BLOCK_CONTEXT_KEY, BlockContext, BlockNode, ExtendsNode
+from django.template.loader_tags import BLOCK_CONTEXT_KEY
+from django.template.loader_tags import BlockContext
+from django.template.loader_tags import BlockNode
+from django.template.loader_tags import ExtendsNode
 
 
 class BlockNotFound(Exception):
diff --git a/wcs/qommon/templatetags/qommon.py b/wcs/qommon/templatetags/qommon.py
index bf41958d..ac7df7cf 100644
--- a/wcs/qommon/templatetags/qommon.py
+++ b/wcs/qommon/templatetags/qommon.py
@@ -15,15 +15,15 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 import datetime
-from decimal import Decimal
-from decimal import InvalidOperation as DecimalInvalidOperation
-from decimal import DivisionByZero as DecimalDivisionByZero
 import hashlib
 import math
-import string
 import random
+import string
 import unicodedata
 import urllib.parse
+from decimal import Decimal
+from decimal import DivisionByZero as DecimalDivisionByZero
+from decimal import InvalidOperation as DecimalInvalidOperation
 
 import pyproj
 from pyproj import Geod
@@ -38,9 +38,12 @@ except ImportError:
 from django import template
 from django.template import defaultfilters
 from django.utils import dateparse
-from django.utils.encoding import force_bytes, force_text
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
 from django.utils.safestring import mark_safe
-from django.utils.timezone import is_naive, make_aware
+from django.utils.timezone import is_naive
+from django.utils.timezone import make_aware
+
 from wcs.qommon import calendar
 from wcs.qommon import evalutils
 from wcs.qommon import tokens
@@ -770,7 +773,8 @@ def phonenumber_fr(value, separator=' '):
 
 @register.filter
 def is_empty(value):
-    from wcs.variables import LazyFormDefObjectsManager, LazyList
+    from wcs.variables import LazyFormDefObjectsManager
+    from wcs.variables import LazyList
 
     if isinstance(value, (str, list, dict)):
         return not value
diff --git a/wcs/qommon/tokens.py b/wcs/qommon/tokens.py
index 8c55bc48..d51ed298 100644
--- a/wcs/qommon/tokens.py
+++ b/wcs/qommon/tokens.py
@@ -16,9 +16,9 @@
 
 import random
 import string
+import time
 
 from .storage import StorableObject
-import time
 
 
 class Token(StorableObject):
diff --git a/wcs/qommon/upload_storage.py b/wcs/qommon/upload_storage.py
index 273aaaee..5444c006 100644
--- a/wcs/qommon/upload_storage.py
+++ b/wcs/qommon/upload_storage.py
@@ -18,14 +18,15 @@ import base64
 import io
 import os
 
-from quixote import get_publisher
-from quixote.http_request import Upload
-
 from django.utils.encoding import force_text
 from django.utils.module_loading import import_string
+from quixote import get_publisher
+from quixote.http_request import Upload
 
 from .errors import ConnectionError
-from .misc import json_loads, file_digest, can_thumbnail
+from .misc import can_thumbnail
+from .misc import file_digest
+from .misc import json_loads
 from .storage import atomic_write
 
 
diff --git a/wcs/qommon/vendor/locket.py b/wcs/qommon/vendor/locket.py
index f1bf7c67..5a903e5f 100644
--- a/wcs/qommon/vendor/locket.py
+++ b/wcs/qommon/vendor/locket.py
@@ -30,9 +30,9 @@
 # policies, either expressed or implied, of the FreeBSD Project.
 
 
-import time
 import errno
 import threading
+import time
 import weakref
 
 __all__ = ["lock_file"]
diff --git a/wcs/qommon/x509utils.py b/wcs/qommon/x509utils.py
index c37199d3..8c672375 100644
--- a/wcs/qommon/x509utils.py
+++ b/wcs/qommon/x509utils.py
@@ -16,10 +16,10 @@
 
 import base64
 import binascii
-import tempfile
 import os
-import subprocess
 import stat
+import subprocess
+import tempfile
 
 from django.utils.encoding import force_text
 
diff --git a/wcs/qommon/xml_storage.py b/wcs/qommon/xml_storage.py
index ea47375e..52679bb9 100644
--- a/wcs/qommon/xml_storage.py
+++ b/wcs/qommon/xml_storage.py
@@ -21,7 +21,8 @@ from django.utils.encoding import force_text
 from quixote import get_publisher
 
 from . import force_str
-from .misc import indent_xml, xml_node_text
+from .misc import indent_xml
+from .misc import xml_node_text
 from .storage import StorableObject
 
 
diff --git a/wcs/roles.py b/wcs/roles.py
index 03d6c7a9..de7a5afd 100644
--- a/wcs/roles.py
+++ b/wcs/roles.py
@@ -19,7 +19,8 @@ import xml.etree.ElementTree as ET
 from django.utils.encoding import force_text
 from quixote import get_publisher
 
-from .qommon import _, misc
+from .qommon import _
+from .qommon import misc
 from .qommon.storage import StorableObject
 
 
diff --git a/wcs/root.py b/wcs/root.py
index 85f9c857..0ffd3498 100644
--- a/wcs/root.py
+++ b/wcs/root.py
@@ -14,39 +14,42 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from importlib import import_module
 import json
 import os
 import re
 import urllib.parse
+from importlib import import_module
 
-from quixote import get_publisher, get_response, get_session, redirect, get_session_manager, get_request
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
+from quixote import get_session_manager
+from quixote import redirect
 from quixote.directory import Directory
-from quixote.html import htmltext, TemplateIO
+from quixote.html import TemplateIO
+from quixote.html import htmltext
 from quixote.util import StaticDirectory
 
+from . import portfolio
+from .api import ApiDirectory
+from .categories import Category
+from .formdef import FormDef
 from .forms import root
-from .qommon import saml2
-
+from .forms.actions import ActionsDirectory
+from .forms.preview import PreviewDirectory
+from .myspace import MyspaceDirectory
 from .qommon import _
 from .qommon import errors
-from .qommon import get_cfg, get_logger
-from .qommon import template
-from .qommon.form import *
+from .qommon import get_cfg
+from .qommon import get_logger
 from .qommon import ident
 from .qommon import pages
-from .qommon.upload_storage import UploadStorageError
-
+from .qommon import saml2
+from .qommon import template
 from .qommon.afterjobs import AfterJobStatusDirectory
-
-from .categories import Category
-from .formdef import FormDef
-from .api import ApiDirectory
-from .myspace import MyspaceDirectory
-from .forms.preview import PreviewDirectory
-from .forms.actions import ActionsDirectory
-
-from . import portfolio
+from .qommon.form import *
+from .qommon.upload_storage import UploadStorageError
 
 
 class CompatibilityDirectory(Directory):
diff --git a/wcs/snapshots.py b/wcs/snapshots.py
index 6bb15fd0..774c87a0 100644
--- a/wcs/snapshots.py
+++ b/wcs/snapshots.py
@@ -17,10 +17,11 @@
 import xml.etree.ElementTree as ET
 
 from django.utils.timezone import now
+from quixote import get_publisher
+from quixote import get_session
 
-from quixote import get_publisher, get_session
-
-from wcs.qommon import _, misc
+from wcs.qommon import _
+from wcs.qommon import misc
 from wcs.qommon.storage import Null
 
 
diff --git a/wcs/sql.py b/wcs/sql.py
index 94fc568c..c7a6e0dd 100644
--- a/wcs/sql.py
+++ b/wcs/sql.py
@@ -15,34 +15,27 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 import copy
+import datetime
 import io
+import re
+import time
+import unicodedata
+
 import psycopg2
 import psycopg2.extensions
 import psycopg2.extras
-import datetime
-import time
-import re
-import unicodedata
 
 try:
     import cPickle as pickle
 except ImportError:
     import pickle
 
-from django.utils.encoding import force_bytes, force_text
-
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
 from quixote import get_publisher
-from . import qommon
-from wcs.qommon import force_str, PICKLE_KWARGS
-from .qommon.storage import _take, deep_bytes2str, parse_clause as parse_storage_clause
-from .qommon.substitution import invalidate_substitution_cache
-from .qommon import get_cfg
-from .qommon.upload_storage import PicklableUpload
-from .qommon.misc import strftime
-from .publisher import UnpicklerClass
 
-import wcs.categories
 import wcs.carddata
+import wcs.categories
 import wcs.custom_views
 import wcs.formdata
 import wcs.logged_errors
@@ -50,6 +43,18 @@ import wcs.roles
 import wcs.snapshots
 import wcs.tracking_code
 import wcs.users
+from wcs.qommon import PICKLE_KWARGS
+from wcs.qommon import force_str
+
+from . import qommon
+from .publisher import UnpicklerClass
+from .qommon import get_cfg
+from .qommon.misc import strftime
+from .qommon.storage import _take
+from .qommon.storage import deep_bytes2str
+from .qommon.storage import parse_clause as parse_storage_clause
+from .qommon.substitution import invalidate_substitution_cache
+from .qommon.upload_storage import PicklableUpload
 
 # enable psycogp2 unicode mode, this will fetch postgresql varchar/text columns
 # as unicode objects
@@ -3367,8 +3372,8 @@ def set_reindex(index, value, conn=None, cur=None):
 
 def migrate_views(conn, cur):
     drop_views(None, conn, cur)
-    from wcs.formdef import FormDef
     from wcs.carddef import CardDef
+    from wcs.formdef import FormDef
 
     for formdef in FormDef.select() + CardDef.select():
         # make sure all formdefs have up-to-date views
@@ -3439,8 +3444,8 @@ def migrate():
         # 41: update full text normalization
         set_reindex('formdata', 'needed', conn=conn, cur=cur)
     if sql_level < 46:
-        from wcs.formdef import FormDef
         from wcs.carddef import CardDef
+        from wcs.formdef import FormDef
 
         # 24: add index on evolution(formdata_id)
         # 35: add indexes on formdata(receipt_time) and formdata(anonymised)
diff --git a/wcs/tracking_code.py b/wcs/tracking_code.py
index ee38acb6..0422d3e8 100644
--- a/wcs/tracking_code.py
+++ b/wcs/tracking_code.py
@@ -16,9 +16,8 @@
 
 import random
 
-from .qommon.storage import StorableObject
-
 from .formdef import FormDef
+from .qommon.storage import StorableObject
 
 
 class TrackingCode(StorableObject):
diff --git a/wcs/urls.py b/wcs/urls.py
index eacf4154..a4873557 100644
--- a/wcs/urls.py
+++ b/wcs/urls.py
@@ -16,9 +16,9 @@
 
 from django.conf.urls import url
 
+from . import api
 from . import compat
 from . import views
-from . import api
 
 urlpatterns = [
     url(r'^robots.txt$', views.robots_txt),
diff --git a/wcs/users.py b/wcs/users.py
index d649f6b0..7d35bf6e 100644
--- a/wcs/users.py
+++ b/wcs/users.py
@@ -18,13 +18,15 @@ import datetime
 
 from quixote import get_publisher
 
-from .qommon import _, N_
-from .qommon.misc import simplify
-from .qommon.storage import StorableObject
-from .qommon import get_cfg
 import wcs.qommon.storage as st
 
-from .qommon.substitution import Substitutions, invalidate_substitution_cache
+from .qommon import N_
+from .qommon import _
+from .qommon import get_cfg
+from .qommon.misc import simplify
+from .qommon.storage import StorableObject
+from .qommon.substitution import Substitutions
+from .qommon.substitution import invalidate_substitution_cache
 
 
 class User(StorableObject):
diff --git a/wcs/utils.py b/wcs/utils.py
index 128c5ad2..ccf065cb 100644
--- a/wcs/utils.py
+++ b/wcs/utils.py
@@ -18,8 +18,9 @@ import os
 
 import django.template.loaders.filesystem
 
+from .qommon.publisher import get_cfg
+from .qommon.publisher import get_publisher
 from .qommon.template import get_theme_directory
-from .qommon.publisher import get_cfg, get_publisher
 
 
 class TemplateLoader(django.template.loaders.filesystem.Loader):
diff --git a/wcs/variables.py b/wcs/variables.py
index 0868f16a..f1f643b1 100644
--- a/wcs/variables.py
+++ b/wcs/variables.py
@@ -18,19 +18,22 @@ import warnings
 
 from django.utils.encoding import force_text
 from django.utils.functional import SimpleLazyObject
-
-from quixote import get_publisher, get_request
-
 from pyproj import Geod
-
-from .qommon import misc, force_str, _
-from .qommon.evalutils import make_datetime
-from .qommon.templatetags.qommon import parse_datetime
-from .qommon.storage import Or, Equal, NotEqual, Null
-from .qommon.substitution import CompatibilityNamesDict
+from quixote import get_publisher
+from quixote import get_request
 
 from .carddef import CardDef
 from .formdef import FormDef
+from .qommon import _
+from .qommon import force_str
+from .qommon import misc
+from .qommon.evalutils import make_datetime
+from .qommon.storage import Equal
+from .qommon.storage import NotEqual
+from .qommon.storage import Null
+from .qommon.storage import Or
+from .qommon.substitution import CompatibilityNamesDict
+from .qommon.templatetags.qommon import parse_datetime
 
 
 class LazyFormDefObjectsManager(object):
diff --git a/wcs/views.py b/wcs/views.py
index 52a1a4bc..22328674 100644
--- a/wcs/views.py
+++ b/wcs/views.py
@@ -14,11 +14,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_publisher, get_request, get_response
 from django.http import HttpResponse
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
 
-from .qommon import template
 from . import compat
+from .qommon import template
 
 
 class Backoffice(compat.TemplateWithFallbackView):
diff --git a/wcs/wf/aggregation_email.py b/wcs/wf/aggregation_email.py
index 7f737fa8..f4b95447 100644
--- a/wcs/wf/aggregation_email.py
+++ b/wcs/wf/aggregation_email.py
@@ -14,14 +14,16 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from ..qommon import _, N_
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
+
+from ..qommon import N_
+from ..qommon import _
+from ..qommon import emails
+from ..qommon.cron import CronJob
+from ..qommon.form import *
 from ..qommon.publisher import get_publisher_class
 from ..qommon.storage import StorableObject
-from ..qommon.form import *
-from ..qommon.cron import CronJob
-from ..qommon import emails
-
-from wcs.workflows import WorkflowStatusItem, register_item_class
 
 
 class AggregationEmailWorkflowStatusItem(WorkflowStatusItem):
diff --git a/wcs/wf/anonymise.py b/wcs/wf/anonymise.py
index 5db0e149..15bed156 100644
--- a/wcs/wf/anonymise.py
+++ b/wcs/wf/anonymise.py
@@ -15,7 +15,8 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 from wcs.qommon import N_
-from wcs.workflows import WorkflowStatusItem, register_item_class
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
 
 
 class AnonymiseWorkflowStatusItem(WorkflowStatusItem):
diff --git a/wcs/wf/attachment.py b/wcs/wf/attachment.py
index 52e4a64e..a008955c 100644
--- a/wcs/wf/attachment.py
+++ b/wcs/wf/attachment.py
@@ -19,14 +19,18 @@ import xml.etree.ElementTree as ET
 
 from quixote import redirect
 
-from ..qommon import _, N_
+from wcs.forms.common import FileDirectory
+from wcs.forms.common import FormStatusPage
+from wcs.portfolio import has_portfolio
+from wcs.portfolio import push_document
 from wcs.workflows import *
+
+from ..qommon import N_
+from ..qommon import _
 from ..qommon import get_cfg
 from ..qommon.errors import *
-from ..qommon.misc import get_document_type_value_options, xml_node_text
-
-from wcs.forms.common import FormStatusPage, FileDirectory
-from wcs.portfolio import has_portfolio, push_document
+from ..qommon.misc import get_document_type_value_options
+from ..qommon.misc import xml_node_text
 
 
 def lookup_wf_attachment(self, filename):
diff --git a/wcs/wf/backoffice_fields.py b/wcs/wf/backoffice_fields.py
index b6bd8bb1..6c7f2478 100644
--- a/wcs/wf/backoffice_fields.py
+++ b/wcs/wf/backoffice_fields.py
@@ -19,17 +19,18 @@ import xml.etree.ElementTree as ET
 from quixote import get_publisher
 from quixote.html import htmltext
 
-from ..qommon import _, N_
-from ..qommon.form import (
-    WidgetListAsTable,
-    CompositeWidget,
-    SingleSelectWidget,
-    ComputedExpressionWidget,
-    StringWidget,
-)
 from wcs.fields import WidgetField
-from wcs.workflows import WorkflowStatusItem, register_item_class
 from wcs.wf.profile import FieldNode
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
+
+from ..qommon import N_
+from ..qommon import _
+from ..qommon.form import CompositeWidget
+from ..qommon.form import ComputedExpressionWidget
+from ..qommon.form import SingleSelectWidget
+from ..qommon.form import StringWidget
+from ..qommon.form import WidgetListAsTable
 
 
 class SetBackofficeFieldRowWidget(CompositeWidget):
diff --git a/wcs/wf/create_carddata.py b/wcs/wf/create_carddata.py
index 557762c0..04773b4d 100644
--- a/wcs/wf/create_carddata.py
+++ b/wcs/wf/create_carddata.py
@@ -14,13 +14,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from wcs.qommon import N_
 from quixote import get_publisher
 
-from wcs.workflows import register_item_class
 from wcs.carddef import CardDef
-
-from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem, LinkedFormdataEvolutionPart
+from wcs.qommon import N_
+from wcs.wf.create_formdata import CreateFormdataWorkflowStatusItem
+from wcs.wf.create_formdata import LinkedFormdataEvolutionPart
+from wcs.workflows import register_item_class
 
 
 class LinkedCardDataEvolutionPart(LinkedFormdataEvolutionPart):
diff --git a/wcs/wf/create_formdata.py b/wcs/wf/create_formdata.py
index 570900b7..f3d77ed4 100644
--- a/wcs/wf/create_formdata.py
+++ b/wcs/wf/create_formdata.py
@@ -17,26 +17,26 @@
 import time
 import xml.etree.ElementTree as ET
 
-from quixote import get_request, get_session, get_publisher
-from quixote.html import htmltext
-
 from django.utils.functional import cached_property
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_session
+from quixote.html import htmltext
 
-from wcs.qommon import _, N_
-from wcs.qommon.form import (
-    Form,
-    WidgetListAsTable,
-    CompositeWidget,
-    SingleSelectWidget,
-    ComputedExpressionWidget,
-    RadiobuttonsWidget,
-    CheckboxWidget,
-    VarnameWidget,
-    HtmlWidget,
-)
-
-from wcs.workflows import WorkflowStatusItem, register_item_class
 from wcs.formdef import FormDef
+from wcs.qommon import N_
+from wcs.qommon import _
+from wcs.qommon.form import CheckboxWidget
+from wcs.qommon.form import CompositeWidget
+from wcs.qommon.form import ComputedExpressionWidget
+from wcs.qommon.form import Form
+from wcs.qommon.form import HtmlWidget
+from wcs.qommon.form import RadiobuttonsWidget
+from wcs.qommon.form import SingleSelectWidget
+from wcs.qommon.form import VarnameWidget
+from wcs.qommon.form import WidgetListAsTable
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
 
 
 class Mapping(object):
diff --git a/wcs/wf/criticality.py b/wcs/wf/criticality.py
index 342997ec..1791c2b2 100644
--- a/wcs/wf/criticality.py
+++ b/wcs/wf/criticality.py
@@ -14,9 +14,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from ..qommon import _, N_
 from wcs.qommon.form import SingleSelectWidget
-from wcs.workflows import WorkflowStatusItem, register_item_class
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
+
+from ..qommon import N_
+from ..qommon import _
 
 MODE_INC = '1'
 MODE_DEC = '2'
diff --git a/wcs/wf/dispatch.py b/wcs/wf/dispatch.py
index 3c9d0ab3..dd672e50 100644
--- a/wcs/wf/dispatch.py
+++ b/wcs/wf/dispatch.py
@@ -19,11 +19,16 @@ import xml.etree.ElementTree as ET
 
 from quixote.html import htmltext
 
-from ..qommon import _, N_
+from wcs.roles import get_user_roles
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import XmlSerialisable
+from wcs.workflows import get_role_name
+from wcs.workflows import register_item_class
+
+from ..qommon import N_
+from ..qommon import _
 from ..qommon.form import *
 from ..qommon.template import Template
-from wcs.roles import get_user_roles
-from wcs.workflows import XmlSerialisable, WorkflowStatusItem, register_item_class, get_role_name
 
 
 class AutomaticDispatchRowWidget(CompositeWidget):
diff --git a/wcs/wf/edit_carddata.py b/wcs/wf/edit_carddata.py
index 3aa9f381..3f3085b5 100644
--- a/wcs/wf/edit_carddata.py
+++ b/wcs/wf/edit_carddata.py
@@ -14,13 +14,13 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from wcs.qommon import _, N_
 from quixote import get_publisher
 
-from wcs.workflows import register_item_class
-
+from wcs.qommon import N_
+from wcs.qommon import _
 from wcs.wf.create_carddata import CreateCarddataWorkflowStatusItem
 from wcs.wf.external_workflow import ExternalWorkflowGlobalAction
+from wcs.workflows import register_item_class
 
 
 class EditCarddataWorkflowStatusItem(CreateCarddataWorkflowStatusItem, ExternalWorkflowGlobalAction):
diff --git a/wcs/wf/export_to_model.py b/wcs/wf/export_to_model.py
index f910d531..4eef3ac1 100644
--- a/wcs/wf/export_to_model.py
+++ b/wcs/wf/export_to_model.py
@@ -17,52 +17,58 @@
 import base64
 import collections
 import io
-from xml.etree import ElementTree as ET
-import zipfile
 import os
 import random
+import shutil
 import subprocess
 import tempfile
 import time
-import shutil
-
-from django.utils.encoding import force_bytes, force_text
+import zipfile
+from xml.etree import ElementTree as ET
 
-from quixote import get_response, get_request, get_publisher
+from django.utils.encoding import force_bytes
+from django.utils.encoding import force_text
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
 from quixote.directory import Directory
 from quixote.html import htmltext
 
-from ..qommon import _, N_, ezt, misc, force_str
+from wcs.fields import CommentField
+from wcs.fields import PageField
+from wcs.fields import SubtitleField
+from wcs.fields import TitleField
+from wcs.portfolio import has_portfolio
+from wcs.portfolio import push_document
+from wcs.workflows import AttachmentEvolutionPart
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import get_formdata_template_context
+from wcs.workflows import register_item_class
+from wcs.workflows import template_on_context
+from wcs.workflows import template_on_formdata
+
+from ..qommon import N_
+from ..qommon import _
+from ..qommon import ezt
+from ..qommon import force_str
 from ..qommon import get_logger
-from ..qommon.form import (
-    SingleSelectWidget,
-    WidgetList,
-    CheckboxWidget,
-    StringWidget,
-    UploadWidget,
-    WysiwygTextWidget,
-    Upload,
-    UploadedFile,
-    UploadValidationError,
-    VarnameWidget,
-    RadiobuttonsWidget,
-    PicklableUpload,
-    ComputedExpressionWidget,
-)
+from ..qommon import misc
 from ..qommon.errors import PublishError
+from ..qommon.form import CheckboxWidget
+from ..qommon.form import ComputedExpressionWidget
+from ..qommon.form import PicklableUpload
+from ..qommon.form import RadiobuttonsWidget
+from ..qommon.form import SingleSelectWidget
+from ..qommon.form import StringWidget
+from ..qommon.form import Upload
+from ..qommon.form import UploadedFile
+from ..qommon.form import UploadValidationError
+from ..qommon.form import UploadWidget
+from ..qommon.form import VarnameWidget
+from ..qommon.form import WidgetList
+from ..qommon.form import WysiwygTextWidget
 from ..qommon.template import TemplateError
 
-from wcs.fields import SubtitleField, TitleField, CommentField, PageField
-from wcs.workflows import (
-    WorkflowStatusItem,
-    AttachmentEvolutionPart,
-    template_on_formdata,
-    register_item_class,
-    get_formdata_template_context,
-    template_on_context,
-)
-from wcs.portfolio import has_portfolio, push_document
-
 OO_TEXT_NS = 'urn:oasis:names:tc:opendocument:xmlns:text:1.0'
 OO_OFFICE_NS = 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'
 OO_STYLE_NS = 'urn:oasis:names:tc:opendocument:xmlns:style:1.0'
diff --git a/wcs/wf/external_workflow.py b/wcs/wf/external_workflow.py
index 1a7a0b0b..64002e0d 100644
--- a/wcs/wf/external_workflow.py
+++ b/wcs/wf/external_workflow.py
@@ -16,13 +16,19 @@
 
 from quixote import get_publisher
 
-from wcs.qommon import _, N_
-from wcs.qommon.form import Form, SingleSelectWidget, ComputedExpressionWidget, RadiobuttonsWidget
-
-from wcs.workflows import WorkflowStatusItem, perform_items, register_item_class
-from wcs.workflows import WorkflowGlobalActionWebserviceTrigger, Workflow
 from wcs.carddef import CardDef
 from wcs.formdef import FormDef
+from wcs.qommon import N_
+from wcs.qommon import _
+from wcs.qommon.form import ComputedExpressionWidget
+from wcs.qommon.form import Form
+from wcs.qommon.form import RadiobuttonsWidget
+from wcs.qommon.form import SingleSelectWidget
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowGlobalActionWebserviceTrigger
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import perform_items
+from wcs.workflows import register_item_class
 
 
 class ExternalWorkflowGlobalAction(WorkflowStatusItem):
diff --git a/wcs/wf/form.py b/wcs/wf/form.py
index 8ce7daab..3483b33a 100644
--- a/wcs/wf/form.py
+++ b/wcs/wf/form.py
@@ -16,17 +16,19 @@
 
 import xml.etree.ElementTree as ET
 
-from ..qommon import _, N_
-from ..qommon.form import *
-
-from wcs.workflows import WorkflowStatusItem, register_item_class
-from wcs.formdef import FormDef, lax_int
-
-from wcs.admin.fields import FieldDefPage, FieldsDirectory
+from wcs.admin.fields import FieldDefPage
+from wcs.admin.fields import FieldsDirectory
 from wcs.formdata import get_dict_with_varnames
-
+from wcs.formdef import FormDef
+from wcs.formdef import lax_int
 from wcs.forms.common import FileDirectory
 from wcs.forms.root import FormPage
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
+
+from ..qommon import N_
+from ..qommon import _
+from ..qommon.form import *
 
 
 def lookup_wf_form_file(self, filename):
diff --git a/wcs/wf/geolocate.py b/wcs/wf/geolocate.py
index 86ee2799..882f8cd5 100644
--- a/wcs/wf/geolocate.py
+++ b/wcs/wf/geolocate.py
@@ -20,19 +20,27 @@ import urllib.parse
 
 try:
     from PIL import Image
-    from PIL.ExifTags import TAGS, GPSTAGS
+    from PIL.ExifTags import GPSTAGS
+    from PIL.ExifTags import TAGS
     from PIL.TiffImagePlugin import IFDRational
 except ImportError:
     Image = None
 
 from quixote import get_publisher
 
-from ..qommon import _, N_, force_str
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
+
+from ..qommon import N_
+from ..qommon import _
+from ..qommon import force_str
 from ..qommon import get_logger
 from ..qommon.errors import ConnectionError
-from ..qommon.form import RadiobuttonsWidget, ComputedExpressionWidget, CheckboxWidget
-from ..qommon.misc import http_get_page, normalize_geolocation
-from wcs.workflows import WorkflowStatusItem, register_item_class
+from ..qommon.form import CheckboxWidget
+from ..qommon.form import ComputedExpressionWidget
+from ..qommon.form import RadiobuttonsWidget
+from ..qommon.misc import http_get_page
+from ..qommon.misc import normalize_geolocation
 
 
 class GeolocateWorkflowStatusItem(WorkflowStatusItem):
diff --git a/wcs/wf/jump.py b/wcs/wf/jump.py
index 5e66ff03..6b76d4f9 100644
--- a/wcs/wf/jump.py
+++ b/wcs/wf/jump.py
@@ -19,19 +19,27 @@ import json
 import os
 import time
 
-from quixote import get_publisher, get_request, redirect
-
+from quixote import get_publisher
+from quixote import get_request
+from quixote import redirect
 from quixote.directory import Directory
-from ..qommon import _, N_, force_str
-from ..qommon.humantime import *
-from ..qommon.form import *
-from ..qommon import errors
-from ..qommon.publisher import get_publisher_class
-from ..qommon.cron import CronJob
 
-from wcs.workflows import Workflow, WorkflowStatusJumpItem, WorkflowGlobalAction, register_item_class
-from wcs.api import get_user_from_api_query_string, is_url_signed
+from wcs.api import get_user_from_api_query_string
+from wcs.api import is_url_signed
 from wcs.conditions import Condition
+from wcs.workflows import Workflow
+from wcs.workflows import WorkflowGlobalAction
+from wcs.workflows import WorkflowStatusJumpItem
+from wcs.workflows import register_item_class
+
+from ..qommon import N_
+from ..qommon import _
+from ..qommon import errors
+from ..qommon import force_str
+from ..qommon.cron import CronJob
+from ..qommon.form import *
+from ..qommon.humantime import *
+from ..qommon.publisher import get_publisher_class
 
 JUMP_TIMEOUT_INTERVAL = max((60 // int(os.environ.get('WCS_JUMP_TIMEOUT_CHECKS', '3')), 1))
 
@@ -306,8 +314,8 @@ def workflows_with_timeout():
 
 def _apply_timeouts(publisher):
     '''Traverse all filled form and apply expired timeout jumps if needed'''
-    from ..formdef import FormDef
     from ..carddef import CardDef
+    from ..formdef import FormDef
 
     wfs_status = workflows_with_timeout()
 
diff --git a/wcs/wf/notification.py b/wcs/wf/notification.py
index d93e59a0..d2ed33c5 100644
--- a/wcs/wf/notification.py
+++ b/wcs/wf/notification.py
@@ -18,12 +18,16 @@ import urllib.parse
 
 from quixote import get_publisher
 
-from ..qommon import _, N_, ezt
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
+from wcs.workflows import template_on_formdata
+
+from ..qommon import N_
+from ..qommon import _
+from ..qommon import ezt
+from ..qommon import get_logger
 from ..qommon.form import *
 from ..qommon.template import TemplateError
-from ..qommon import get_logger
-
-from wcs.workflows import WorkflowStatusItem, register_item_class, template_on_formdata
 from .wscall import WebserviceCallStatusItem
 
 
diff --git a/wcs/wf/profile.py b/wcs/wf/profile.py
index ef5da882..ce195acc 100644
--- a/wcs/wf/profile.py
+++ b/wcs/wf/profile.py
@@ -21,16 +21,28 @@ import time
 import urllib.parse
 import xml.etree.ElementTree as ET
 
-from quixote import get_publisher, get_response, get_request
-
-from ..qommon import _, N_
-from ..qommon.form import CompositeWidget, SingleSelectWidget, WidgetListAsTable, ComputedExpressionWidget
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+
+from wcs.api_utils import MissingSecret
+from wcs.api_utils import get_secret_and_orig
+from wcs.api_utils import sign_url
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import XmlSerialisable
+from wcs.workflows import register_item_class
+
+from ..qommon import N_
+from ..qommon import _
+from ..qommon.form import CompositeWidget
+from ..qommon.form import ComputedExpressionWidget
+from ..qommon.form import SingleSelectWidget
+from ..qommon.form import WidgetListAsTable
 from ..qommon.ident.idp import is_idp_managing_user_attributes
-from ..qommon.misc import http_patch_request, JSONEncoder
-from ..qommon.publisher import get_cfg, get_logger
-
-from wcs.api_utils import sign_url, get_secret_and_orig, MissingSecret
-from wcs.workflows import XmlSerialisable, WorkflowStatusItem, register_item_class
+from ..qommon.misc import JSONEncoder
+from ..qommon.misc import http_patch_request
+from ..qommon.publisher import get_cfg
+from ..qommon.publisher import get_logger
 
 
 def user_ws_url(user_uuid):
diff --git a/wcs/wf/redirect_to_url.py b/wcs/wf/redirect_to_url.py
index 3ce7e727..0f4d90f0 100644
--- a/wcs/wf/redirect_to_url.py
+++ b/wcs/wf/redirect_to_url.py
@@ -14,9 +14,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from ..qommon import _, N_
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
+
+from ..qommon import N_
+from ..qommon import _
 from ..qommon.form import ComputedExpressionWidget
-from wcs.workflows import WorkflowStatusItem, register_item_class
 
 
 class RedirectToUrlWorkflowStatusItem(WorkflowStatusItem):
diff --git a/wcs/wf/register_comment.py b/wcs/wf/register_comment.py
index 1e06c479..8baa332d 100644
--- a/wcs/wf/register_comment.py
+++ b/wcs/wf/register_comment.py
@@ -14,19 +14,19 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from ..qommon import _, N_, ezt
-from ..qommon.form import *
-from ..qommon.template import TemplateError
-from ..qommon import get_logger
+import sys
 
-from wcs.workflows import (
-    WorkflowStatusItem,
-    register_item_class,
-    template_on_formdata,
-    AttachmentEvolutionPart,
-)
+from wcs.workflows import AttachmentEvolutionPart
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
+from wcs.workflows import template_on_formdata
 
-import sys
+from ..qommon import N_
+from ..qommon import _
+from ..qommon import ezt
+from ..qommon import get_logger
+from ..qommon.form import *
+from ..qommon.template import TemplateError
 
 
 class JournalEvolutionPart:
diff --git a/wcs/wf/remove.py b/wcs/wf/remove.py
index 2868d3b8..5a7d9bea 100644
--- a/wcs/wf/remove.py
+++ b/wcs/wf/remove.py
@@ -14,9 +14,16 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_publisher, get_request, get_response, get_session
-from ..qommon import _, N_
-from wcs.workflows import WorkflowStatusItem, register_item_class
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import get_session
+
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
+
+from ..qommon import N_
+from ..qommon import _
 
 
 class RemoveWorkflowStatusItem(WorkflowStatusItem):
diff --git a/wcs/wf/resubmit.py b/wcs/wf/resubmit.py
index 875ae773..28a491ae 100644
--- a/wcs/wf/resubmit.py
+++ b/wcs/wf/resubmit.py
@@ -14,12 +14,20 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from quixote import get_publisher, get_request, get_session
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_session
 
-from ..qommon import _, N_
-from wcs.workflows import WorkflowStatusItem, register_item_class
 from wcs.formdef import FormDef
-from wcs.qommon.form import WidgetList, SingleSelectWidget, StringWidget, WysiwygTextWidget
+from wcs.qommon.form import SingleSelectWidget
+from wcs.qommon.form import StringWidget
+from wcs.qommon.form import WidgetList
+from wcs.qommon.form import WysiwygTextWidget
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
+
+from ..qommon import N_
+from ..qommon import _
 
 
 class ResubmitWorkflowStatusItem(WorkflowStatusItem):
diff --git a/wcs/wf/roles.py b/wcs/wf/roles.py
index fbc25e77..6ec62d81 100644
--- a/wcs/wf/roles.py
+++ b/wcs/wf/roles.py
@@ -17,16 +17,25 @@
 import sys
 import urllib.parse
 
-from quixote import get_request, get_publisher, get_response
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
 
-from ..qommon import _, N_
-from ..qommon.form import *
-from wcs.workflows import WorkflowStatusItem, register_item_class
+from wcs.api_utils import MissingSecret
+from wcs.api_utils import get_secret_and_orig
+from wcs.api_utils import sign_url
 from wcs.roles import get_user_roles
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
+
+from ..qommon import N_
+from ..qommon import _
+from ..qommon.form import *
 from ..qommon.ident.idp import is_idp_managing_user_attributes
-from ..qommon.misc import http_post_request, http_delete_request
-from ..qommon.publisher import get_cfg, get_logger
-from wcs.api_utils import sign_url, get_secret_and_orig, MissingSecret
+from ..qommon.misc import http_delete_request
+from ..qommon.misc import http_post_request
+from ..qommon.publisher import get_cfg
+from ..qommon.publisher import get_logger
 
 
 def roles_ws_url(role_uuid, user_uuid):
diff --git a/wcs/wf/timeout_jump.py b/wcs/wf/timeout_jump.py
index e95d7403..9bca4001 100644
--- a/wcs/wf/timeout_jump.py
+++ b/wcs/wf/timeout_jump.py
@@ -15,7 +15,9 @@
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 from wcs.qommon import N_
-from .jump import JumpWorkflowStatusItem, register_item_class
+
+from .jump import JumpWorkflowStatusItem
+from .jump import register_item_class
 
 
 class TimeoutWorkflowStatusItem(JumpWorkflowStatusItem):
diff --git a/wcs/wf/wscall.py b/wcs/wf/wscall.py
index 10664d84..ce643da4 100644
--- a/wcs/wf/wscall.py
+++ b/wcs/wf/wscall.py
@@ -14,29 +14,31 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+import collections
 import datetime
 import io
+import mimetypes
 import sys
 import traceback
 import xml.etree.ElementTree as ET
-import collections
-import mimetypes
 
 from django.utils.encoding import force_text
-
-from quixote.html import TemplateIO, htmltext
-
-from ..qommon import _, N_, force_str
+from quixote.html import TemplateIO
+from quixote.html import htmltext
+
+from wcs.workflows import AbortActionException
+from wcs.workflows import AttachmentEvolutionPart
+from wcs.workflows import WorkflowStatusItem
+from wcs.workflows import register_item_class
+from wcs.wscalls import call_webservice
+from wcs.wscalls import get_app_error_code
+
+from ..qommon import N_
+from ..qommon import _
+from ..qommon import force_str
 from ..qommon.errors import ConnectionError
 from ..qommon.form import *
 from ..qommon.misc import json_loads
-from wcs.workflows import (
-    WorkflowStatusItem,
-    register_item_class,
-    AbortActionException,
-    AttachmentEvolutionPart,
-)
-from wcs.wscalls import call_webservice, get_app_error_code
 
 
 class JournalWsCallErrorPart:
diff --git a/wcs/workflows.py b/wcs/workflows.py
index e45830b1..a6198890 100644
--- a/wcs/workflows.py
+++ b/wcs/workflows.py
@@ -14,39 +14,57 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
-from .qommon import ezt
 import collections
 import copy
 import datetime
-import xml.etree.ElementTree as ET
-import random
 import os
+import random
 import sys
 import time
 import uuid
+import xml.etree.ElementTree as ET
 
 from django.utils.encoding import force_text
-
-from quixote import get_request, get_response, redirect, get_publisher
-
-from .qommon import _, N_, force_str
-from .qommon.misc import C_, get_as_datetime, file_digest, get_foreground_colour, xml_node_text
-from .qommon.storage import StorableObject, atomic_write, NotEqual, Contains, Null, pickle_2to3_conversion
-from .qommon.form import *
-from .qommon.humantime import seconds2humanduration
-from .qommon import emails, get_cfg, get_logger
+from quixote import get_publisher
+from quixote import get_request
+from quixote import get_response
+from quixote import redirect
 from quixote.html import htmltext
-from .qommon import errors
-from .qommon.template import Template, TemplateError
-from .qommon.upload_storage import PicklableUpload, get_storage_object
 
+from .carddef import CardDef
 from .conditions import Condition
-from .roles import logged_users_role, get_user_roles
 from .fields import FileField
-from .formdef import FormDef, FormdefImportError
-from .carddef import CardDef
 from .formdata import Evolution
+from .formdef import FormDef
+from .formdef import FormdefImportError
 from .mail_templates import MailTemplate
+from .qommon import N_
+from .qommon import _
+from .qommon import emails
+from .qommon import errors
+from .qommon import ezt
+from .qommon import force_str
+from .qommon import get_cfg
+from .qommon import get_logger
+from .qommon.form import *
+from .qommon.humantime import seconds2humanduration
+from .qommon.misc import C_
+from .qommon.misc import file_digest
+from .qommon.misc import get_as_datetime
+from .qommon.misc import get_foreground_colour
+from .qommon.misc import xml_node_text
+from .qommon.storage import Contains
+from .qommon.storage import NotEqual
+from .qommon.storage import Null
+from .qommon.storage import StorableObject
+from .qommon.storage import atomic_write
+from .qommon.storage import pickle_2to3_conversion
+from .qommon.template import Template
+from .qommon.template import TemplateError
+from .qommon.upload_storage import PicklableUpload
+from .qommon.upload_storage import get_storage_object
+from .roles import get_user_roles
+from .roles import logged_users_role
 
 if not __name__.startswith('wcs.') and not __name__ == "__main__":
     raise ImportError('Import of workflows module must be absolute (import wcs.workflows)')
diff --git a/wcs/wscalls.py b/wcs/wscalls.py
index 328b846c..38f6c23b 100644
--- a/wcs/wscalls.py
+++ b/wcs/wscalls.py
@@ -21,25 +21,29 @@ import urllib.parse
 import xml.etree.ElementTree as ET
 
 from django.utils.encoding import force_text
+from quixote import get_publisher
+from quixote import get_request
 
-from quixote import get_publisher, get_request
+from wcs.api_utils import MissingSecret
+from wcs.api_utils import get_secret_and_orig
+from wcs.api_utils import sign_url
+from wcs.workflows import WorkflowStatusItem
 
-from .qommon import _, force_str
-from .qommon.misc import simplify, get_variadic_url, JSONEncoder, json_loads
-from .qommon.xml_storage import XmlStorableObject
-from .qommon.form import (
-    CompositeWidget,
-    StringWidget,
-    WidgetDict,
-    ComputedExpressionWidget,
-    RadiobuttonsWidget,
-    CheckboxWidget,
-)
+from .qommon import _
+from .qommon import force_str
 from .qommon import misc
+from .qommon.form import CheckboxWidget
+from .qommon.form import CompositeWidget
+from .qommon.form import ComputedExpressionWidget
+from .qommon.form import RadiobuttonsWidget
+from .qommon.form import StringWidget
+from .qommon.form import WidgetDict
+from .qommon.misc import JSONEncoder
+from .qommon.misc import get_variadic_url
+from .qommon.misc import json_loads
+from .qommon.misc import simplify
 from .qommon.template import Template
-
-from wcs.api_utils import sign_url, get_secret_and_orig, MissingSecret
-from wcs.workflows import WorkflowStatusItem
+from .qommon.xml_storage import XmlStorableObject
 
 
 def get_app_error_code(response, data, response_type):
-- 
2.30.1

