From 5bc518eba6db5ccc04a48613d62a2a4fe702f494 Mon Sep 17 00:00:00 2001 From: Tom Hubrecht Date: Sun, 7 Feb 2021 23:24:33 +0100 Subject: [PATCH] Isort --- avisstage/admin.py | 5 +- avisstage/api.py | 6 +- avisstage/decorators.py | 2 +- avisstage/documents.py | 2 +- avisstage/forms.py | 10 +-- .../management/commands/nettoie_lieux.py | 3 +- .../management/commands/nettoie_stages.py | 3 +- .../management/commands/supprime_lieu.py | 3 +- .../management/commands/termine_scolarite.py | 9 +-- avisstage/migrations/0001_initial.py | 11 ++-- .../migrations/0002_auto_20171002_2243.py | 3 +- .../migrations/0003_auto_20210117_1208.py | 2 +- .../migrations/0004_allauth_to_authens.py | 1 - .../migrations/0006_auto_20210131_1954.py | 3 +- avisstage/models.py | 36 +++++------ avisstage/templatetags/avisstage_tags.py | 5 +- avisstage/tests.py | 19 +++--- avisstage/urls.py | 6 +- avisstage/views.py | 64 +++++++++---------- avisstage/views_search.py | 24 ++++--- setup.cfg | 10 +++ 21 files changed, 121 insertions(+), 106 deletions(-) create mode 100644 setup.cfg diff --git a/avisstage/admin.py b/avisstage/admin.py index 52a6c2d..9bf977f 100644 --- a/avisstage/admin.py +++ b/avisstage/admin.py @@ -1,9 +1,10 @@ +import authens.models as authmod + from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User -from avisstage.models import * -import authens.models as authmod +from avisstage.models import * class NormalienInline(admin.StackedInline): diff --git a/avisstage/api.py b/avisstage/api.py index 61e555f..4d53f95 100644 --- a/avisstage/api.py +++ b/avisstage/api.py @@ -1,13 +1,13 @@ # coding: utf-8 -from tastypie.resources import ModelResource -from tastypie.authentication import SessionAuthentication from tastypie import fields, utils +from tastypie.authentication import SessionAuthentication +from tastypie.resources import ModelResource from django.contrib.gis import geos from django.urls import reverse -from .models import Lieu, Stage, Normalien, StageMatiere +from .models import Lieu, Normalien, Stage, StageMatiere from .utils import approximate_distance diff --git a/avisstage/decorators.py b/avisstage/decorators.py index 8437240..5886ddf 100644 --- a/avisstage/decorators.py +++ b/avisstage/decorators.py @@ -1,7 +1,7 @@ from functools import wraps -from django.urls import reverse from django.shortcuts import redirect +from django.urls import reverse def en_scolarite_required(view_func): diff --git a/avisstage/documents.py b/avisstage/documents.py index f8fde43..9191a24 100644 --- a/avisstage/documents.py +++ b/avisstage/documents.py @@ -1,7 +1,7 @@ from django_elasticsearch_dsl import Document, Index, fields from elasticsearch_dsl import analyzer, token_filter, tokenizer -from .models import Stage, AvisStage, AvisLieu +from .models import AvisLieu, AvisStage, Stage from .statics import PAYS_OPTIONS PAYS_DICT = dict(PAYS_OPTIONS) diff --git a/avisstage/forms.py b/avisstage/forms.py index d3da9a4..d778e5c 100644 --- a/avisstage/forms.py +++ b/avisstage/forms.py @@ -1,16 +1,16 @@ +import re import unicodedata +from simple_email_confirmation.models import EmailAddress + from django import forms from django.contrib.auth.forms import PasswordResetForm from django.utils import timezone -from simple_email_confirmation.models import EmailAddress - -import re - -from .models import Normalien, Stage, Lieu, AvisLieu, AvisStage, User +from .models import AvisLieu, AvisStage, Lieu, Normalien, Stage, User from .widgets import LatLonField + # Sur-classe utile class HTMLTrimmerForm(forms.ModelForm): def clean(self): diff --git a/avisstage/management/commands/nettoie_lieux.py b/avisstage/management/commands/nettoie_lieux.py index 02daea2..a857503 100644 --- a/avisstage/management/commands/nettoie_lieux.py +++ b/avisstage/management/commands/nettoie_lieux.py @@ -1,7 +1,8 @@ # coding: utf-8 from django.core.management.base import BaseCommand, CommandError from django.db.models import Count -from avisstage.models import Stage, Lieu + +from avisstage.models import Lieu, Stage class Command(BaseCommand): diff --git a/avisstage/management/commands/nettoie_stages.py b/avisstage/management/commands/nettoie_stages.py index eec8e9b..72600b9 100644 --- a/avisstage/management/commands/nettoie_stages.py +++ b/avisstage/management/commands/nettoie_stages.py @@ -1,7 +1,8 @@ # coding: utf-8 from django.core.management.base import BaseCommand, CommandError from django.db.models import Count -from avisstage.models import Stage, Lieu + +from avisstage.models import Lieu, Stage class Command(BaseCommand): diff --git a/avisstage/management/commands/supprime_lieu.py b/avisstage/management/commands/supprime_lieu.py index dd779a2..02c54aa 100644 --- a/avisstage/management/commands/supprime_lieu.py +++ b/avisstage/management/commands/supprime_lieu.py @@ -1,7 +1,8 @@ # coding: utf-8 from django.core.management.base import BaseCommand, CommandError from django.db.models import Count -from avisstage.models import Stage, Lieu + +from avisstage.models import Lieu, Stage class Command(BaseCommand): diff --git a/avisstage/management/commands/termine_scolarite.py b/avisstage/management/commands/termine_scolarite.py index aaf1e9e..41f489a 100644 --- a/avisstage/management/commands/termine_scolarite.py +++ b/avisstage/management/commands/termine_scolarite.py @@ -1,9 +1,10 @@ -from django.core.management.base import BaseCommand, CommandError -from avisstage.models import Normalien - -from django.utils import timezone from datetime import timedelta +from django.core.management.base import BaseCommand, CommandError +from django.utils import timezone + +from avisstage.models import Normalien + class Command(BaseCommand): help = 'Réinitialise les statuts "en scolarité" de tout le monde' diff --git a/avisstage/migrations/0001_initial.py b/avisstage/migrations/0001_initial.py index a083c8d..85df322 100644 --- a/avisstage/migrations/0001_initial.py +++ b/avisstage/migrations/0001_initial.py @@ -2,14 +2,15 @@ # Generated by Django 1.11 on 2017-06-20 17:45 from __future__ import unicode_literals -from django.conf import settings -import django.contrib.gis.db.models.fields -from django.db import migrations, models -import django.db.models.deletion -import django.utils.timezone import taggit_autosuggest.managers import tinymce.models +import django.contrib.gis.db.models.fields +import django.db.models.deletion +import django.utils.timezone +from django.conf import settings +from django.db import migrations, models + class Migration(migrations.Migration): diff --git a/avisstage/migrations/0002_auto_20171002_2243.py b/avisstage/migrations/0002_auto_20171002_2243.py index bdfefce..f2b0136 100644 --- a/avisstage/migrations/0002_auto_20171002_2243.py +++ b/avisstage/migrations/0002_auto_20171002_2243.py @@ -2,9 +2,10 @@ # Generated by Django 1.11.2 on 2017-10-02 20:43 from __future__ import unicode_literals -from django.db import migrations, models import tinymce.models +from django.db import migrations, models + class Migration(migrations.Migration): diff --git a/avisstage/migrations/0003_auto_20210117_1208.py b/avisstage/migrations/0003_auto_20210117_1208.py index 4d13ea9..3b200ac 100644 --- a/avisstage/migrations/0003_auto_20210117_1208.py +++ b/avisstage/migrations/0003_auto_20210117_1208.py @@ -1,8 +1,8 @@ # Generated by Django 2.2.17 on 2021-01-17 11:08 +import django.db.models.deletion from django.conf import settings from django.db import migrations, models -import django.db.models.deletion class Migration(migrations.Migration): diff --git a/avisstage/migrations/0004_allauth_to_authens.py b/avisstage/migrations/0004_allauth_to_authens.py index 29f8f8b..3ab2c60 100644 --- a/avisstage/migrations/0004_allauth_to_authens.py +++ b/avisstage/migrations/0004_allauth_to_authens.py @@ -1,6 +1,5 @@ from django.apps import apps as global_apps from django.db import migrations - from django.utils import timezone diff --git a/avisstage/migrations/0006_auto_20210131_1954.py b/avisstage/migrations/0006_auto_20210131_1954.py index c940e17..f7b7394 100644 --- a/avisstage/migrations/0006_auto_20210131_1954.py +++ b/avisstage/migrations/0006_auto_20210131_1954.py @@ -1,8 +1,9 @@ # Generated by Django 2.2.17 on 2021-01-31 18:54 -import avisstage.models from django.db import migrations, models +import avisstage.models + class Migration(migrations.Migration): diff --git a/avisstage/models.py b/avisstage/models.py index 9439748..c0c7838 100644 --- a/avisstage/models.py +++ b/avisstage/models.py @@ -1,34 +1,32 @@ -from django.db import models -from django.db.models.signals import post_save +from datetime import timedelta + +from authens.models import CASAccount +from authens.signals import post_cas_connect +from taggit_autosuggest.managers import TaggableManager +from tinymce.models import HTMLField as RichTextField + from django.contrib.auth.models import User from django.contrib.gis.db import models as geomodels -from django.template.defaultfilters import slugify +from django.db import models +from django.db.models.signals import post_save from django.forms.widgets import DateInput +from django.template.defaultfilters import slugify from django.urls import reverse - from django.utils import timezone from django.utils.functional import cached_property from django.utils.html import strip_tags -from taggit_autosuggest.managers import TaggableManager -from tinymce.models import HTMLField as RichTextField - -from authens.signals import post_cas_connect -from authens.models import CASAccount - -from datetime import timedelta - -from .utils import choices_length, is_email_ens from .statics import ( DEPARTEMENTS_DEFAUT, - PAYS_OPTIONS, - TYPE_LIEU_OPTIONS, - TYPE_STAGE_OPTIONS, - TYPE_LIEU_DICT, - TYPE_STAGE_DICT, - NIVEAU_SCOL_OPTIONS, NIVEAU_SCOL_DICT, + NIVEAU_SCOL_OPTIONS, + PAYS_OPTIONS, + TYPE_LIEU_DICT, + TYPE_LIEU_OPTIONS, + TYPE_STAGE_DICT, + TYPE_STAGE_OPTIONS, ) +from .utils import choices_length, is_email_ens def _default_cas_login(): diff --git a/avisstage/templatetags/avisstage_tags.py b/avisstage/templatetags/avisstage_tags.py index bba61d5..eb31cc5 100644 --- a/avisstage/templatetags/avisstage_tags.py +++ b/avisstage/templatetags/avisstage_tags.py @@ -1,8 +1,9 @@ # coding: utf-8 +import re + from django import template -from avisstage.forms import LieuForm, FeedbackForm -import re +from avisstage.forms import FeedbackForm, LieuForm register = template.Library() diff --git a/avisstage/tests.py b/avisstage/tests.py index 2c9b760..559b50b 100644 --- a/avisstage/tests.py +++ b/avisstage/tests.py @@ -1,16 +1,15 @@ -from authens.tests.cas_utils import FakeCASClient -from authens.models import CASAccount, OldCASAccount - from datetime import date, timedelta - -from django.test import TestCase -from django.urls import reverse -from django.conf import settings -from django.utils import timezone - from unittest import mock -from .models import User, Normalien, Lieu, Stage, StageMatiere, AvisLieu +from authens.models import CASAccount, OldCASAccount +from authens.tests.cas_utils import FakeCASClient + +from django.conf import settings +from django.test import TestCase +from django.urls import reverse +from django.utils import timezone + +from .models import AvisLieu, Lieu, Normalien, Stage, StageMatiere, User class ExperiENSTestCase(TestCase): diff --git a/avisstage/urls.py b/avisstage/urls.py index b7ce528..97647e7 100644 --- a/avisstage/urls.py +++ b/avisstage/urls.py @@ -1,7 +1,9 @@ -from django.urls import include, path -from . import views, api from tastypie.api import Api +from django.urls import include, path + +from . import api, views + v1_api = Api(api_name="v1") v1_api.register(api.LieuResource()) v1_api.register(api.StageResource()) diff --git a/avisstage/views.py b/avisstage/views.py index 57fcaba..ce26aa2 100644 --- a/avisstage/views.py +++ b/avisstage/views.py @@ -1,49 +1,49 @@ # coding: utf-8 -from django.shortcuts import render, redirect, get_object_or_404 +import math +import random +from collections import Counter, defaultdict + +from braces.views import LoginRequiredMixin +from simple_email_confirmation.models import EmailAddress -from django.views.generic import ( - DetailView, - ListView, - UpdateView, - CreateView, - TemplateView, - DeleteView, - FormView, - View, -) -from django.views.generic.detail import SingleObjectMixin from django import forms -from django.urls import reverse, reverse_lazy from django.conf import settings +from django.contrib import messages from django.contrib.admin.views.decorators import staff_member_required from django.contrib.auth.decorators import login_required from django.contrib.auth.tokens import default_token_generator from django.contrib.auth.views import PasswordResetConfirmView -from django.contrib import messages -from braces.views import LoginRequiredMixin -from django.http import JsonResponse, HttpResponseForbidden, Http404 from django.core.mail import send_mail -from django.db.models import Q, Count -from collections import Counter, defaultdict -from simple_email_confirmation.models import EmailAddress - -from .models import Normalien, Stage, Lieu, AvisLieu, AvisStage -from .forms import ( - StageForm, - LieuForm, - AvisStageForm, - AvisLieuForm, - FeedbackForm, - AdresseEmailForm, - ReinitMdpForm, +from django.db.models import Count, Q +from django.http import Http404, HttpResponseForbidden, JsonResponse +from django.shortcuts import get_object_or_404, redirect, render +from django.urls import reverse, reverse_lazy +from django.views.generic import ( + CreateView, + DeleteView, + DetailView, + FormView, + ListView, + TemplateView, + UpdateView, + View, ) +from django.views.generic.detail import SingleObjectMixin + +from .forms import ( + AdresseEmailForm, + AvisLieuForm, + AvisStageForm, + FeedbackForm, + LieuForm, + ReinitMdpForm, + StageForm, +) +from .models import AvisLieu, AvisStage, Lieu, Normalien, Stage from .utils import en_scolarite - from .views_search import * -import random, math - # # LECTURE # diff --git a/avisstage/views_search.py b/avisstage/views_search.py index f8fe183..f88b411 100644 --- a/avisstage/views_search.py +++ b/avisstage/views_search.py @@ -1,18 +1,17 @@ # coding: utf-8 -from datetime import date - -from django import forms -from django.contrib.auth.decorators import login_required -from django.conf import settings -from django.core.cache import cache -from django.core.paginator import Paginator -from django.db.models import Q, Case, When -from django.http import JsonResponse, HttpResponseBadRequest -from django.shortcuts import render, redirect, get_object_or_404 - import json import logging +from datetime import date + +from django import forms +from django.conf import settings +from django.contrib.auth.decorators import login_required +from django.core.cache import cache +from django.core.paginator import Paginator +from django.db.models import Case, Q, When +from django.http import HttpResponseBadRequest, JsonResponse +from django.shortcuts import get_object_or_404, redirect, render USE_ELASTICSEARCH = getattr(settings, "USE_ELASTICSEARCH", True) @@ -21,8 +20,7 @@ if USE_ELASTICSEARCH: from .decorators import en_scolarite_required from .models import Stage -from .statics import TYPE_LIEU_OPTIONS, TYPE_STAGE_OPTIONS, NIVEAU_SCOL_OPTIONS - +from .statics import NIVEAU_SCOL_OPTIONS, TYPE_LIEU_OPTIONS, TYPE_STAGE_OPTIONS logger = logging.getLogger("recherche") diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..81f23f8 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,10 @@ +[flake8] +max-line-length = 99 +exclude = .git, *.pyc, __pycache__, migrations +extend-ignore = E231, E203 + +[isort] +profile = black +known_django = django +known_first_party = avisstage +sections = FUTURE,STDLIB,THIRDPARTY,DJANGO,FIRSTPARTY,LOCALFOLDER