Commit c36bfe9c authored by Hypsug0's avatar Hypsug0
Browse files

style: apply isort and black format

parent accbed19
from django.contrib import admin
from leaflet.admin import LeafletGeoAdminMixin, LeafletGeoAdmin
from django.contrib.auth.admin import UserAdmin
from leaflet.admin import LeafletGeoAdmin, LeafletGeoAdminMixin
from .models import Profile
......
import django_filters
from .models import Profile
from .forms import ProfileSearchFilterForm
from .models import Profile
class ProfileFilter(django_filters.FilterSet):
username = django_filters.CharFilter(label="Utilisateur", lookup_expr="icontains")
first_name = django_filters.CharFilter(label="Prénom", lookup_expr="icontains")
last_name = django_filters.CharFilter(
label="Nom de famille", lookup_expr="icontains"
)
last_name = django_filters.CharFilter(label="Nom de famille", lookup_expr="icontains")
class Meta:
model = Profile
......
......@@ -26,9 +26,7 @@ class ManageAccountAuthMixin(LoginRequiredMixin):
or loggeduser.is_staff
or loggeduser.is_superuser
):
return super(ManageAccountAuthMixin, self).dispatch(
request, *args, **kwargs
)
return super(ManageAccountAuthMixin, self).dispatch(request, *args, **kwargs)
else:
return redirect("core:view_unauth")
......@@ -44,8 +42,6 @@ class ManageMyAccountAuthMixin(LoginRequiredMixin):
else:
loggeduser = get_user_model().objects.get(id=request.user.id)
if loggeduser.id == request.user.id:
return super(ManageMyAccountAuthMixin, self).dispatch(
request, *args, **kwargs
)
return super(ManageMyAccountAuthMixin, self).dispatch(request, *args, **kwargs)
else:
return redirect("core:view_unauth")
......@@ -2,15 +2,8 @@ import uuid
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import (
AbstractBaseUser,
PermissionsMixin,
UserManager,
)
from django.contrib.auth.validators import (
ASCIIUsernameValidator,
UnicodeUsernameValidator,
)
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, UserManager
from django.contrib.auth.validators import ASCIIUsernameValidator, UnicodeUsernameValidator
from django.contrib.gis.db import models
from django.contrib.postgres.fields import JSONField
from django.core.mail import send_mail
......@@ -21,7 +14,6 @@ from django.utils.translation import ugettext_lazy as _
from geodata.models import Territory
from management.models import CatchAuth
# Create your models here.
......@@ -37,17 +29,13 @@ class Profile(AbstractBaseUser, PermissionsMixin):
Username and password are required. Other fields are optional.
"""
username_validator = (
UnicodeUsernameValidator() if six.PY3 else ASCIIUsernameValidator()
)
username_validator = UnicodeUsernameValidator() if six.PY3 else ASCIIUsernameValidator()
uuid = models.UUIDField(default=uuid.uuid4, unique=True, editable=False)
username = models.CharField(
_("username"),
max_length=150,
unique=True,
help_text=_(
"Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only."
),
help_text=_("Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only."),
validators=[username_validator],
error_messages={"unique": _("A user with that username already exists.")},
)
......@@ -68,9 +56,7 @@ class Profile(AbstractBaseUser, PermissionsMixin):
),
)
date_joined = models.DateTimeField(_("date joined"), default=timezone.now)
is_resp = models.BooleanField(
default=False, verbose_name=_("Responsable d" "un territoire")
)
is_resp = models.BooleanField(default=False, verbose_name=_("Responsable d" "un territoire"))
resp_territory = models.ManyToManyField(
Territory, blank=True, verbose_name=_("Territoires du rôle de coordinateur")
)
......@@ -81,11 +67,11 @@ class Profile(AbstractBaseUser, PermissionsMixin):
default=False, verbose_name=_("Peut éditer toutes les données")
)
catchauth = models.ManyToManyField(
"management.CatchAuth", blank=True, verbose_name=_("Authorisations de capture"),
)
organism = models.CharField(
max_length=255, blank=True, null=True, verbose_name=_("Organisme")
"management.CatchAuth",
blank=True,
verbose_name=_("Authorisations de capture"),
)
organism = models.CharField(max_length=255, blank=True, null=True, verbose_name=_("Organisme"))
home_phone = models.CharField(
max_length=50, blank=True, null=True, verbose_name=_("Numéro de téléphone fixe")
)
......@@ -101,21 +87,15 @@ class Profile(AbstractBaseUser, PermissionsMixin):
addr_building = models.CharField(
max_length=255, blank=True, null=True, verbose_name=_("Immeuble")
)
addr_street = models.CharField(
max_length=255, blank=True, null=True, verbose_name=_("Rue")
)
addr_city = models.CharField(
max_length=255, blank=True, null=True, verbose_name=_("Commune")
)
addr_street = models.CharField(max_length=255, blank=True, null=True, verbose_name=_("Rue"))
addr_city = models.CharField(max_length=255, blank=True, null=True, verbose_name=_("Commune"))
addr_city_code = models.CharField(
max_length=10, blank=True, null=True, verbose_name=_("Code postal")
)
addr_dept = models.CharField(
max_length=255, blank=True, null=True, verbose_name=_("Département")
)
addr_country = models.CharField(
max_length=255, blank=True, null=True, verbose_name=_("Pays")
)
addr_country = models.CharField(max_length=255, blank=True, null=True, verbose_name=_("Pays"))
comment = models.TextField(blank=True, null=True, verbose_name=_("Commentaire"))
id_bdsource = models.CharField(max_length=100, blank=True, null=True)
bdsource = models.CharField(max_length=100, blank=True, null=True)
......
......@@ -65,9 +65,7 @@ class ProfileTable(tables.Table):
orderable=False,
attrs={"th": {"style": "width: 75px;"}},
)
username = tables.LinkColumn(
"accounts:user_detail", args=[A("id")], accessor="username"
)
username = tables.LinkColumn("accounts:user_detail", args=[A("id")], accessor="username")
modify_by = tables.TemplateColumn(
MODIFY_BY, verbose_name="Dernière modification", orderable=False
)
......
from django.urls import path, re_path
from .views import (
MyProfileDetail,
MyProfileDetailExport,
MyProfileUpdate,
UserCreate,
UserUpdate,
UserPassword,
UserDelete,
change_password,
UserListView,
UserDetail,
MyProfileUpdate,
MyProfileDetail,
MyProfileDetailExport,
UserListView,
UserPassword,
UserUpdate,
change_password,
)
# from django.contrib.auth.paths import views
......
......@@ -5,23 +5,24 @@ from django.contrib.auth import get_user_model, update_session_auth_hash
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin
from django.core.mail import send_mail
from django.forms.models import model_to_dict
from django.shortcuts import render
from django.urls import reverse, reverse_lazy
from django.utils.translation import ugettext_lazy as _
from django.views.generic import DetailView
from django.views.generic.edit import CreateView, UpdateView, DeleteView
from django.views.generic.base import TemplateResponseMixin
from django.views.generic.edit import CreateView, DeleteView, UpdateView
from django_filters.views import FilterView
from django_tables2 import SingleTableView
from django.views.generic.base import TemplateResponseMixin
from django.forms.models import model_to_dict
from core.functions import generate_username
from .filters import ProfileFilter
from .forms import (
PasswordUpdateForm,
UserAdminUpdatePasswordForm,
UserCreateAdminForm,
UserCreateForm,
UserAdminUpdatePasswordForm,
PasswordUpdateForm,
UserUpdateAdminForm,
UserUpdateForm,
)
......@@ -204,9 +205,7 @@ class UserDelete(ManageAccountAuthMixin, DeleteView):
context = super(UserDelete, self).get_context_data(**kwargs)
context["icon"] = "fi-trash"
context["title"] = "Suppression d'un compte"
context["message_alert"] = _(
"Êtes-vous certain de vouloir supprimer l'utilisateur"
)
context["message_alert"] = _("Êtes-vous certain de vouloir supprimer l'utilisateur")
return context
......
# -*- coding: utf-8 -*-
from django.urls import path
from django.contrib.auth.decorators import login_required
from django.urls import path
from djgeojson.views import GeoJSONLayerView, TiledGeoJSONLayerView
from sights.models import Place
from sights.models import Territory, Municipality
from sights.models import Municipality, Place, Territory
from .views import (
places_as_geojson,
PlaceAutocomplete,
AllUserAutocomplete,
ActiveUserAutocomplete,
AllUserAutocomplete,
GeoJSONTiledPlaceData,
MetaPlaceAutocomplete,
MunicipalityAutocomplete,
TerritoryAutocomplete,
PlaceAutocomplete,
TaxaAutocomplete,
MetaPlaceAutocomplete,
TerritoryAutocomplete,
metaplaces_as_geojson,
places_in_metaplaces_as_geojson,
places_as_geojson,
places_in_metaplace_as_geojson,
GeoJSONTiledPlaceData,
places_in_metaplaces_as_geojson,
)
app_name = "general_api"
......
......@@ -6,14 +6,14 @@ 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 Q, Count
from django.db.models import Count, Q
from django.http import HttpResponse
from djgeojson.views import GeoJSONLayerView, TiledGeoJSONLayerView
from accounts.models import UserFullName
from dicts.models import Specie
from geodata.models import Territory, Municipality
from sights.models import Place, MetaPlace
from geodata.models import Municipality, Territory
from sights.models import MetaPlace, Place
# Get an instance of a logger
logger = logging.getLogger(__name__)
......@@ -132,10 +132,7 @@ class PlaceAutocomplete(LoginRequiredMixin, autocomplete.Select2QuerySetView):
Q(is_hidden=False)
| (
Q(is_hidden=True)
& (
Q(created_by=loggeduser)
| Q(authorized_user=loggeduser)
)
& (Q(created_by=loggeduser) | Q(authorized_user=loggeduser))
)
)
)
......@@ -218,10 +215,7 @@ class GeoJSONTiledPlaceData(LoginRequiredMixin, TiledGeoJSONLayerView):
Q(is_hidden=False)
| (
Q(is_hidden=True)
& (
Q(created_by=loggeduser)
| Q(authorized_user=loggeduser)
)
& (Q(created_by=loggeduser) | Q(authorized_user=loggeduser))
)
)
)
......@@ -231,10 +225,7 @@ class GeoJSONTiledPlaceData(LoginRequiredMixin, TiledGeoJSONLayerView):
logger.debug("Chargement de la carte pour l'obs lambda")
qs = qs.filter(
Q(is_hidden=False)
| (
Q(is_hidden=True)
& Q(authorized_user__username__contains=loggeduser.username)
)
| (Q(is_hidden=True) & Q(authorized_user__username__contains=loggeduser.username))
)
return qs
......
from django.contrib import admin
from .models import Actu
......
from crispy_forms.bootstrap import Div
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Column, Layout, Row, Submit, Button
from crispy_forms.layout import Button, Column, Layout, Row, Submit
from django import forms
from django.utils.translation import ugettext_lazy as _
......
......@@ -25,9 +25,7 @@ class BlogCreateAuthMixin:
or loggeduser.is_staff
or loggeduser.is_superuser
):
return super(BlogCreateAuthMixin, self).dispatch(
request, *args, **kwargs
)
return super(BlogCreateAuthMixin, self).dispatch(request, *args, **kwargs)
else:
return redirect("core:view_unauth")
......@@ -51,8 +49,6 @@ class BlogModifyAuthMixin:
or loggeduser.is_superuser
or loggeduser == obj.created_by
):
return super(BlogModifyAuthMixin, self).dispatch(
request, *args, **kwargs
)
return super(BlogModifyAuthMixin, self).dispatch(request, *args, **kwargs)
else:
return redirect("core:view_unauth")
......@@ -4,7 +4,6 @@ from django.db import models
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
# Create your models here.
......
from django.urls import path
from .views import ActuCreate, ActuUpdate, ActuDelete, ActuDetail, ActuList
from .views import ActuCreate, ActuDelete, ActuDetail, ActuList, ActuUpdate
app_name = "blog"
......
......@@ -4,14 +4,14 @@ 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, UpdateView, DeleteView
from django.views.generic.edit import CreateView, DeleteView, UpdateView
from .mixins import BlogCreateAuthMixin, BlogModifyAuthMixin
from .forms import ActuForm
from .models import Actu
from sights.models import Place, Session, Sighting
from accounts.models import Profile
from sights.models import Place, Session, Sighting
from .forms import ActuForm
from .mixins import BlogCreateAuthMixin, BlogModifyAuthMixin
from .models import Actu
# Create your views here.
......@@ -70,9 +70,7 @@ class ActuDelete(BlogModifyAuthMixin, DeleteView):
context = super(ActuDelete, self).get_context_data(**kwargs)
context["icon"] = "fi-trash"
context["title"] = _("Suppression d'une actualité")
context["message_alert"] = _(
"Êtes-vous certain de vouloir supprimer l'actualité"
)
context["message_alert"] = _("Êtes-vous certain de vouloir supprimer l'actualité")
return context
......
from crispy_forms.helper import FormHelper
from crispy_forms.bootstrap import AccordionGroup
from crispy_forms.helper import FormHelper
def input_sm_helper(form):
......
......@@ -23,9 +23,7 @@ class ManageAccountAuthMixin:
or loggeduser.is_staff
or loggeduser.is_superuser
):
return super(ManageAccountAuthMixin, self).dispatch(
request, *args, **kwargs
)
return super(ManageAccountAuthMixin, self).dispatch(request, *args, **kwargs)
else:
return redirect("core:view_unauth")
......
from django.urls import path
from .views import UnauthorizedModify, UnauthorizedView, SystemInformation
from .views import SystemInformation, UnauthorizedModify, UnauthorizedView
app_name = "core"
urlpatterns = [
......
......@@ -2,10 +2,11 @@ import logging
import os
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import TemplateView
from django.db import connection
from .mixins import AdminRequiredMixin
from django.views.generic import TemplateView
from .functions import version
from .mixins import AdminRequiredMixin
logger = logging.getLogger(__name__)
......@@ -30,9 +31,7 @@ class UnauthorizedModify(LoginRequiredMixin, TemplateView):
def get_context_data(self, **kwargs):
context = super(UnauthorizedModify, self).get_context_data(**kwargs)
context[
"message"
] = "Vous n'êtes pas autorisé à modifier ou supprimer cette donnée"
context["message"] = "Vous n'êtes pas autorisé à modifier ou supprimer cette donnée"
return context
......
from django.conf import settings
from core.functions import version
......
Supports Markdown
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