Commit 07416dc2 authored by Hypsug0's avatar Hypsug0
Browse files

black format

parent b0e02799
......@@ -4,9 +4,21 @@ from django.contrib.auth.admin import UserAdmin
from .models import Profile
class GeoUserAdmin(LeafletGeoAdmin):
list_display = ['id','username','email','first_name','last_name','is_superuser','is_staff','is_active','last_login']
search_fields = ['username','email','first_name','last_name']
list_filter = ('is_active','is_staff','is_superuser')
list_display = [
"id",
"username",
"email",
"first_name",
"last_name",
"is_superuser",
"is_staff",
"is_active",
"last_login",
]
search_fields = ["username", "email", "first_name", "last_name"]
list_filter = ("is_active", "is_staff", "is_superuser")
admin.site.register(Profile, GeoUserAdmin)
......@@ -2,5 +2,5 @@ from django.apps import AppConfig
class AccountsConfig(AppConfig):
name = 'accounts'
label = 'Gestion des comptes observateurs'
name = "accounts"
label = "Gestion des comptes observateurs"
......@@ -3,16 +3,21 @@ import django_filters
from .models import Profile
from .forms import ProfileSearchFilterForm
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')
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"
)
class Meta:
model = Profile
fields = [
'username', 'first_name', 'last_name'
"username",
"first_name",
"last_name"
# , 'addr_city_code'
]
order_by = ['username']
form = ProfileSearchFilterForm
\ No newline at end of file
order_by = ["username"]
form = ProfileSearchFilterForm
......@@ -81,7 +81,11 @@ class UserCreateAdminForm(UserCreationForm):
self.helper.layout = Layout(
Row(
Column(
Submit("submit", _("Enregistrer"), css_class="btn-primary btn-sm",),
Submit(
"submit",
_("Enregistrer"),
css_class="btn-primary btn-sm",
),
Button(
"cancel",
_("Annuler"),
......@@ -101,12 +105,17 @@ class UserCreateAdminForm(UserCreationForm):
_("Identité"),
Row(
Column("email", css_class="col-xs-12 col-lg-6"),
Column("organism", css_class="col-xs-12 col-lg-6",),
Column(
"first_name", css_class="col-xs-12 col-lg-6",
"organism",
css_class="col-xs-12 col-lg-6",
),
Column(
"first_name",
css_class="col-xs-12 col-lg-6",
),
Column(
"last_name", css_class="col-xs-12 col-lg-6",
"last_name",
css_class="col-xs-12 col-lg-6",
),
),
Row(
......@@ -135,7 +144,8 @@ class UserCreateAdminForm(UserCreationForm):
css_class="col-xs-12 col-lg-6",
),
Column(
"edit_all_data", css_class="col-xs-12 col-lg-6",
"edit_all_data",
css_class="col-xs-12 col-lg-6",
),
Column("catchauth", css_class="col-lg-12"),
),
......@@ -157,7 +167,8 @@ class UserCreateAdminForm(UserCreationForm):
Fieldset(
_("Adresse postale"),
Column(
"addr_appt", css_class="col-lg-2 col-md-3 col-xs-6",
"addr_appt",
css_class="col-lg-2 col-md-3 col-xs-6",
),
Column(
"addr_building",
......@@ -169,7 +180,8 @@ class UserCreateAdminForm(UserCreationForm):
),
Column("addr_city", css_class="col-lg-6 col-md-12"),
Column(
"addr_city_code", css_class="col-lg-3 col-md-12",
"addr_city_code",
css_class="col-lg-3 col-md-12",
),
Column("addr_dept", css_class="col-lg-3 col-md-12"),
Column("addr_country", css_class="col-lg-12"),
......@@ -182,7 +194,9 @@ class UserCreateAdminForm(UserCreationForm):
"Source",
Row(
Column(
"bdsource", css_class="col-md-6 col-xs-12", readonly=True,
"bdsource",
css_class="col-md-6 col-xs-12",
readonly=True,
),
Column(
"id_bdsource",
......@@ -197,7 +211,11 @@ class UserCreateAdminForm(UserCreationForm):
),
Row(
Column(
Submit("submit", _("Enregistrer"), css_class="btn-primary btn-sm",),
Submit(
"submit",
_("Enregistrer"),
css_class="btn-primary btn-sm",
),
Button(
"cancel",
_("Annuler"),
......@@ -263,7 +281,11 @@ class UserCreateForm(UserCreationForm):
self.helper.layout = Layout(
Row(
Column(
Submit("submit", _("Enregistrer"), css_class="btn-primary btn-sm",),
Submit(
"submit",
_("Enregistrer"),
css_class="btn-primary btn-sm",
),
Button(
"cancel",
_("Annuler"),
......@@ -283,12 +305,17 @@ class UserCreateForm(UserCreationForm):
_("Identité"),
Row(
Column("email", css_class="col-xs-12 col-lg-6"),
Column("organism", css_class="col-xs-12 col-lg-6",),
Column(
"first_name", css_class="col-xs-12 col-lg-6",
"organism",
css_class="col-xs-12 col-lg-6",
),
Column(
"last_name", css_class="col-xs-12 col-lg-6",
"first_name",
css_class="col-xs-12 col-lg-6",
),
Column(
"last_name",
css_class="col-xs-12 col-lg-6",
),
),
Row(
......@@ -320,7 +347,8 @@ class UserCreateForm(UserCreationForm):
Fieldset(
_("Adresse postale"),
Column(
"addr_appt", css_class="col-lg-2 col-md-3 col-xs-6",
"addr_appt",
css_class="col-lg-2 col-md-3 col-xs-6",
),
Column(
"addr_building",
......@@ -332,7 +360,8 @@ class UserCreateForm(UserCreationForm):
),
Column("addr_city", css_class="col-lg-6 col-md-12"),
Column(
"addr_city_code", css_class="col-lg-3 col-md-12",
"addr_city_code",
css_class="col-lg-3 col-md-12",
),
Column("addr_dept", css_class="col-lg-3 col-md-12"),
Column("addr_country", css_class="col-lg-12"),
......@@ -345,7 +374,9 @@ class UserCreateForm(UserCreationForm):
"Source",
Row(
Column(
"bdsource", css_class="col-md-6 col-xs-12", readonly=True,
"bdsource",
css_class="col-md-6 col-xs-12",
readonly=True,
),
Column(
"id_bdsource",
......@@ -360,7 +391,11 @@ class UserCreateForm(UserCreationForm):
),
Row(
Column(
Submit("submit", _("Enregistrer"), css_class="btn-primary btn-sm",),
Submit(
"submit",
_("Enregistrer"),
css_class="btn-primary btn-sm",
),
Button(
"cancel",
_("Annuler"),
......@@ -499,7 +534,11 @@ class UserUpdateAdminForm(forms.ModelForm):
self.helper.layout = Layout(
Row(
Column(
Submit("submit", _("Enregistrer"), css_class="btn-primary btn-sm",),
Submit(
"submit",
_("Enregistrer"),
css_class="btn-primary btn-sm",
),
Button(
"cancel",
_("Annuler"),
......@@ -536,17 +575,20 @@ class UserUpdateAdminForm(forms.ModelForm):
Fieldset(
_("Responsabilité et autorisations"),
Column(
"is_resp", css_class="col-xs-12 col-md-3 col-lg-2",
"is_resp",
css_class="col-xs-12 col-md-3 col-lg-2",
),
Column(
"resp_territory",
css_class="col-xs-12 col-md-9 col-lg-10",
),
Column(
"access_all_data", css_class="col-xs-12 col-lg-6",
"access_all_data",
css_class="col-xs-12 col-lg-6",
),
Column(
"edit_all_data", css_class="col-xs-12 col-lg-6",
"edit_all_data",
css_class="col-xs-12 col-lg-6",
),
Column("catchauth", css_class="col-lg-12"),
css_class="col-lg-12",
......@@ -567,7 +609,8 @@ class UserUpdateAdminForm(forms.ModelForm):
Fieldset(
_("Adresse postale"),
Column(
"addr_appt", css_class="col-lg-2 col-md-3 col-xs-6",
"addr_appt",
css_class="col-lg-2 col-md-3 col-xs-6",
),
Column(
"addr_building",
......@@ -579,7 +622,8 @@ class UserUpdateAdminForm(forms.ModelForm):
),
Column("addr_city", css_class="col-lg-6 col-md-12"),
Column(
"addr_city_code", css_class="col-lg-3 col-md-12",
"addr_city_code",
css_class="col-lg-3 col-md-12",
),
Column("addr_dept", css_class="col-lg-3 col-md-12"),
Column("addr_country", css_class="col-lg-12"),
......@@ -592,7 +636,9 @@ class UserUpdateAdminForm(forms.ModelForm):
"Source",
Row(
Column(
"bdsource", css_class="col-md-6 col-xs-12", readonly=True,
"bdsource",
css_class="col-md-6 col-xs-12",
readonly=True,
),
Column(
"id_bdsource",
......@@ -607,7 +653,11 @@ class UserUpdateAdminForm(forms.ModelForm):
),
Row(
Column(
Submit("submit", _("Enregistrer"), css_class="btn-primary btn-sm",),
Submit(
"submit",
_("Enregistrer"),
css_class="btn-primary btn-sm",
),
Button(
"cancel",
_("Annuler"),
......@@ -639,7 +689,9 @@ class UserAdminUpdatePasswordForm(forms.ModelForm):
help_text=password_validation.password_validators_help_text_html(),
)
new_password2 = forms.CharField(
label=_("New password confirmation"), strip=False, widget=forms.PasswordInput,
label=_("New password confirmation"),
strip=False,
widget=forms.PasswordInput,
)
class Meta:
......@@ -682,7 +734,8 @@ class UserAdminUpdatePasswordForm(forms.ModelForm):
if password1 and password2:
if password1 != password2:
raise forms.ValidationError(
self.error_messages["password_mismatch"], code="password_mismatch",
self.error_messages["password_mismatch"],
code="password_mismatch",
)
password_validation.validate_password(password2)
return password2
......@@ -737,12 +790,17 @@ class UserUpdateForm(forms.ModelForm):
Fieldset(
_("Caractéristiques principales"),
Row(
Column("email", css_class="col-xs-12 col-md-12 col-lg-4",),
Column(
"first_name", css_class="col-xs-12 col-md-6 col-lg-4",
"email",
css_class="col-xs-12 col-md-12 col-lg-4",
),
Column(
"last_name", css_class="col-xs-12 col-md-6 col-lg-4",
"first_name",
css_class="col-xs-12 col-md-6 col-lg-4",
),
Column(
"last_name",
css_class="col-xs-12 col-md-6 col-lg-4",
),
Field("username", type="hidden"),
),
......@@ -750,12 +808,18 @@ class UserUpdateForm(forms.ModelForm):
Fieldset(
_("Responsabilité et autorisations"),
Row(
Column("is_resp", css_class="col-xs-12 col-md-3 col-lg-2",),
Column(
"is_resp",
css_class="col-xs-12 col-md-3 col-lg-2",
),
Column(
"resp_territory",
css_class="col-xs-12 col-md-9 col-lg-10",
),
Column("access_all_data", css_class="col-xs-12 col-lg-6",),
Column(
"access_all_data",
css_class="col-xs-12 col-lg-6",
),
Column("edit_all_data", css_class="col-xs-12 col-lg-6"),
Column("catchauth", css_class="col-lg-12"),
),
......@@ -772,9 +836,13 @@ class UserUpdateForm(forms.ModelForm):
_("Adresse postale"),
Column("addr_appt", css_class="col-lg-2 col-md-3 col-xs-6"),
Column(
"addr_building", css_class="col-lg-2 col-md-3 col-xs-6",
"addr_building",
css_class="col-lg-2 col-md-3 col-xs-6",
),
Column(
"addr_street",
css_class="col-lg-8 col-md-6 col-xs-12",
),
Column("addr_street", css_class="col-lg-8 col-md-6 col-xs-12",),
Column("addr_city", css_class="col-lg-6 col-md-12"),
Column("addr_city_code", css_class="col-lg-3 col-md-12"),
Column("addr_dept", css_class="col-lg-3 col-md-12"),
......@@ -838,7 +906,11 @@ class PasswordResetForm(PasswordResetForm):
self.helper.layout = Layout(
"email",
Div(
Submit("submit", "Réinitialiser le mot de passe", css_class="button",),
Submit(
"submit",
"Réinitialiser le mot de passe",
css_class="button",
),
HTML('<a class="button alert" href="/">Annuler</a>'),
css_class="text-right",
),
......
......@@ -82,7 +82,9 @@ 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"),
"management.CatchAuth",
blank=True,
verbose_name=_("Authorisations de capture"),
)
organism = models.CharField(
max_length=255, blank=True, null=True, verbose_name=_("Organisme")
......
......@@ -2,4 +2,4 @@ from django.apps import AppConfig
class ApiConfig(AppConfig):
name = 'api'
name = "api"
from django.contrib import admin
from .models import Actu
class ActuAdmin(admin.ModelAdmin):
list_display = ('title', 'author', 'timestamp_create', 'timestamp_update')
list_display = ("title", "author", "timestamp_create", "timestamp_update")
fieldsets = [
(None, {'fields': ('title', 'briefdescr', 'text')}),
(None, {"fields": ("title", "briefdescr", "text")}),
]
def save_model(self, request, obj, form, change):
if getattr(obj, 'author', None) is None:
if getattr(obj, "author", None) is None:
obj.author = request.user
obj.save()
# Register your models here.
admin.site.register(Actu, ActuAdmin)
\ No newline at end of file
admin.site.register(Actu, ActuAdmin)
......@@ -2,4 +2,4 @@ from django.apps import AppConfig
class BlogConfig(AppConfig):
name = 'blog'
name = "blog"
......@@ -10,34 +10,54 @@ from .models import Actu
class ActuForm(forms.ModelForm):
class Meta:
model = Actu
fields = ('title', 'briefdescr', 'text')
fields = ("title", "briefdescr", "text")
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_method = 'post'
self.helper.form_action = 'submit'
self.helper.form_method = "post"
self.helper.form_action = "submit"
self.helper.form_show_errors = True
self.helper.layout = Layout(
Row(Column(
Submit('submit', _('Enregistrer'), css_class="btn-primary btn-sm"),
Button('cancel', _('Retour'), css_class='btn-warning btn-sm', onclick="history.go(-1)"),
css_class='col-lg-12 btn-group pull-right', role='button'
), ),
Row(
Column(
Submit("submit", _("Enregistrer"), css_class="btn-primary btn-sm"),
Button(
"cancel",
_("Retour"),
css_class="btn-warning btn-sm",
onclick="history.go(-1)",
),
css_class="col-lg-12 btn-group pull-right",
role="button",
),
),
Div(
Div(
Row(
Column(
Column('title', css_class='col-lg-12'),
Column('briefdescr', css_class='col-lg-12'),
Column('text', css_class='col-lg-12'),
css_class='col-lg-12'),
), css_class='panel-body'),
css_class='panel panel-default'),
Row(Column(
Submit('submit', _('Enregistrer'), css_class="btn-primary btn-sm"),
Button('cancel', _('Retour'), css_class='btn-warning btn-sm', onclick="history.go(-1)"),
css_class='col-lg-12 btn-group pull-right', role='button'
), ),
Column("title", css_class="col-lg-12"),
Column("briefdescr", css_class="col-lg-12"),
Column("text", css_class="col-lg-12"),
css_class="col-lg-12",
),
),
css_class="panel-body",
),
css_class="panel panel-default",
),
Row(
Column(
Submit("submit", _("Enregistrer"), css_class="btn-primary btn-sm"),
Button(
"cancel",
_("Retour"),
css_class="btn-warning btn-sm",
onclick="history.go(-1)",
),
css_class="col-lg-12 btn-group pull-right",
role="button",
),
),
)
super(ActuForm, self).__init__(*args, **kwargs)
......@@ -2,4 +2,4 @@ from django.apps import AppConfig
class CoreConfig(AppConfig):
name = 'core'
\ No newline at end of file
name = "core"
from crispy_forms.helper import FormHelper
from crispy_forms.bootstrap import AccordionGroup
def input_sm_helper(form):
""" set all bootstrap input as input-sm """
form.helper = FormHelper(form)
form.helper.field_class = 'input-sm'
form.helper.field_class = "input-sm"
class PrimaryAccordionGroup(AccordionGroup):
template = 'crispy/accordion-group-primary.html'
template = "crispy/accordion-group-primary.html"
class InfoAccordionGroup(AccordionGroup):
template = 'crispy/accordion-group-info.html'
template = "crispy/accordion-group-info.html"
class DangerAccordionGroup(AccordionGroup):
template = 'crispy/accordion-group-danger.html'
\ No newline at end of file
template = "crispy/accordion-group-danger.html"
import logging
import logging
import os
from django.contrib.auth.mixins import LoginRequiredMixin
......@@ -9,6 +9,7 @@ from .functions import version
logger = logging.getLogger(__name__)
def db_datas():
with connection.cursor() as cursor:
cursor.execute(
......
......@@ -76,7 +76,7 @@ MAIN_APPS = [
"django_extensions",
"rest_framework",
"rest_framework_gis",
'drf_yasg',
"drf_yasg",
]
PROJECT_APPS = [
......@@ -109,7 +109,9 @@ ROOT_URLCONF = "dbchiro.urls"
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [root("templates"),],
"DIRS": [
root("templates"),
],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
......@@ -123,7 +125,11 @@ TEMPLATES = [
},
]
CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache",}}
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
}
}
WSGI_APPLICATION = "dbchiro.wsgi.application"
......@@ -220,9 +226,15 @@ AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]
# Internationalization
......@@ -341,7 +353,9 @@ LEAFLET_CONFIG = {
"js": "/static/js/leaflet/Leaflet.fullscreen.min.js",
"css": "/static/css/leaflet.fullscreen.css",
},
"ajax": {"js": "/static/js/leaflet/leaflet.ajax.min.js",},
"ajax": {
"js": "/static/js/leaflet/leaflet.ajax.min.js",
},
},
}
......
"""FICHIER DE CONFIGURATION DE DBCHIROWEB"""
# Nom du site, affiché sur les pages internet.
SITE_NAME = 'dbChiro[web] GCRA'