Commit dfaadcb7 authored by fred.perso's avatar fred.perso

Merge branch 'uuid' into 'master'

Uuid

See merge request !15
parents dee7c278 33c446f3
......@@ -18,3 +18,4 @@ import_bdchironalpesra.sh
/core/static/img/logo_site.png
core/static/img/logo_site.png
.vscode/*
/docs/build
\ No newline at end of file
from crispy_forms.bootstrap import Accordion, Div, Field
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Fieldset, ButtonHolder, Column, Layout, Row, Submit, Button, HTML
from crispy_forms.layout import (
Fieldset,
ButtonHolder,
Column,
Layout,
Row,
Submit,
Button,
HTML,
)
from dal import autocomplete
from django.contrib.auth import get_user_model
from django.contrib.auth import password_validation
from django.contrib.auth.forms import UserCreationForm, PasswordChangeForm, PasswordResetForm
from django.contrib.auth.forms import (
UserCreationForm,
PasswordChangeForm,
PasswordResetForm,
)
from django.contrib.gis import forms
from django.forms import CharField
from django.forms.widgets import HiddenInput
......@@ -15,7 +28,7 @@ from .models import Profile
class UserCreateAdminForm(UserCreationForm):
username = CharField(initial='tmpusername123')
username = CharField(initial="tmpusername123")
password_clear = CharField()
# password_clear = CharField(
......@@ -28,95 +41,196 @@ class UserCreateAdminForm(UserCreationForm):
class Meta:
model = Profile
fields = UserCreationForm.Meta.fields + (
'first_name', 'last_name', 'email', 'is_resp', 'resp_territory', 'access_all_data',
'edit_all_data', 'catchauth',
'organism', 'mobile_phone', 'home_phone', 'addr_appt', 'addr_building', 'addr_street', 'addr_city',
'addr_city_code',
'addr_dept', 'addr_country',
'comment', 'id_bdsource', 'bdsource')
widgets = {'username': HiddenInput(),
'password1': HiddenInput(), 'password2': HiddenInput(),
'resp_territory': autocomplete.ModelSelect2Multiple(url='api:territory_autocomplete'), }
"first_name",
"last_name",
"email",
"is_resp",
"resp_territory",
"access_all_data",
"edit_all_data",
"catchauth",
"organism",
"mobile_phone",
"home_phone",
"addr_appt",
"addr_building",
"addr_street",
"addr_city",
"addr_city_code",
"addr_dept",
"addr_country",
"comment",
"id_bdsource",
"bdsource",
)
widgets = {
"username": HiddenInput(),
"password1": HiddenInput(),
"password2": HiddenInput(),
"resp_territory": autocomplete.ModelSelect2Multiple(
url="api:territory_autocomplete"
),
}
# readonly_fields = ('password_gen',)
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.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 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 right",
role="button",
)
),
Accordion(
PrimaryAccordionGroup('Informations principales',
Row(
Column(
Fieldset(_("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'),
Column('last_name', css_class='col-xs-12 col-lg-6'),
),
Row(
Field('username', type="hidden"),
Field('password1', type='hidden'),
Field('password2', type='hidden'),
Field('password_clear', type='hidden'),
),
css_class='col-lg-12'),
Fieldset(_("Responsabilité et autorisations"),
Row(
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'),
),
Row(
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'),
),
css_class='col-lg-12'),
), ), ),
InfoAccordionGroup(_('Coordonnées'),
Row(
Column(
Fieldset(_('Numéros de téléphone'),
Column('mobile_phone', css_class='col-lg-6'),
Column('home_phone', css_class='col-lg-6'),
css_class='col-lg-12'),
Fieldset(_('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'),
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'),
Column('addr_country', css_class='col-lg-12'),
css_class='col-lg-12'),
), ), ),
PrimaryAccordionGroup(
"Informations principales",
Row(
Column(
Fieldset(
_("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",
),
Column(
"last_name",
css_class="col-xs-12 col-lg-6",
),
),
Row(
Field("username", type="hidden"),
Field("password1", type="hidden"),
Field("password2", type="hidden"),
Field("password_clear", type="hidden"),
),
css_class="col-lg-12",
),
Fieldset(
_("Responsabilité et autorisations"),
Row(
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",
),
),
Row(
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"),
),
css_class="col-lg-12",
),
)
),
),
InfoAccordionGroup(
'Source',
_("Coordonnées"),
Row(
Column('bdsource', css_class='col-md-6 col-xs-12', readonly=True),
Column('id_bdsource', css_class='col-md-6 col-xs-12', readonly=True),
Column(
Fieldset(
_("Numéros de téléphone"),
Column("mobile_phone", css_class="col-lg-6"),
Column("home_phone", css_class="col-lg-6"),
css_class="col-lg-12",
),
Fieldset(
_("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",
),
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"
),
Column("addr_country", css_class="col-lg-12"),
css_class="col-lg-12",
),
)
),
),
InfoAccordionGroup(
'Commentaire',
"Source",
Row(
Column('comment', css_class='col-lg-12'),
Column(
"bdsource",
css_class="col-md-6 col-xs-12",
readonly=True,
),
Column(
"id_bdsource",
css_class="col-md-6 col-xs-12",
readonly=True,
),
),
),
InfoAccordionGroup(
"Commentaire", Row(Column("comment", css_class="col-lg-12"))
),
),
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 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 right', role='button'
), ),
)
self.helper.form_show_errors = True
......@@ -124,7 +238,7 @@ class UserCreateAdminForm(UserCreationForm):
class UserCreateForm(UserCreationForm):
username = CharField(initial='tmpusername123')
username = CharField(initial="tmpusername123")
password_clear = CharField()
# password_clear = CharField(
......@@ -137,87 +251,172 @@ class UserCreateForm(UserCreationForm):
class Meta:
model = Profile
fields = UserCreationForm.Meta.fields + (
'first_name', 'last_name', 'email', 'catchauth',
'organism', 'mobile_phone', 'home_phone', 'addr_appt', 'addr_building', 'addr_street', 'addr_city',
'addr_city_code',
'addr_dept', 'addr_country',
'comment', 'id_bdsource', 'bdsource')
widgets = {'username': HiddenInput(),
'password1': HiddenInput(), 'password2': HiddenInput(),
'resp_territory': autocomplete.ModelSelect2Multiple(url='api:territory_autocomplete'), }
"first_name",
"last_name",
"email",
"catchauth",
"organism",
"mobile_phone",
"home_phone",
"addr_appt",
"addr_building",
"addr_street",
"addr_city",
"addr_city_code",
"addr_dept",
"addr_country",
"comment",
"id_bdsource",
"bdsource",
)
widgets = {
"username": HiddenInput(),
"password1": HiddenInput(),
"password2": HiddenInput(),
"resp_territory": autocomplete.ModelSelect2Multiple(
url="api:territory_autocomplete"
),
}
# readonly_fields = ('password_gen',)
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.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 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 right",
role="button",
)
),
Accordion(
PrimaryAccordionGroup('Informations principales',
Row(
Column(
Fieldset(_("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'),
Column('last_name', css_class='col-xs-12 col-lg-6'),
),
Row(
Field('username', type="hidden"),
Field('password1', type='hidden'),
Field('password2', type='hidden'),
Field('password_clear', type='hidden'),
),
css_class='col-lg-12'),
Fieldset(_("Responsabilité et autorisations"),
Row(
Column('catchauth', css_class='col-lg-12'),
),
css_class='col-lg-12'),
), ), ),
InfoAccordionGroup(_('Coordonnées'),
Row(
Column(
Fieldset(_('Numéros de téléphone'),
Column('mobile_phone', css_class='col-lg-6'),
Column('home_phone', css_class='col-lg-6'),
css_class='col-lg-12'),
Fieldset(_('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'),
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'),
Column('addr_country', css_class='col-lg-12'),
css_class='col-lg-12'),
), ), ),
PrimaryAccordionGroup(
"Informations principales",
Row(
Column(
Fieldset(
_("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",
),
Column(
"last_name",
css_class="col-xs-12 col-lg-6",
),
),
Row(
Field("username", type="hidden"),
Field("password1", type="hidden"),
Field("password2", type="hidden"),
Field("password_clear", type="hidden"),
),
css_class="col-lg-12",
),
Fieldset(
_("Responsabilité et autorisations"),
Row(Column("catchauth", css_class="col-lg-12")),
css_class="col-lg-12",
),
)
),
),
InfoAccordionGroup(
'Source',
_("Coordonnées"),
Row(
Column('bdsource', css_class='col-md-6 col-xs-12', readonly=True),
Column('id_bdsource', css_class='col-md-6 col-xs-12', readonly=True),
Column(
Fieldset(
_("Numéros de téléphone"),
Column("mobile_phone", css_class="col-lg-6"),
Column("home_phone", css_class="col-lg-6"),
css_class="col-lg-12",
),
Fieldset(
_("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",
),
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"
),
Column("addr_country", css_class="col-lg-12"),
css_class="col-lg-12",
),
)
),
),
InfoAccordionGroup(
'Commentaire',
"Source",
Row(
Column('comment', css_class='col-lg-12'),
Column(
"bdsource",
css_class="col-md-6 col-xs-12",
readonly=True,
),
Column(
"id_bdsource",
css_class="col-md-6 col-xs-12",
readonly=True,
),
),
),
InfoAccordionGroup(
"Commentaire", Row(Column("comment", css_class="col-lg-12"))
),
),
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 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 right', role='button'
), ),
)
self.helper.form_show_errors = True
......@@ -253,81 +452,182 @@ class UserUpdateAdminForm(forms.ModelForm):
class Meta:
model = Profile
fields = UserCreationForm.Meta.fields + (
'first_name', 'last_name', 'email', 'organism', 'is_resp', 'resp_territory', 'access_all_data',
'edit_all_data', 'catchauth', 'mobile_phone', 'home_phone', 'addr_appt', 'addr_building', 'addr_street',
'addr_city', 'addr_city_code',
'addr_dept', 'addr_country', 'comment', 'id_bdsource', 'bdsource')
widgets = {'resp_territory': autocomplete.ModelSelect2Multiple(url='api:territory_autocomplete'), }
"first_name",
"last_name",
"email",
"organism",
"is_resp",
"resp_territory",
"access_all_data",
"edit_all_data",
"catchauth",
"mobile_phone",
"home_phone",
"addr_appt",
"addr_building",
"addr_street",
"addr_city",
"addr_city_code",
"addr_dept",
"addr_country",
"comment",
"id_bdsource",
"bdsource",
)
widgets = {
"resp_territory": autocomplete.ModelSelect2Multiple(
url="api:territory_autocomplete"
)
}
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_method = 'post'
self.helper.form_method = "post"
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 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 right",
role="button",
)
),
Accordion(
PrimaryAccordionGroup('Informations principales',
Row(
Column(
Fieldset(_("Caractéristiques principales"),
Column('email', css_class='col-xs-12 col-lg-6'),
Column('organism', css_class='col-xs-12 col-lg-6'),
Column('username', css_class='col-xs-12 col-sm-12 col-lg-4'),
Column('first_name', css_class='col-xs-12 col-sm-6 col-lg-4'),
Column('last_name', css_class='col-xs-12 col-sm-6 col-lg-4'),
css_class='col-lg-12'),
Fieldset(_("Responsabilité et autorisations"),
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('edit_all_data', css_class='col-xs-12 col-lg-6'),
Column('catchauth', css_class='col-lg-12'),
css_class='col-lg-12'),
), ), ),
InfoAccordionGroup(_('Coordonnées'),
Row(
Column(
Fieldset(_('Numéros de téléphone'),
Column('mobile_phone', css_class='col-lg-6'),
Column('home_phone', css_class='col-lg-6'),
css_class='col-lg-12'),
Fieldset(_('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'),
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'),
Column('addr_country', css_class='col-lg-12'),
css_class='col-lg-12'),
), ), ),
PrimaryAccordionGroup(
"Informations principales",
Row(
Column(
Fieldset(
_("Caractéristiques principales"),
Column("email", css_class="col-xs-12 col-lg-6"),
Column(
"organism", css_class="col-xs-12 col-lg-6"
),
Column(
"username",
css_class="col-xs-12 col-sm-12 col-lg-4",
),
Column(
"first_name",
css_class="col-xs-12 col-sm-6 col-lg-4",
),
Column(
"last_name",
css_class="col-xs-12 col-sm-6 col-lg-4",
),
css_class="col-lg-12",
),
Fieldset(
_("Responsabilité et autorisations"),
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(
"edit_all_data",
css_class="col-xs-12 col-lg-6",
),
Column("catchauth", css_class="col-lg-12"),
css_class="col-lg-12",
),
)
),
),