From e5d8a3ae68a0e88d6353413177064fc38e1f1e55 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= <zebuline@entrouvert.com>
Date: Thu, 8 Apr 2021 11:25:34 +0200
Subject: [PATCH 3/4] misc: apply isort (#52856)

---
 .../management/commands/cancel_events.py      |  3 +-
 .../commands/send_booking_reminders.py        |  5 +-
 chrono/agendas/migrations/0001_initial.py     |  2 +-
 chrono/agendas/migrations/0002_event.py       |  2 +-
 chrono/agendas/migrations/0003_booking.py     |  2 +-
 .../0004_booking_cancellation_datetime.py     |  2 +-
 .../migrations/0006_auto_20160707_1357.py     |  3 +-
 .../migrations/0020_auto_20171102_1021.py     |  3 +-
 .../migrations/0025_auto_20181206_1252.py     |  2 +-
 ...0037_timeperiodexceptionsource_ics_file.py |  3 +-
 .../migrations/0038_start_virtual_agendas.py  |  2 +-
 .../migrations/0040_timeperiod_agenda.py      |  2 +-
 .../migrations/0047_auto_20200617_1521.py     |  3 +-
 chrono/agendas/migrations/0050_event_slug.py  |  3 +-
 .../0053_event_date_range_constraint.py       |  1 -
 .../migrations/0054_agenda_categories.py      |  2 +-
 .../migrations/0056_auto_20200811_1611.py     |  2 +-
 .../migrations/0060_auto_20200903_1041.py     |  2 +-
 .../migrations/0062_auto_20200915_1401.py     |  2 +-
 .../migrations/0064_booking_form_url.py       |  3 +-
 .../0065_unavailability_calendar.py           |  2 +-
 .../migrations/0070_auto_20201202_1834.py     |  2 +-
 .../migrations/0075_auto_20210216_1553.py     |  2 +-
 .../migrations/0078_absence_reasons.py        |  2 +-
 chrono/agendas/models.py                      | 24 +++--
 chrono/api/utils.py                           |  1 -
 chrono/api/views.py                           |  8 +-
 chrono/interval.py                            |  2 +-
 chrono/manager/forms.py                       | 14 +--
 chrono/manager/views.py                       | 87 +++++++++----------
 chrono/manager/widgets.py                     |  2 +-
 chrono/settings.py                            |  1 +
 chrono/urls.py                                |  8 +-
 chrono/urls_utils.py                          |  1 -
 chrono/utils/requests_wrapper.py              |  8 +-
 chrono/utils/signature.py                     |  5 +-
 chrono/utils/spooler.py                       |  1 -
 chrono/views.py                               |  1 -
 setup.py                                      |  8 +-
 tests/conftest.py                             |  3 +-
 tests/manager/test_absence_reason.py          |  2 +-
 tests/manager/test_all.py                     | 18 ++--
 tests/manager/test_event.py                   |  2 +-
 tests/test_agendas.py                         | 17 ++--
 tests/test_api.py                             |  9 +-
 tests/test_import_export.py                   | 19 ++--
 tests/test_metz.py                            |  1 -
 tests/test_misc.py                            | 15 +---
 tests/test_requests.py                        |  3 +-
 tests/test_sso.py                             |  1 -
 tests/test_time_periods.py                    |  4 +-
 51 files changed, 149 insertions(+), 173 deletions(-)

diff --git a/chrono/agendas/management/commands/cancel_events.py b/chrono/agendas/management/commands/cancel_events.py
index 926634a..37ff4af 100644
--- a/chrono/agendas/management/commands/cancel_events.py
+++ b/chrono/agendas/management/commands/cancel_events.py
@@ -16,11 +16,10 @@
 
 from datetime import timedelta
 
-from requests import RequestException
-
 from django.core.management.base import BaseCommand
 from django.db import transaction
 from django.utils import timezone
+from requests import RequestException
 
 from chrono.agendas.models import Event, EventCancellationReport
 
diff --git a/chrono/agendas/management/commands/send_booking_reminders.py b/chrono/agendas/management/commands/send_booking_reminders.py
index c7e6544..4b3495e 100644
--- a/chrono/agendas/management/commands/send_booking_reminders.py
+++ b/chrono/agendas/management/commands/send_booking_reminders.py
@@ -15,12 +15,10 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from datetime import datetime, timedelta
-from urllib.parse import urljoin
-from requests import RequestException
 from smtplib import SMTPException
+from urllib.parse import urljoin
 
 import pytz
-
 from django.conf import settings
 from django.core.mail import send_mail
 from django.core.management.base import BaseCommand
@@ -29,6 +27,7 @@ from django.db.transaction import atomic
 from django.template.loader import render_to_string
 from django.utils import timezone, translation
 from django.utils.translation import ugettext_lazy as _
+from requests import RequestException
 
 from chrono.agendas.models import Agenda, Booking
 from chrono.utils.requests_wrapper import requests
diff --git a/chrono/agendas/migrations/0001_initial.py b/chrono/agendas/migrations/0001_initial.py
index 741e948..71e3d60 100644
--- a/chrono/agendas/migrations/0001_initial.py
+++ b/chrono/agendas/migrations/0001_initial.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-from django.db import models, migrations
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0002_event.py b/chrono/agendas/migrations/0002_event.py
index 75d346c..4bd52d9 100644
--- a/chrono/agendas/migrations/0002_event.py
+++ b/chrono/agendas/migrations/0002_event.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-from django.db import models, migrations
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0003_booking.py b/chrono/agendas/migrations/0003_booking.py
index d7a1996..5ea140f 100644
--- a/chrono/agendas/migrations/0003_booking.py
+++ b/chrono/agendas/migrations/0003_booking.py
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-from django.db import models, migrations
 import jsonfield.fields
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0004_booking_cancellation_datetime.py b/chrono/agendas/migrations/0004_booking_cancellation_datetime.py
index 2eac49c..d5d3fbc 100644
--- a/chrono/agendas/migrations/0004_booking_cancellation_datetime.py
+++ b/chrono/agendas/migrations/0004_booking_cancellation_datetime.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-from django.db import models, migrations
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0006_auto_20160707_1357.py b/chrono/agendas/migrations/0006_auto_20160707_1357.py
index ec25781..5046f95 100644
--- a/chrono/agendas/migrations/0006_auto_20160707_1357.py
+++ b/chrono/agendas/migrations/0006_auto_20160707_1357.py
@@ -1,8 +1,9 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-from django.db import migrations, models
 import datetime
+
+from django.db import migrations, models
 from django.utils.timezone import utc
 
 
diff --git a/chrono/agendas/migrations/0020_auto_20171102_1021.py b/chrono/agendas/migrations/0020_auto_20171102_1021.py
index 49d7aa6..4bdb3d4 100644
--- a/chrono/agendas/migrations/0020_auto_20171102_1021.py
+++ b/chrono/agendas/migrations/0020_auto_20171102_1021.py
@@ -1,8 +1,9 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-from django.db import migrations, models
 import datetime
+
+from django.db import migrations, models
 from django.utils.timezone import utc
 
 
diff --git a/chrono/agendas/migrations/0025_auto_20181206_1252.py b/chrono/agendas/migrations/0025_auto_20181206_1252.py
index e733eca..be9d1d6 100644
--- a/chrono/agendas/migrations/0025_auto_20181206_1252.py
+++ b/chrono/agendas/migrations/0025_auto_20181206_1252.py
@@ -2,8 +2,8 @@
 # Generated by Django 1.11.12 on 2018-12-06 12:52
 from __future__ import unicode_literals
 
-from django.db import migrations, models
 import django.db.models.deletion
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0037_timeperiodexceptionsource_ics_file.py b/chrono/agendas/migrations/0037_timeperiodexceptionsource_ics_file.py
index b6ca2e7..f346154 100644
--- a/chrono/agendas/migrations/0037_timeperiodexceptionsource_ics_file.py
+++ b/chrono/agendas/migrations/0037_timeperiodexceptionsource_ics_file.py
@@ -1,9 +1,10 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-import chrono.agendas.models
 from django.db import migrations, models
 
+import chrono.agendas.models
+
 
 class Migration(migrations.Migration):
 
diff --git a/chrono/agendas/migrations/0038_start_virtual_agendas.py b/chrono/agendas/migrations/0038_start_virtual_agendas.py
index 29de801..9f3bc57 100644
--- a/chrono/agendas/migrations/0038_start_virtual_agendas.py
+++ b/chrono/agendas/migrations/0038_start_virtual_agendas.py
@@ -2,8 +2,8 @@
 # Generated by Django 1.11.18 on 2020-02-20 12:15
 from __future__ import unicode_literals
 
-from django.db import migrations, models
 import django.db.models.deletion
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0040_timeperiod_agenda.py b/chrono/agendas/migrations/0040_timeperiod_agenda.py
index e07ec7d..9c76244 100644
--- a/chrono/agendas/migrations/0040_timeperiod_agenda.py
+++ b/chrono/agendas/migrations/0040_timeperiod_agenda.py
@@ -2,8 +2,8 @@
 # Generated by Django 1.11.18 on 2020-02-26 13:27
 from __future__ import unicode_literals
 
-from django.db import migrations, models
 import django.db.models.deletion
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0047_auto_20200617_1521.py b/chrono/agendas/migrations/0047_auto_20200617_1521.py
index 5653cba..b928fd8 100644
--- a/chrono/agendas/migrations/0047_auto_20200617_1521.py
+++ b/chrono/agendas/migrations/0047_auto_20200617_1521.py
@@ -2,9 +2,10 @@
 # Generated by Django 1.11.18 on 2020-06-17 13:21
 from __future__ import unicode_literals
 
-import chrono.agendas.models
 from django.db import migrations, models
 
+import chrono.agendas.models
+
 
 class Migration(migrations.Migration):
 
diff --git a/chrono/agendas/migrations/0050_event_slug.py b/chrono/agendas/migrations/0050_event_slug.py
index d8153c2..370b892 100644
--- a/chrono/agendas/migrations/0050_event_slug.py
+++ b/chrono/agendas/migrations/0050_event_slug.py
@@ -1,9 +1,10 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-import chrono.agendas.models
 from django.db import migrations, models
 
+import chrono.agendas.models
+
 
 class Migration(migrations.Migration):
 
diff --git a/chrono/agendas/migrations/0053_event_date_range_constraint.py b/chrono/agendas/migrations/0053_event_date_range_constraint.py
index 3b298f1..97880bc 100644
--- a/chrono/agendas/migrations/0053_event_date_range_constraint.py
+++ b/chrono/agendas/migrations/0053_event_date_range_constraint.py
@@ -4,7 +4,6 @@ from __future__ import unicode_literals
 from django.db import migrations, transaction
 from django.db.utils import InternalError, OperationalError, ProgrammingError
 
-
 sql_forwards = """
 ALTER TABLE agendas_event
 ADD CONSTRAINT tstzrange_constraint
diff --git a/chrono/agendas/migrations/0054_agenda_categories.py b/chrono/agendas/migrations/0054_agenda_categories.py
index e68c0bc..35766d2 100644
--- a/chrono/agendas/migrations/0054_agenda_categories.py
+++ b/chrono/agendas/migrations/0054_agenda_categories.py
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-from django.db import migrations, models
 import django.db.models.deletion
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0056_auto_20200811_1611.py b/chrono/agendas/migrations/0056_auto_20200811_1611.py
index 18df6a4..aa9a35d 100644
--- a/chrono/agendas/migrations/0056_auto_20200811_1611.py
+++ b/chrono/agendas/migrations/0056_auto_20200811_1611.py
@@ -2,9 +2,9 @@
 # Generated by Django 1.11.18 on 2020-08-11 14:11
 from __future__ import unicode_literals
 
-from django.db import migrations, models
 import django.db.models.deletion
 import jsonfield.fields
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0060_auto_20200903_1041.py b/chrono/agendas/migrations/0060_auto_20200903_1041.py
index 2096ec2..98c5b12 100644
--- a/chrono/agendas/migrations/0060_auto_20200903_1041.py
+++ b/chrono/agendas/migrations/0060_auto_20200903_1041.py
@@ -3,8 +3,8 @@
 from __future__ import unicode_literals
 
 import django.contrib.postgres.fields
-from django.db import migrations, models
 import django.db.models.deletion
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0062_auto_20200915_1401.py b/chrono/agendas/migrations/0062_auto_20200915_1401.py
index 202d2e5..3f682a1 100644
--- a/chrono/agendas/migrations/0062_auto_20200915_1401.py
+++ b/chrono/agendas/migrations/0062_auto_20200915_1401.py
@@ -2,8 +2,8 @@
 # Generated by Django 1.11.18 on 2020-09-15 12:01
 from __future__ import unicode_literals
 
-from django.db import migrations, models
 import django.db.models.deletion
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0064_booking_form_url.py b/chrono/agendas/migrations/0064_booking_form_url.py
index cd4a63d..ed23203 100644
--- a/chrono/agendas/migrations/0064_booking_form_url.py
+++ b/chrono/agendas/migrations/0064_booking_form_url.py
@@ -1,9 +1,10 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-import chrono.agendas.models
 from django.db import migrations, models
 
+import chrono.agendas.models
+
 
 class Migration(migrations.Migration):
 
diff --git a/chrono/agendas/migrations/0065_unavailability_calendar.py b/chrono/agendas/migrations/0065_unavailability_calendar.py
index 39702b2..16fc0b6 100644
--- a/chrono/agendas/migrations/0065_unavailability_calendar.py
+++ b/chrono/agendas/migrations/0065_unavailability_calendar.py
@@ -2,8 +2,8 @@
 # Generated by Django 1.11.18 on 2020-10-05 12:37
 from __future__ import unicode_literals
 
-from django.db import migrations, models
 import django.db.models.deletion
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0070_auto_20201202_1834.py b/chrono/agendas/migrations/0070_auto_20201202_1834.py
index 95c199a..db6b613 100644
--- a/chrono/agendas/migrations/0070_auto_20201202_1834.py
+++ b/chrono/agendas/migrations/0070_auto_20201202_1834.py
@@ -2,8 +2,8 @@
 # Generated by Django 1.11.29 on 2020-12-02 17:34
 from __future__ import unicode_literals
 
-from django.db import migrations, models
 import django.db.models.deletion
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0075_auto_20210216_1553.py b/chrono/agendas/migrations/0075_auto_20210216_1553.py
index 584ddf5..05ced74 100644
--- a/chrono/agendas/migrations/0075_auto_20210216_1553.py
+++ b/chrono/agendas/migrations/0075_auto_20210216_1553.py
@@ -2,9 +2,9 @@
 # Generated by Django 1.11.18 on 2021-02-16 14:53
 from __future__ import unicode_literals
 
-from django.db import migrations, models
 import django.db.models.deletion
 import jsonfield.fields
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/migrations/0078_absence_reasons.py b/chrono/agendas/migrations/0078_absence_reasons.py
index 028ecd8..32d1040 100644
--- a/chrono/agendas/migrations/0078_absence_reasons.py
+++ b/chrono/agendas/migrations/0078_absence_reasons.py
@@ -1,8 +1,8 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-from django.db import migrations, models
 import django.db.models.deletion
+from django.db import migrations, models
 
 
 class Migration(migrations.Migration):
diff --git a/chrono/agendas/models.py b/chrono/agendas/models.py
index 0834bb2..cafd307 100644
--- a/chrono/agendas/models.py
+++ b/chrono/agendas/models.py
@@ -15,8 +15,8 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import copy
 import collections
+import copy
 import datetime
 import functools
 import itertools
@@ -24,20 +24,18 @@ import math
 import sys
 import uuid
 
+import django
 import requests
 import vobject
-from dateutil.rrule import rrule, rruleset, DAILY, WEEKLY
-
-import django
+from dateutil.rrule import DAILY, WEEKLY, rrule, rruleset
 from django.conf import settings
 from django.contrib.auth.models import Group
 from django.contrib.postgres.fields import ArrayField
-from django.core.exceptions import FieldDoesNotExist
-from django.core.exceptions import ValidationError
+from django.core.exceptions import FieldDoesNotExist, ValidationError
 from django.core.validators import MaxValueValidator, MinValueValidator
-from django.db import models, transaction, connection
-from django.db.models import Count, Q, Case, When
-from django.template import engines, Context, Template, TemplateSyntaxError, VariableDoesNotExist
+from django.db import connection, models, transaction
+from django.db.models import Case, Count, Q, When
+from django.template import Context, Template, TemplateSyntaxError, VariableDoesNotExist, engines
 from django.urls import reverse
 from django.utils import functional
 from django.utils.dates import WEEKDAYS
@@ -45,15 +43,15 @@ from django.utils.encoding import force_text
 from django.utils.formats import date_format
 from django.utils.module_loading import import_string
 from django.utils.text import slugify
-from django.utils.timezone import localtime, now, make_aware, make_naive, is_aware, utc
-from django.utils.translation import ugettext_lazy as _, ugettext, ungettext
-
+from django.utils.timezone import is_aware, localtime, make_aware, make_naive, now, utc
+from django.utils.translation import ugettext
+from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import ungettext
 from jsonfield import JSONField
 
 from chrono.interval import Interval, IntervalSet
 from chrono.utils.requests_wrapper import requests as requests_wrapper
 
-
 AGENDA_KINDS = (
     ('events', _('Events')),
     ('meetings', _('Meetings')),
diff --git a/chrono/api/utils.py b/chrono/api/utils.py
index 0ddba26..2646b8b 100644
--- a/chrono/api/utils.py
+++ b/chrono/api/utils.py
@@ -17,7 +17,6 @@
 
 
 from django.utils.encoding import force_text
-
 from rest_framework.response import Response as DRFResponse
 from rest_framework.views import exception_handler as DRF_exception_handler
 
diff --git a/chrono/api/views.py b/chrono/api/views.py
index e11bca7..fd25c1e 100644
--- a/chrono/api/views.py
+++ b/chrono/api/views.py
@@ -27,18 +27,18 @@ from django.urls import reverse
 from django.utils.dateparse import parse_date, parse_datetime
 from django.utils.encoding import force_text
 from django.utils.formats import date_format
-from django.utils.timezone import now, is_naive, make_aware, localtime
+from django.utils.timezone import is_naive, localtime, make_aware, now
 from django.utils.translation import gettext_noop
 from django.utils.translation import ugettext_lazy as _
-
 from django_filters import rest_framework as filters
 from rest_framework import permissions, serializers, status
 from rest_framework.exceptions import ValidationError
 from rest_framework.generics import ListAPIView
 from rest_framework.views import APIView
 
-from chrono.api.utils import Response, APIError
-from ..agendas.models import Agenda, Event, Booking, MeetingType, TimePeriodException, Desk, BookingColor
+from chrono.api.utils import APIError, Response
+
+from ..agendas.models import Agenda, Booking, BookingColor, Desk, Event, MeetingType, TimePeriodException
 from ..interval import IntervalSet
 
 
diff --git a/chrono/interval.py b/chrono/interval.py
index 1af6ea0..4dcd2d5 100644
--- a/chrono/interval.py
+++ b/chrono/interval.py
@@ -14,8 +14,8 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import collections
 import bisect
+import collections
 
 Interval = collections.namedtuple('Interval', ['begin', 'end'])
 
diff --git a/chrono/manager/forms.py b/chrono/manager/forms.py
index 85bd044..185248e 100644
--- a/chrono/manager/forms.py
+++ b/chrono/manager/forms.py
@@ -27,25 +27,25 @@ from django.db import transaction
 from django.forms import ValidationError
 from django.utils.encoding import force_text
 from django.utils.six import StringIO
-from django.utils.timezone import now, make_aware, make_naive
+from django.utils.timezone import make_aware, make_naive, now
 from django.utils.translation import ugettext_lazy as _
 
 from chrono.agendas.models import (
+    WEEKDAYS_LIST,
     AbsenceReason,
     Agenda,
+    AgendaNotificationsSettings,
+    AgendaReminderSettings,
     Booking,
+    Desk,
     Event,
     MeetingType,
+    Resource,
     TimePeriod,
-    Desk,
     TimePeriodException,
     TimePeriodExceptionSource,
-    VirtualMember,
-    Resource,
-    AgendaNotificationsSettings,
-    AgendaReminderSettings,
-    WEEKDAYS_LIST,
     UnavailabilityCalendar,
+    VirtualMember,
     generate_slug,
 )
 
diff --git a/chrono/manager/views.py b/chrono/manager/views.py
index 0275b09..f7e39fa 100644
--- a/chrono/manager/views.py
+++ b/chrono/manager/views.py
@@ -19,97 +19,94 @@ import datetime
 import itertools
 import json
 import math
-import requests
 import uuid
 
+import requests
 from django.contrib import messages
 from django.core.exceptions import PermissionDenied
 from django.db import transaction
-from django.db.models import Q, Value, BooleanField
-from django.db.models import Min, Max
+from django.db.models import BooleanField, Max, Min, Q, Value
 from django.http import Http404, HttpResponse, HttpResponseRedirect
-from django.shortcuts import get_object_or_404
-from django.shortcuts import redirect
-from django.shortcuts import render
+from django.shortcuts import get_object_or_404, redirect, render
 from django.template.defaultfilters import title
 from django.template.loader import render_to_string
 from django.urls import reverse, reverse_lazy
 from django.utils import lorem_ipsum
 from django.utils.dates import MONTHS
+from django.utils.encoding import force_text
 from django.utils.html import format_html
-from django.utils.timezone import now, make_aware, make_naive, localtime
+from django.utils.timezone import localtime, make_aware, make_naive, now
 from django.utils.translation import ugettext_lazy as _
 from django.utils.translation import ungettext
-from django.utils.encoding import force_text
 from django.views.generic import (
-    DetailView,
     CreateView,
-    UpdateView,
-    ListView,
+    DayArchiveView,
     DeleteView,
+    DetailView,
     FormView,
-    TemplateView,
-    DayArchiveView,
+    ListView,
     MonthArchiveView,
     RedirectView,
+    TemplateView,
+    UpdateView,
     View,
 )
 
 from chrono.agendas.models import (
+    AbsenceReason,
+    AbsenceReasonGroup,
     Agenda,
+    AgendaImportError,
+    AgendaNotificationsSettings,
+    AgendaReminderSettings,
+    Booking,
+    BookingColor,
+    Category,
+    Desk,
     Event,
+    EventCancellationReport,
+    ICSError,
     MeetingType,
+    Resource,
     TimePeriod,
-    Booking,
-    Desk,
     TimePeriodException,
-    ICSError,
-    AgendaImportError,
     TimePeriodExceptionSource,
-    VirtualMember,
-    Resource,
-    Category,
-    EventCancellationReport,
-    AgendaNotificationsSettings,
-    AgendaReminderSettings,
     UnavailabilityCalendar,
-    BookingColor,
-    AbsenceReason,
-    AbsenceReasonGroup,
+    VirtualMember,
 )
 
 from .forms import (
     AgendaAddForm,
-    AgendaEditForm,
     AgendaBookingDelaysForm,
+    AgendaDuplicateForm,
+    AgendaEditForm,
+    AgendaNotificationsForm,
+    AgendaReminderForm,
+    AgendaResourceForm,
     AgendaRolesForm,
-    NewEventForm,
+    AgendasExportForm,
+    AgendasImportForm,
+    BookingAbsenceReasonForm,
+    BookingCancelForm,
+    DeskForm,
+    EventCancelForm,
     EventForm,
-    NewMeetingTypeForm,
-    MeetingTypeForm,
-    TimePeriodForm,
+    ExceptionsImportForm,
     ImportEventsForm,
+    MeetingTypeForm,
     NewDeskForm,
-    DeskForm,
+    NewEventForm,
+    NewMeetingTypeForm,
     NewTimePeriodExceptionForm,
-    TimePeriodExceptionForm,
-    ExceptionsImportForm,
-    AgendasImportForm,
     TimePeriodAddForm,
+    TimePeriodExceptionForm,
     TimePeriodExceptionSourceReplaceForm,
-    VirtualMemberForm,
-    AgendaResourceForm,
-    AgendaDuplicateForm,
-    BookingCancelForm,
-    EventCancelForm,
-    AgendaNotificationsForm,
-    AgendaReminderForm,
+    TimePeriodForm,
     UnavailabilityCalendarAddForm,
     UnavailabilityCalendarEditForm,
-    AgendasExportForm,
-    BookingAbsenceReasonForm,
+    VirtualMemberForm,
 )
-from .utils import import_site, export_site
+from .utils import export_site, import_site
 
 FUTURE_BOOKING_ERROR_MSG = _('This cannot be removed as there are bookings for a future date.')
 
diff --git a/chrono/manager/widgets.py b/chrono/manager/widgets.py
index d93e4d1..bba7bb0 100644
--- a/chrono/manager/widgets.py
+++ b/chrono/manager/widgets.py
@@ -16,7 +16,7 @@
 
 
 from django.forms.fields import SplitDateTimeField
-from django.forms.widgets import TimeInput, SelectMultiple, SplitDateTimeWidget
+from django.forms.widgets import SelectMultiple, SplitDateTimeWidget, TimeInput
 from django.utils.safestring import mark_safe
 
 
diff --git a/chrono/settings.py b/chrono/settings.py
index f4a334a..8fcb8de 100644
--- a/chrono/settings.py
+++ b/chrono/settings.py
@@ -24,6 +24,7 @@ and to disable DEBUG mode in production.
 """
 
 import os
+
 from django.conf.global_settings import STATICFILES_FINDERS
 
 _ = lambda s: s
diff --git a/chrono/urls.py b/chrono/urls.py
index 5f0e700..003930e 100644
--- a/chrono/urls.py
+++ b/chrono/urls.py
@@ -15,17 +15,15 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from django.conf import settings
-from django.contrib.auth.decorators import login_required
 from django.conf.urls import include, url
 from django.conf.urls.static import static
+from django.contrib.auth.decorators import login_required
 from django.contrib.staticfiles.urls import staticfiles_urlpatterns
 
-from .urls_utils import decorated_includes
-
-from .views import homepage, LoginView, LogoutView
 from .api.urls import urlpatterns as chrono_api_urls
 from .manager.urls import urlpatterns as chrono_manager_urls
-
+from .urls_utils import decorated_includes
+from .views import LoginView, LogoutView, homepage
 
 urlpatterns = [
     url(r'^$', homepage, name='home'),
diff --git a/chrono/urls_utils.py b/chrono/urls_utils.py
index dc76807..9c5d131 100644
--- a/chrono/urls_utils.py
+++ b/chrono/urls_utils.py
@@ -17,7 +17,6 @@
 # Decorating URL includes, <https://djangosnippets.org/snippets/2532/>
 
 import django
-
 from django.contrib.auth.decorators import user_passes_test
 from django.core.exceptions import PermissionDenied
 from django.db.models import Q
diff --git a/chrono/utils/requests_wrapper.py b/chrono/utils/requests_wrapper.py
index 5505e19..17361d0 100644
--- a/chrono/utils/requests_wrapper.py
+++ b/chrono/utils/requests_wrapper.py
@@ -17,15 +17,15 @@
 import hashlib
 import logging
 
-from requests import Response, Session as RequestsSession
-from requests.auth import AuthBase
-
 from django.conf import settings
 from django.core.cache import cache
 from django.utils.encoding import smart_bytes
 from django.utils.http import urlencode
-from django.utils.six.moves.urllib import parse as urlparse
 from django.utils.six import BytesIO
+from django.utils.six.moves.urllib import parse as urlparse
+from requests import Response
+from requests import Session as RequestsSession
+from requests.auth import AuthBase
 
 from .signature import sign_url
 
diff --git a/chrono/utils/signature.py b/chrono/utils/signature.py
index efd560e..0cc74c7 100644
--- a/chrono/utils/signature.py
+++ b/chrono/utils/signature.py
@@ -16,17 +16,16 @@
 
 import base64
 import datetime
-import hmac
 import hashlib
+import hmac
 import random
 
 from django.conf import settings
+from django.utils import six
 from django.utils.encoding import smart_bytes
 from django.utils.http import quote, urlencode
-from django.utils import six
 from django.utils.six.moves.urllib import parse as urlparse
 
-
 # Simple signature scheme for query strings
 
 
diff --git a/chrono/utils/spooler.py b/chrono/utils/spooler.py
index c0e6644..3ab6c3c 100644
--- a/chrono/utils/spooler.py
+++ b/chrono/utils/spooler.py
@@ -16,7 +16,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from django.db import connection
-
 from uwsgidecorators import spool
 
 from chrono.agendas.models import ICSError, TimePeriodExceptionSource
diff --git a/chrono/views.py b/chrono/views.py
index f26423a..2ce6833 100644
--- a/chrono/views.py
+++ b/chrono/views.py
@@ -23,7 +23,6 @@ from django.shortcuts import resolve_url
 from django.utils.decorators import method_decorator
 from django.views.decorators.cache import never_cache
 
-
 if 'mellon' in settings.INSTALLED_APPS:
     from mellon.utils import get_idps
 else:
diff --git a/setup.py b/setup.py
index 2412e9d..e10fd47 100644
--- a/setup.py
+++ b/setup.py
@@ -6,14 +6,14 @@ import os
 import re
 import subprocess
 import sys
-
-from setuptools.command.install_lib import install_lib as _install_lib
+from distutils.cmd import Command
 from distutils.command.build import build as _build
 from distutils.command.sdist import sdist
-from distutils.cmd import Command
 from distutils.errors import CompileError
 from distutils.spawn import find_executable
-from setuptools import setup, find_packages
+
+from setuptools import find_packages, setup
+from setuptools.command.install_lib import install_lib as _install_lib
 
 
 class eo_sdist(sdist):
diff --git a/tests/conftest.py b/tests/conftest.py
index bc14a96..ebd52a1 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,6 +1,5 @@
-import pytest
-
 import django_webtest
+import pytest
 
 
 @pytest.fixture
diff --git a/tests/manager/test_absence_reason.py b/tests/manager/test_absence_reason.py
index d4ffc29..d6db734 100644
--- a/tests/manager/test_absence_reason.py
+++ b/tests/manager/test_absence_reason.py
@@ -5,7 +5,7 @@ from __future__ import unicode_literals
 import pytest
 from django.contrib.auth.models import Group, User
 
-from chrono.agendas.models import Agenda, AbsenceReason, AbsenceReasonGroup
+from chrono.agendas.models import AbsenceReason, AbsenceReasonGroup, Agenda
 
 from .test_all import login
 
diff --git a/tests/manager/test_all.py b/tests/manager/test_all.py
index 1f85d90..46a1d70 100644
--- a/tests/manager/test_all.py
+++ b/tests/manager/test_all.py
@@ -1,13 +1,17 @@
 # -*- coding: utf-8 -*-
 
 from __future__ import unicode_literals
+
 import copy
 import datetime
 import json
-import mock
 import os
 
-from django.contrib.auth.models import User, Group
+import freezegun
+import mock
+import pytest
+import requests
+from django.contrib.auth.models import Group, User
 from django.core.files.base import ContentFile
 from django.core.management import call_command
 from django.db import connection
@@ -15,15 +19,12 @@ from django.test import override_settings
 from django.test.utils import CaptureQueriesContext
 from django.urls import reverse
 from django.utils.encoding import force_text
-from django.utils.timezone import make_aware, now, localtime
-
-import freezegun
-import pytest
-import requests
+from django.utils.timezone import localtime, make_aware, now
 from webtest import Upload
 
 from chrono.agendas.models import (
     Agenda,
+    AgendaReminderSettings,
     Booking,
     Desk,
     Event,
@@ -32,9 +33,8 @@ from chrono.agendas.models import (
     TimePeriod,
     TimePeriodException,
     TimePeriodExceptionSource,
-    VirtualMember,
-    AgendaReminderSettings,
     UnavailabilityCalendar,
+    VirtualMember,
 )
 from chrono.manager.forms import TimePeriodExceptionForm
 from chrono.utils.signature import check_query
diff --git a/tests/manager/test_event.py b/tests/manager/test_event.py
index 4ff1b45..9427b65 100644
--- a/tests/manager/test_event.py
+++ b/tests/manager/test_event.py
@@ -15,7 +15,7 @@ from django.test.utils import CaptureQueriesContext
 from django.utils.timezone import localtime, make_aware, now
 from webtest import Upload
 
-from chrono.agendas.models import Agenda, Booking, Event, AbsenceReasonGroup, AbsenceReason
+from chrono.agendas.models import AbsenceReason, AbsenceReasonGroup, Agenda, Booking, Event
 
 from .test_all import login
 
diff --git a/tests/test_agendas.py b/tests/test_agendas.py
index 667a84f..0ce5a24 100644
--- a/tests/test_agendas.py
+++ b/tests/test_agendas.py
@@ -1,35 +1,34 @@
-import pytest
 import datetime
 import json
-import mock
-import requests
 import smtplib
 
-
-from django.db.models import Q
+import mock
+import pytest
+import requests
 from django.contrib.auth.models import Group, User
 from django.core.files.base import ContentFile
 from django.core.management import call_command
+from django.db.models import Q
 from django.test import override_settings
 from django.utils.timezone import localtime, make_aware, now
 
 from chrono.agendas.models import (
     Agenda,
+    AgendaNotificationsSettings,
+    AgendaReminderSettings,
     Booking,
     Category,
     Desk,
     Event,
+    EventCancellationReport,
     ICSError,
     MeetingType,
     Resource,
     TimePeriod,
     TimePeriodException,
     TimePeriodExceptionSource,
-    VirtualMember,
-    EventCancellationReport,
-    AgendaNotificationsSettings,
-    AgendaReminderSettings,
     UnavailabilityCalendar,
+    VirtualMember,
 )
 
 pytestmark = pytest.mark.django_db
diff --git a/tests/test_api.py b/tests/test_api.py
index bda0ffa..6ef326b 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -1,19 +1,20 @@
 # -*- coding: utf-8 -*-
 
 import datetime
-import mock
 import urllib.parse as urlparse
-import pytest
 
+import mock
+import pytest
 from django.contrib.auth import get_user_model
 from django.db import connection
 from django.test import override_settings
 from django.test.utils import CaptureQueriesContext
-from django.utils.timezone import now, make_aware, localtime
+from django.utils.timezone import localtime, make_aware, now
 
 from chrono.agendas.models import (
     Agenda,
     Booking,
+    BookingColor,
     Category,
     Desk,
     Event,
@@ -23,10 +24,8 @@ from chrono.agendas.models import (
     TimePeriodException,
     UnavailabilityCalendar,
     VirtualMember,
-    BookingColor,
 )
 
-
 pytestmark = pytest.mark.django_db
 
 
diff --git a/tests/test_import_export.py b/tests/test_import_export.py
index e8203db..235fce8 100644
--- a/tests/test_import_export.py
+++ b/tests/test_import_export.py
@@ -4,39 +4,38 @@ from __future__ import unicode_literals
 
 import copy
 import datetime
-from io import StringIO
 import json
-import mock
 import os
 import shutil
 import sys
 import tempfile
+from io import StringIO
 
+import mock
 import pytest
 from dateutil.rrule import DAILY
-
 from django.contrib.auth.models import Group
-from django.core.management import call_command, CommandError
+from django.core.management import CommandError, call_command
 from django.test import override_settings
 from django.utils.encoding import force_bytes
 from django.utils.timezone import make_aware, now
 
 from chrono.agendas.models import (
+    AbsenceReasonGroup,
     Agenda,
+    AgendaImportError,
+    AgendaNotificationsSettings,
+    AgendaReminderSettings,
     Category,
     Desk,
     Event,
+    MeetingType,
     Resource,
     TimePeriod,
     TimePeriodException,
     TimePeriodExceptionSource,
-    AgendaImportError,
-    MeetingType,
-    VirtualMember,
-    AgendaNotificationsSettings,
-    AgendaReminderSettings,
     UnavailabilityCalendar,
-    AbsenceReasonGroup,
+    VirtualMember,
 )
 from chrono.manager.utils import import_site
 
diff --git a/tests/test_metz.py b/tests/test_metz.py
index ee924eb..fb66450 100644
--- a/tests/test_metz.py
+++ b/tests/test_metz.py
@@ -1,5 +1,4 @@
 import pytest
-
 from django.core.management import call_command
 
 
diff --git a/tests/test_misc.py b/tests/test_misc.py
index 258754e..de2772c 100644
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -1,21 +1,12 @@
 import datetime
 
-from django.db import IntegrityError
-from django.db import ProgrammingError
-from django.db import connection
-from django.db import transaction
+import pytest
+from django.db import IntegrityError, ProgrammingError, connection, transaction
 from django.db.migrations.executor import MigrationExecutor
 from django.test import override_settings
 from django.utils.timezone import now
 
-
-import pytest
-
-from chrono.agendas.models import Agenda
-from chrono.agendas.models import Booking
-from chrono.agendas.models import Desk
-from chrono.agendas.models import Event
-from chrono.agendas.models import MeetingType
+from chrono.agendas.models import Agenda, Booking, Desk, Event, MeetingType
 
 pytestmark = pytest.mark.django_db
 
diff --git a/tests/test_requests.py b/tests/test_requests.py
index d92f72f..ad62826 100644
--- a/tests/test_requests.py
+++ b/tests/test_requests.py
@@ -2,11 +2,10 @@
 
 import mock
 import pytest
-
 from django.contrib.auth.models import AnonymousUser
 from django.utils.six.moves.urllib import parse as urlparse
 
-from chrono.utils.requests_wrapper import requests, NothingInCacheException
+from chrono.utils.requests_wrapper import NothingInCacheException, requests
 from chrono.utils.signature import check_query
 
 
diff --git a/tests/test_sso.py b/tests/test_sso.py
index af0c5a4..8e521ab 100644
--- a/tests/test_sso.py
+++ b/tests/test_sso.py
@@ -1,5 +1,4 @@
 import pytest
-
 from django.test import override_settings
 
 from chrono.wsgi import application
diff --git a/tests/test_time_periods.py b/tests/test_time_periods.py
index 15ac888..8b0e33e 100644
--- a/tests/test_time_periods.py
+++ b/tests/test_time_periods.py
@@ -1,14 +1,14 @@
 # -*- coding: utf-8 -*-
 
 import datetime
-import pytest
 
+import pytest
 from django.db.models import Q
 from django.test import override_settings
 from django.utils.encoding import force_text
 from django.utils.timezone import localtime, make_aware
 
-from chrono.agendas.models import Agenda, TimePeriod, TimePeriodException, MeetingType, Desk
+from chrono.agendas.models import Agenda, Desk, MeetingType, TimePeriod, TimePeriodException
 
 pytestmark = pytest.mark.django_db
 
-- 
2.30.2

