Commit 4d51fa07 authored by Hypsug0's avatar Hypsug0
Browse files

Flake8 code check

parent 0995f942
[flake8]
ignore = D203, E203
ignore = D203, E203, W503, E501
exclude =
.git,
.venv,
__pycache__,
docs/source/conf.py,
frontend,
node-modules,
build,
dist,
migrations
max-complexity = 10
\ No newline at end of file
repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3.8
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from leaflet.admin import LeafletGeoAdmin, LeafletGeoAdminMixin
from leaflet.admin import LeafletGeoAdmin
from .models import Profile
......
"""
Mixins
Mixins
"""
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin
from django.shortcuts import redirect
......@@ -16,7 +15,7 @@ class ManageAccountAuthMixin(LoginRequiredMixin):
def dispatch(self, request, *args, **kwargs):
if not request.user.is_authenticated:
return redirect("%s?next=%s" % (reverse("auth_login"), request.path))
return redirect(f"{reverse('auth_login')}?next={request.path}")
else:
loggeduser = get_user_model().objects.get(id=request.user.id)
if (
......
......@@ -12,7 +12,6 @@ from django.utils import six, timezone
from django.utils.translation import ugettext_lazy as _
from geodata.models import Territory
from management.models import CatchAuth
# Create your models here.
......
from django.test import TestCase
# from django.test import TestCase
# Create your tests here.
from django.urls import path, re_path
from django.urls import path
from .views import (
MyProfileDetail,
......
......@@ -126,7 +126,7 @@ class UserUpdate(ManageAccountAuthMixin, UpdateView):
def get_form_kwargs(self):
kwargs = super(UserUpdate, self).get_form_kwargs()
user = self.request.user
# user = self.request.user
return kwargs
def form_valid(self, form):
......
from django.contrib import admin
# from django.contrib import admin
# Register your models here.
from django.db import models
# from django.db import models
# Create your models here.
from django.test import TestCase
# from django.test import TestCase
# Create your tests here.
......@@ -2,9 +2,9 @@
from django.contrib.auth.decorators import login_required
from django.urls import path
from djgeojson.views import GeoJSONLayerView, TiledGeoJSONLayerView
from djgeojson.views import GeoJSONLayerView
from sights.models import Municipality, Place, Territory
from sights.models import Municipality, Territory
from .views import (
ActiveUserAutocomplete,
......
......@@ -6,7 +6,7 @@ from django.contrib.auth import get_user_model
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.serializers import serialize
from django.db.models import Count, Q
from django.db.models import Q
from django.http import HttpResponse
from djgeojson.views import GeoJSONLayerView, TiledGeoJSONLayerView
......@@ -117,7 +117,7 @@ class PlaceAutocomplete(LoginRequiredMixin, autocomplete.Select2QuerySetView):
loggeduser = self.request.user
userdetail = get_user_model().objects.get(id=loggeduser.id)
places = Place.objects.filter(telemetric_crossaz=False)
if userdetail.access_all_data == True:
if userdetail.access_all_data is True:
logger.debug("Chargement de la carte pour l'utilisateur avec accès total")
qs = places
elif userdetail.is_resp:
......@@ -198,7 +198,7 @@ class GeoJSONTiledPlaceData(LoginRequiredMixin, TiledGeoJSONLayerView):
user = get_user_model().objects.get(id=loggeduser.id)
qs = super(GeoJSONTiledPlaceData, self).get_queryset()
qs = qs.filter(telemetric_crossaz=False)
if user.access_all_data == True:
if user.access_all_data is True:
logger.debug("Chargement de la carte pour l'utilisateur avec accès total")
qs = qs
elif user.is_resp:
......@@ -241,7 +241,7 @@ def places_as_geojson(request):
loggeduser = request.user
userdetail = get_user_model().objects.get(id=loggeduser.id)
places = Place.objects.filter(telemetric_crossaz=False)
if userdetail.access_all_data == True:
if userdetail.access_all_data is True:
logger.debug("Chargement de la carte pour l'utilisateur avec accès total")
place_list = places
elif userdetail.is_resp:
......@@ -297,7 +297,7 @@ def places_in_metaplaces_as_geojson(request):
loggeduser = request.user
userdetail = get_user_model().objects.get(id=loggeduser.id)
places = Place.objects.exclude(metaplace__isnull=True)
if userdetail.access_all_data == True:
if userdetail.access_all_data is True:
logger.debug("Chargement de la carte pour l'utilisateur avec accès total")
place_list = places
elif userdetail.is_resp:
......
"""
Mixins
Mixins
"""
from django.conf import settings
from django.contrib.auth import get_user_model
from django.shortcuts import redirect
from django.urls import reverse
......
from django.test import TestCase
# from django.test import TestCase
# Create your tests here.
from django.contrib.auth.mixins import LoginRequiredMixin
from django.shortcuts import get_object_or_404, render
from django.urls import reverse_lazy
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from django.views.generic import DetailView, ListView
from django.views.generic.edit import CreateView, DeleteView, UpdateView
......@@ -36,7 +33,7 @@ class ActuCreate(BlogCreateAuthMixin, CreateView):
context["title"] = _("Ajout d'une actualité")
context[
"js"
] = """
] = """
"""
return context
......@@ -56,7 +53,7 @@ class ActuUpdate(BlogModifyAuthMixin, UpdateView):
context["title"] = _("Modification d'une actualité")
context[
"js"
] = """
] = """
"""
return context
......@@ -83,7 +80,7 @@ class ActuDetail(DetailView):
context["icon"] = "fi-align-left"
context[
"js"
] = """
] = """
"""
return context
......
from django.contrib import admin
# from django.contrib import admin
# Register your models here.
"""
Mixins
Mixins
"""
from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
from django.shortcuts import redirect
from django.urls import reverse
......
from django.db import models
#!/usr/bin/python
"""core Models
"""
# from django.contrib import admin
from django.test import TestCase
# from django.test import TestCase
# Create your tests here.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment