Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Belgian Biodiversity Platform
astapor
Commits
f9262906
Commit
f9262906
authored
Jun 16, 2017
by
Nicolas Noé
Browse files
Better depth display in Admin.
parent
d2c24a3a
Changes
3
Hide whitespace changes
Inline
Side-by-side
website/specimens/admin.py
View file @
f9262906
...
...
@@ -19,7 +19,7 @@ class MyAdminForm(forms.ModelForm):
class
SpecimenAdmin
(
admin
.
ModelAdmin
):
form
=
MyAdminForm
list_display
=
(
'specimen_id'
,
'scientific_name'
,
'identified_by'
,
'specimen_location'
,
'depth'
,
'fixation'
)
list_display
=
(
'specimen_id'
,
'scientific_name'
,
'identified_by'
,
'specimen_location'
,
'depth
_str
'
,
'fixation'
)
list_filter
=
(
'identified_by'
,
'specimen_location'
,
'fixation'
)
search_fields
=
[
'scientific_name'
]
...
...
website/specimens/management/commands/csv_import.py
View file @
f9262906
...
...
@@ -14,6 +14,7 @@ MODELS_TO_TRUNCATE = [Fixation, Person, SpecimenLocation, Specimen]
# - Column name is important, not column order
# - Lat/lon use comma as a separator
class
Command
(
BaseCommand
):
help
=
'Initial data import to populate the tables'
...
...
website/specimens/models.py
View file @
f9262906
...
...
@@ -34,4 +34,16 @@ class Specimen(models.Model):
fixation
=
models
.
ForeignKey
(
Fixation
,
blank
=
True
,
null
=
True
)
comment
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
def
depth_str
(
self
):
if
self
.
depth
:
if
self
.
depth
.
lower
==
self
.
depth
.
upper
:
# Single value
str
=
"{depth}m."
.
format
(
depth
=
self
.
depth
.
lower
)
else
:
# Real range
str
=
'{min_depth}-{max_depth}m.'
.
format
(
min_depth
=
self
.
depth
.
lower
,
max_depth
=
self
.
depth
.
upper
)
else
:
# No data
str
=
'-'
return
str
depth_str
.
short_description
=
'Depth'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment