Commit f9262906 authored by Nicolas Noé's avatar Nicolas Noé
Browse files

Better depth display in Admin.

parent d2c24a3a
......@@ -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']
......
......@@ -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'
......
......@@ -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'
Markdown is supported
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