Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dbchiro
dbchiroweb
Commits
9131586c
Commit
9131586c
authored
Jan 07, 2020
by
Hypsug0
Browse files
Fix superuser creation skipped if superuser exists
parent
0a5631cf
Changes
27
Hide whitespace changes
Inline
Side-by-side
accounts/models.py
View file @
9131586c
...
...
@@ -82,9 +82,7 @@ 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"
)
...
...
accounts/tables.py
View file @
9131586c
...
...
@@ -6,7 +6,7 @@ from .models import Profile
class
ProfileTable
(
tables
.
Table
):
ACTIONS
=
'''
ACTIONS
=
"""
<div class="btn-group btn-group-xs">
<button type="button" class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
...
...
@@ -49,29 +49,49 @@ class ProfileTable(tables.Table):
</div>
</div>
</div>
'''
"""
MODIFY_BY
=
"""
{% if record.updated_by %}{{record.updated_by}}{% else %}{{ record.created_by }}{% endif %}
"""
is_resp
=
tables
.
BooleanColumn
(
verbose_name
=
_
(
'
Responsable local
'
))
access_all_data
=
tables
.
BooleanColumn
(
verbose_name
=
_
(
'
Peut tout lire
'
))
edit_all_data
=
tables
.
BooleanColumn
(
verbose_name
=
_
(
'
Peut tout éditer
'
))
mobile_phone
=
tables
.
Column
(
verbose_name
=
_
(
'
n° mobile
'
))
home_phone
=
tables
.
Column
(
verbose_name
=
_
(
'
n° domicile
'
))
email
=
tables
.
EmailColumn
(
verbose_name
=
_
(
'
@email
'
))
is_resp
=
tables
.
BooleanColumn
(
verbose_name
=
_
(
"
Responsable local
"
))
access_all_data
=
tables
.
BooleanColumn
(
verbose_name
=
_
(
"
Peut tout lire
"
))
edit_all_data
=
tables
.
BooleanColumn
(
verbose_name
=
_
(
"
Peut tout éditer
"
))
mobile_phone
=
tables
.
Column
(
verbose_name
=
_
(
"
n° mobile
"
))
home_phone
=
tables
.
Column
(
verbose_name
=
_
(
"
n° domicile
"
))
email
=
tables
.
EmailColumn
(
verbose_name
=
_
(
"
@email
"
))
actions
=
tables
.
TemplateColumn
(
ACTIONS
,
verbose_name
=
"Actions"
,
orderable
=
False
,
attrs
=
{
'th'
:
{
'style'
:
'width: 75px;'
}})
username
=
tables
.
LinkColumn
(
'accounts:user_detail'
,
args
=
[
A
(
'id'
)],
accessor
=
'username'
)
ACTIONS
,
verbose_name
=
"Actions"
,
orderable
=
False
,
attrs
=
{
"th"
:
{
"style"
:
"width: 75px;"
}},
)
username
=
tables
.
LinkColumn
(
"accounts:user_detail"
,
args
=
[
A
(
"id"
)],
accessor
=
"username"
)
modify_by
=
tables
.
TemplateColumn
(
MODIFY_BY
,
verbose_name
=
"Dernière modification"
,
orderable
=
False
)
MODIFY_BY
,
verbose_name
=
"Dernière modification"
,
orderable
=
False
)
last_login
=
tables
.
DateTimeColumn
()
class
Meta
:
model
=
Profile
template
=
'
table_bootstrap.html
'
attrs
=
{
'
class
'
:
'
table table-striped
'
}
template
=
"
table_bootstrap.html
"
attrs
=
{
"
class
"
:
"
table table-striped
"
}
fields
=
(
'actions'
,
'username'
,
'email'
,
'first_name'
,
'last_name'
,
'organism'
,
'is_active'
,
'is_resp'
,
'access_all_data'
,
'edit_all_data'
,
'home_phone'
,
'mobile_phone'
,
'addr_city'
,
'last_login'
,
'modify_by'
,)
exclude
=
(
'id'
,)
"actions"
,
"username"
,
"email"
,
"first_name"
,
"last_name"
,
"organism"
,
"is_active"
,
"is_resp"
,
"access_all_data"
,
"edit_all_data"
,
"home_phone"
,
"mobile_phone"
,
"addr_city"
,
"last_login"
,
"modify_by"
,
)
exclude
=
(
"id"
,)
accounts/urls.py
View file @
9131586c
...
...
@@ -24,7 +24,11 @@ urlpatterns = [
path
(
"<int:pk>/detail"
,
UserDetail
.
as_view
(),
name
=
"user_detail"
),
path
(
"myprofile/change_password"
,
change_password
,
name
=
"change_password"
),
path
(
"myprofile/detail"
,
MyProfileDetail
.
as_view
(),
name
=
"myprofile_detail"
),
path
(
"myprofile/detail/export"
,
MyProfileDetailExport
.
as_view
(),
name
=
"myprofile_detail_export"
),
path
(
"myprofile/detail/export"
,
MyProfileDetailExport
.
as_view
(),
name
=
"myprofile_detail_export"
,
),
path
(
"myprofile/update"
,
MyProfileUpdate
.
as_view
(),
name
=
"myprofile_update"
),
path
(
"list"
,
UserListView
.
as_view
(),
name
=
"user_search"
),
]
accounts/views.py
View file @
9131586c
...
...
@@ -31,6 +31,7 @@ from .tables import ProfileTable
logger
=
logging
.
getLogger
(
__name__
)
class
UserCreate
(
ManageAccountAuthMixin
,
CreateView
):
"""
User Creation View
...
...
@@ -185,9 +186,7 @@ class MyProfileUpdate(ManageMyAccountAuthMixin, UpdateView):
return
super
(
MyProfileUpdate
,
self
).
form_valid
(
form
)
def
get_object
(
self
):
return
get_user_model
().
objects
.
get
(
id
=
self
.
request
.
user
.
id
)
# or request.POST
return
get_user_model
().
objects
.
get
(
id
=
self
.
request
.
user
.
id
)
# or request.POST
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
MyProfileUpdate
,
self
).
get_context_data
(
**
kwargs
)
...
...
@@ -214,31 +213,30 @@ class UserDelete(ManageAccountAuthMixin, DeleteView):
class
UserDetail
(
LoginRequiredMixin
,
DetailView
):
model
=
get_user_model
()
template_name
=
"accounts/profile.html"
class
MyProfileDetail
(
LoginRequiredMixin
,
DetailView
):
model
=
get_user_model
()
template_name
=
"accounts/profile.html"
def
get_object
(
self
):
logger
.
info
(
self
.
request
.
user
.
id
)
return
get_user_model
().
objects
.
get
(
id
=
self
.
request
.
user
.
id
)
return
get_user_model
().
objects
.
get
(
id
=
self
.
request
.
user
.
id
)
class
MyProfileDetailExport
(
LoginRequiredMixin
,
DetailView
,
TemplateResponseMixin
):
class
MyProfileDetailExport
(
LoginRequiredMixin
,
DetailView
,
TemplateResponseMixin
):
model
=
get_user_model
()
content_type
=
"text/plain; charset=utf-8"
content_type
=
"text/plain; charset=utf-8"
template_name
=
"accounts/personnal_data.txt"
def
get_object
(
self
):
logger
.
debug
(
self
.
request
.
user
.
id
)
profile
=
get_user_model
().
objects
.
get
(
id
=
self
.
request
.
user
.
id
)
dict
=
model_to_dict
(
profile
)
del
dict
[
'
password
'
]
del
dict
[
"
password
"
]
return
dict
@
login_required
()
def
change_password
(
request
):
"""
...
...
blog/urls.py
View file @
9131586c
...
...
@@ -11,4 +11,4 @@ urlpatterns = [
path
(
"actu/add"
,
ActuCreate
.
as_view
(),
name
=
"actu_create"
),
path
(
"actu/<int:pk>/update"
,
ActuUpdate
.
as_view
(),
name
=
"actu_update"
),
path
(
"actu/<int:pk>/delete"
,
ActuDelete
.
as_view
(),
name
=
"actu_delete"
),
]
\ No newline at end of file
]
blog/views.py
View file @
9131586c
...
...
@@ -19,10 +19,11 @@ from accounts.models import Profile
# model = Actu
#
class
ActuCreate
(
BlogCreateAuthMixin
,
CreateView
):
model
=
Actu
form_class
=
ActuForm
template_name
=
'
normal_form.html
'
template_name
=
"
normal_form.html
"
def
form_valid
(
self
,
form
):
form
.
instance
.
created_by
=
self
.
request
.
user
...
...
@@ -31,9 +32,11 @@ class ActuCreate(BlogCreateAuthMixin, CreateView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
ActuCreate
,
self
).
get_context_data
(
**
kwargs
)
context
[
'icon'
]
=
'fi-align-left'
context
[
'title'
]
=
_
(
'Ajout d
\'
une actualité'
)
context
[
'js'
]
=
"""
context
[
"icon"
]
=
"fi-align-left"
context
[
"title"
]
=
_
(
"Ajout d'une actualité"
)
context
[
"js"
]
=
"""
"""
return
context
...
...
@@ -41,7 +44,7 @@ class ActuCreate(BlogCreateAuthMixin, CreateView):
class
ActuUpdate
(
BlogModifyAuthMixin
,
UpdateView
):
model
=
Actu
form_class
=
ActuForm
template_name
=
'
normal_form.html
'
template_name
=
"
normal_form.html
"
def
form_valid
(
self
,
form
):
form
.
instance
.
created_by
=
self
.
request
.
user
...
...
@@ -49,57 +52,64 @@ class ActuUpdate(BlogModifyAuthMixin, UpdateView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
ActuUpdate
,
self
).
get_context_data
(
**
kwargs
)
context
[
'icon'
]
=
'fi-align-left'
context
[
'title'
]
=
_
(
'Modification d
\'
une actualité'
)
context
[
'js'
]
=
"""
context
[
"icon"
]
=
"fi-align-left"
context
[
"title"
]
=
_
(
"Modification d'une actualité"
)
context
[
"js"
]
=
"""
"""
return
context
class
ActuDelete
(
BlogModifyAuthMixin
,
DeleteView
):
model
=
Actu
template_name
=
'
confirm_delete.html
'
success_url
=
reverse_lazy
(
'
blog:home
'
)
template_name
=
"
confirm_delete.html
"
success_url
=
reverse_lazy
(
"
blog:home
"
)
def
get_context_data
(
self
,
**
kwargs
):
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
[
"icon"
]
=
"fi-trash"
context
[
"title"
]
=
_
(
"Suppression d'une actualité"
)
context
[
"message_alert"
]
=
_
(
"Êtes-vous certain de vouloir supprimer l'actualité"
)
return
context
class
ActuDetail
(
DetailView
):
model
=
Actu
template_name
=
'
actu_detail.html
'
template_name
=
"
actu_detail.html
"
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
ActuDetail
,
self
).
get_context_data
(
**
kwargs
)
context
[
'icon'
]
=
'fi-align-left'
context
[
'js'
]
=
"""
context
[
"icon"
]
=
"fi-align-left"
context
[
"js"
]
=
"""
"""
return
context
class
ActuList
(
ListView
):
model
=
Actu
template_name
=
'
actu_list.html
'
ordering
=
'
-timestamp_update
'
template_name
=
"
actu_list.html
"
ordering
=
"
-timestamp_update
"
paginate_by
=
3
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
ActuList
,
self
).
get_context_data
(
**
kwargs
)
context
[
'icon'
]
=
'fas fa-info-circle'
context
[
'title'
]
=
_
(
'Dernières actualités'
)
context
[
'sightingsicon'
]
=
'fi-eye'
context
[
'sightingscount'
]
=
Sighting
.
objects
.
all
().
count
()
context
[
'sightingstext'
]
=
_
(
'observations'
)
context
[
'placesicon'
]
=
'fi-marker'
context
[
'placescount'
]
=
Place
.
objects
.
all
().
count
()
context
[
'placestext'
]
=
_
(
'localités'
)
context
[
'sessionsicon'
]
=
'far fa-calendar-alt'
context
[
'sessionscount'
]
=
Session
.
objects
.
all
().
count
()
context
[
'sessionstext'
]
=
_
(
'sessions'
)
context
[
'observersicon'
]
=
'fi-torsos-all-female'
context
[
'observerscount'
]
=
Profile
.
objects
.
all
().
count
()
context
[
'observerstext'
]
=
_
(
'observateurs'
)
return
context
\ No newline at end of file
context
[
"icon"
]
=
"fas fa-info-circle"
context
[
"title"
]
=
_
(
"Dernières actualités"
)
context
[
"sightingsicon"
]
=
"fi-eye"
context
[
"sightingscount"
]
=
Sighting
.
objects
.
all
().
count
()
context
[
"sightingstext"
]
=
_
(
"observations"
)
context
[
"placesicon"
]
=
"fi-marker"
context
[
"placescount"
]
=
Place
.
objects
.
all
().
count
()
context
[
"placestext"
]
=
_
(
"localités"
)
context
[
"sessionsicon"
]
=
"far fa-calendar-alt"
context
[
"sessionscount"
]
=
Session
.
objects
.
all
().
count
()
context
[
"sessionstext"
]
=
_
(
"sessions"
)
context
[
"observersicon"
]
=
"fi-torsos-all-female"
context
[
"observerscount"
]
=
Profile
.
objects
.
all
().
count
()
context
[
"observerstext"
]
=
_
(
"observateurs"
)
return
context
core/js.py
View file @
9131586c
...
...
@@ -46,4 +46,4 @@ TimeInput = """
format: 'HH:mm'
});
});
"""
\ No newline at end of file
"""
core/mixins.py
View file @
9131586c
...
...
@@ -2,7 +2,7 @@
Mixins
"""
from
django.contrib.auth.mixins
import
LoginRequiredMixin
,
UserPassesTestMixin
from
django.contrib.auth.mixins
import
LoginRequiredMixin
,
UserPassesTestMixin
class
ManageAccountAuthMixin
:
...
...
@@ -29,8 +29,6 @@ class ManageAccountAuthMixin:
return
redirect
(
"core:view_unauth"
)
class
AdminRequiredMixin
(
LoginRequiredMixin
,
UserPassesTestMixin
):
def
test_func
(
self
):
return
self
.
request
.
user
.
is_superuser
or
self
.
request
.
user
.
is_staff
core/views.py
View file @
9131586c
...
...
@@ -5,15 +5,18 @@ from .mixins import AdminRequiredMixin
from
.functions
import
version
import
os
def
db_datas
():
with
connection
.
cursor
()
as
cursor
:
cursor
.
execute
(
"SELECT pg_size_pretty( pg_database_size( current_database() ) ), version(), postgis_version()"
)
cursor
.
execute
(
"SELECT pg_size_pretty( pg_database_size( current_database() ) ), version(), postgis_version()"
)
row
=
cursor
.
fetchone
()
print
(
row
)
data
=
{}
data
[
'
database_size
'
]
=
row
[
0
]
data
[
'
database_pg_version
'
]
=
row
[
1
]
data
[
'
database_postgis_version
'
]
=
row
[
2
]
data
[
"
database_size
"
]
=
row
[
0
]
data
[
"
database_pg_version
"
]
=
row
[
1
]
data
[
"
database_postgis_version
"
]
=
row
[
2
]
return
data
...
...
@@ -49,4 +52,3 @@ class SystemInformation(AdminRequiredMixin, TemplateView):
sysinfo
=
{
**
server_info
,
**
db_datas
()}
context
[
"sysinfo"
]
=
sysinfo
return
context
dbchiro/settings/helper/context_processors.py
View file @
9131586c
...
...
@@ -5,6 +5,6 @@ from core.functions import version
def
site_info
(
request
):
"""Return SITE NAME to frontend"""
return
{
'
SITE_NAME
'
:
settings
.
SITE_NAME
,
'
VERSION
'
:
version
(),
"
SITE_NAME
"
:
settings
.
SITE_NAME
,
"
VERSION
"
:
version
(),
}
dicts/admin.py
View file @
9131586c
...
...
@@ -14,10 +14,10 @@ class CustomApp(AppConfig):
name
=
"dicts"
def
ready
(
self
):
models
=
apps
.
get_app_config
(
'
dicts
'
).
get_models
()
models
=
apps
.
get_app_config
(
"
dicts
"
).
get_models
()
for
model
in
models
:
admin_class
=
type
(
"AdminClass"
,
(
ListAdminMixin
,
admin
.
ModelAdmin
),
{})
try
:
admin
.
site
.
register
(
model
,
admin_class
)
except
admin
.
sites
.
AlreadyRegistered
as
e
:
pass
\ No newline at end of file
pass
docker-entrypoint-ubuntu.sh
View file @
9131586c
...
...
@@ -145,13 +145,13 @@ username = '$SU_USERNAME';
password = '
$SU_PWD
';
email = '
$SU_EMAIL
';
if Profile.objects.filter(
username=usernam
e).count()==0:
if Profile.objects.filter(
is_superuser=Tru
e).count()==0:
superuser=Profile.objects.create_user(username, email, password);
superuser.is_superuser=True;
superuser.save();
print('Superuser',username,'created.');
else:
print('
Superuser
creation skipped.')
print('
One or more Superuser already exists,
creation skipped.')
"
printf
"
$script
"
| python3 manage.py shell
...
...
docker-entrypoint.sh
View file @
9131586c
...
...
@@ -101,7 +101,7 @@ if [ ! -d /dbchiro/media ]; then
echo
"Create media dir"
mkdir
/dbchiro/media
else
echo
"Media dir already ex
u
sts"
echo
"Media dir already ex
i
sts"
fi
rm
-rf
/app/media
...
...
@@ -145,13 +145,13 @@ username = '$SU_USERNAME';
password = '
$SU_PWD
';
email = '
$SU_EMAIL
';
if Profile.objects.filter(
username=usernam
e).count()==0:
if Profile.objects.filter(
is_superuser=Tru
e).count()==0:
superuser=Profile.objects.create_user(username, email, password);
superuser.is_superuser=True;
superuser.save();
print('Superuser',username,'created.');
else:
print('
Superuser
creation skipped.')
print('
One or more Superuser already exists,
creation skipped.')
"
printf
"
$script
"
| python manage.py shell
...
...
geodata/models.py
View file @
9131586c
...
...
@@ -52,11 +52,14 @@ class Municipality(models.Model):
class
LandCover
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
)
code
=
models
.
ForeignKey
(
LandCoverCLC
,
verbose_name
=
_
(
"Code"
),
blank
=
True
,
null
=
True
,
on_delete
=
models
.
CASCADE
)
LandCoverCLC
,
verbose_name
=
_
(
"Code"
),
blank
=
True
,
null
=
True
,
on_delete
=
models
.
CASCADE
,
)
geom
=
models
.
MultiPolygonField
(
srid
=
settings
.
GEODATA_SRID
,
verbose_name
=
_
(
"Géométries"
),
spatial_index
=
True
,
srid
=
settings
.
GEODATA_SRID
,
verbose_name
=
_
(
"Géométries"
),
spatial_index
=
True
,
)
def
__str__
(
self
):
...
...
@@ -75,4 +78,3 @@ class Elevation(models.Model):
class
Meta
:
verbose_name
=
_
(
"Altitude"
)
management/models.py
View file @
9131586c
...
...
@@ -15,17 +15,13 @@ class CatchAuth(models.Model):
related_name
=
"catchauth"
,
)
date_start
=
models
.
DateField
(
verbose_name
=
_
(
"Date de début d'application"
),
help_text
=
_
(
"format jj/mm/aaaa"
),
verbose_name
=
_
(
"Date de début d'application"
),
help_text
=
_
(
"format jj/mm/aaaa"
),
)
date_end
=
models
.
DateField
(
verbose_name
=
_
(
"Date de fin d'application"
),
help_text
=
_
(
"format jj/mm/aaaa"
),
verbose_name
=
_
(
"Date de fin d'application"
),
help_text
=
_
(
"format jj/mm/aaaa"
),
)
official_reference
=
models
.
CharField
(
max_length
=
255
,
unique
=
True
,
verbose_name
=
_
(
"Référence du texte officiel"
),
max_length
=
255
,
unique
=
True
,
verbose_name
=
_
(
"Référence du texte officiel"
),
)
file
=
models
.
FileField
(
upload_to
=
"catchauth/%Y/"
,
...
...
@@ -42,7 +38,7 @@ class CatchAuth(models.Model):
db_index
=
True
,
editable
=
False
,
related_name
=
"catchauth_creator"
,
on_delete
=
models
.
SET_NULL
on_delete
=
models
.
SET_NULL
,
)
updated_by
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
...
...
@@ -51,7 +47,7 @@ class CatchAuth(models.Model):
db_index
=
True
,
editable
=
False
,
related_name
=
"catchauth_modifier"
,
on_delete
=
models
.
SET_NULL
on_delete
=
models
.
SET_NULL
,
)
def
__str__
(
self
):
...
...
@@ -75,9 +71,7 @@ class Study(models.Model):
max_length
=
255
,
db_index
=
True
,
verbose_name
=
"nom du l'étude"
)
year
=
models
.
CharField
(
max_length
=
10
,
db_index
=
True
,
verbose_name
=
"Année de réalisation l'étude"
,
max_length
=
10
,
db_index
=
True
,
verbose_name
=
"Année de réalisation l'étude"
,
)
project_manager
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
...
...
@@ -86,7 +80,7 @@ class Study(models.Model):
related_name
=
"study"
,
null
=
True
,
blank
=
True
,
on_delete
=
models
.
SET_NULL
on_delete
=
models
.
SET_NULL
,
)
# study_organism = models.ForeignKey(
# 'Organism',
...
...
@@ -111,9 +105,7 @@ class Study(models.Model):
type_espace
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
,
null
=
True
,
verbose_name
=
"Type d'espace"
)
comment
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
"Commentaire"
)
comment
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
"Commentaire"
)
timestamp_create
=
models
.
DateTimeField
(
auto_now_add
=
True
,
editable
=
False
)
timestamp_update
=
models
.
DateTimeField
(
auto_now
=
True
,
editable
=
False
)
created_by
=
models
.
ForeignKey
(
...
...
@@ -123,7 +115,7 @@ class Study(models.Model):
db_index
=
True
,
editable
=
False
,
related_name
=
"study_creator"
,
on_delete
=
models
.
SET_NULL
on_delete
=
models
.
SET_NULL
,
)
updated_by
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
...
...
@@ -132,7 +124,7 @@ class Study(models.Model):
db_index
=
True
,
editable
=
False
,
related_name
=
"study_modifier"
,
on_delete
=
models
.
SET_NULL
on_delete
=
models
.
SET_NULL
,
)
def
__str__
(
self
):
...
...
@@ -170,9 +162,7 @@ class Transmitter(models.Model):
max_length
=
30
,
unique
=
True
,
null
=
True
,
verbose_name
=
"Référence"
)
frequency
=
models
.
FloatField
(
null
=
True
,
verbose_name
=
"Fréquence en MHz"
)
weight
=
models
.
FloatField
(
null
=
True
,
blank
=
True
,
verbose_name
=
"Poids (en grammes)"
)
weight
=
models
.
FloatField
(
null
=
True
,
blank
=
True
,
verbose_name
=
"Poids (en grammes)"
)
autonomy
=
models
.
FloatField
(
null
=
True
,
blank
=
True
,
verbose_name
=
"Autonomie (en jours)"
)
...
...
@@ -185,24 +175,17 @@ class Transmitter(models.Model):
owner
=
models
.
CharField
(
max_length
=
100
,
null
=
True
,
blank
=
True
,
verbose_name
=
"Propriétaire"
)
buying_date
=
models
.
DateField
(
null
=
True
,
blank
=
True
,
verbose_name
=
"Date d'achat"
)
buying_date
=
models
.
DateField
(
null
=
True
,
blank
=
True
,
verbose_name
=
"Date d'achat"
)
last_recond_date
=
models
.
DateField
(
null
=
True
,
blank
=
True
,
verbose_name
=
"Date de dernier reconditionnement"
)
status
=
models
.
CharField
(
max_length
=
50
,
choices
=
TRANSMITTER_STATUS
,
default
=
"ok"
,
verbose_name
=
"Statut"
,
max_length
=
50
,
choices
=
TRANSMITTER_STATUS
,
default
=
"ok"
,
verbose_name
=
"Statut"
,
)
available
=
models
.
BooleanField
(
verbose_name
=
"Disponible pour la saisie"
,
default
=
True
)
comment
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
"Commentaire"
)
comment
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
"Commentaire"
)
timestamp_create
=
models
.
DateTimeField
(
auto_now_add
=
True
,
editable
=
False
)
timestamp_update
=
models
.
DateTimeField
(
auto_now
=
True
,
editable
=
False
)
created_by
=
models
.
ForeignKey
(
...
...
@@ -212,7 +195,7 @@ class Transmitter(models.Model):
db_index
=
True
,
editable
=
False
,
related_name
=
"transmitter_creator"
,
on_delete
=
models
.
SET_NULL
on_delete
=
models
.
SET_NULL
,
)
updated_by
=
models
.
ForeignKey
(
settings
.
AUTH_USER_MODEL
,
...
...
@@ -221,7 +204,7 @@ class Transmitter(models.Model):
db_index
=
True
,
editable
=
False
,
related_name
=
"transmitter_modifier"
,
on_delete
=
models
.
SET_NULL
on_delete
=
models
.
SET_NULL
,
)
def
__str__
(
self
):
...
...
management/tables.py
View file @
9131586c
...
...
@@ -4,7 +4,7 @@ from .models import Study, Transmitter, CatchAuth
class
StudyTable
(
tables
.
Table
):
ACTIONS
=
'''
ACTIONS
=
"""
<div class="btn-group btn-group-xs">
<button type="button" class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
...
...
@@ -41,21 +41,34 @@ class StudyTable(tables.Table):
</div>
</div>
</div>
'''
actions
=
tables
.
TemplateColumn
(
ACTIONS
,
verbose_name
=
"Actions"
,
orderable
=
False
)
"""
actions
=
tables
.
TemplateColumn
(
ACTIONS
,
verbose_name
=
"Actions"
,
orderable
=
False
)
class
Meta
:
model
=
Study
template
=
'table_bootstrap.html'
attrs
=
{
'class'
:
'table table-striped table-condensed'
}
fields
=
(
'actions'
,
'name'
,
'year'
,
'project_manager'
,
'type_etude'
,
'type_espace'
,
'public_funding'
,
'public_report'
,
'public_raw_data'
,
'confidential'
,
'confidential_end_data'
,
'timestamp_create'
,
'timestamp_update'
,
'created_by'
,
'comment'
)
template
=
"table_bootstrap.html"
attrs
=
{
"class"
:
"table table-striped table-condensed"
}
fields
=
(
"actions"
,
"name"
,
"year"
,
"project_manager"
,
"type_etude"
,
"type_espace"
,
"public_funding"
,
"public_report"
,
"public_raw_data"
,
"confidential"
,
"confidential_end_data"
,
"timestamp_create"
,