Tweak Collections Label
This commit is contained in:
parent
e361ba26e2
commit
f630cd9e11
3 changed files with 27 additions and 7 deletions
|
@ -76,10 +76,9 @@ class Collection(models.Model):
|
||||||
display_name = models.CharField(max_length=255, editable=False)
|
display_name = models.CharField(max_length=255, editable=False)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
self.display_name = "{} {} {} {} {} {}".format(self.project,
|
self.display_name = "{}_{}_{}_{}".format(self.project,
|
||||||
self.study_location, self.collection_start_date,
|
self.collection_end_date.date(), self.study_location,
|
||||||
self.collection_end_date, self.collection_type,
|
self.collection_type)
|
||||||
self.collection_method)
|
|
||||||
super(Collection, self).save(*args, **kwargs)
|
super(Collection, self).save(*args, **kwargs)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
@ -88,6 +87,7 @@ class Collection(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ('project', 'study_location', 'collection_type',
|
unique_together = ('project', 'study_location', 'collection_type',
|
||||||
'collection_start_date', 'collection_end_date', 'collection_method')
|
'collection_start_date', 'collection_end_date', 'collection_method')
|
||||||
|
ordering = ['project', 'collection_end_date']
|
||||||
|
|
||||||
|
|
||||||
class DatasheetAttachment(models.Model):
|
class DatasheetAttachment(models.Model):
|
||||||
|
@ -105,7 +105,8 @@ class CollectionTrap(models.Model):
|
||||||
time_closed = models.TimeField()
|
time_closed = models.TimeField()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{collection} {number_of_traps} {date_opened} {date_closed}".format(self)
|
return "{} # Traps: {} {} {}".format(
|
||||||
|
self.collection, self.number_of_traps, self.date_opened, self.date_closed)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ('collection', 'date_opened', 'time_opened', 'date_closed', 'time_closed')
|
unique_together = ('collection', 'date_opened', 'time_opened', 'date_closed', 'time_closed')
|
||||||
|
|
19
ccdb/locations/migrations/0003_study_location_code_req.py
Normal file
19
ccdb/locations/migrations/0003_study_location_code_req.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('locations', '0002_remove_site_fk_dupes'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='studylocation',
|
||||||
|
name='code',
|
||||||
|
field=models.CharField(max_length=10),
|
||||||
|
),
|
||||||
|
]
|
|
@ -50,7 +50,7 @@ class MunicipalLocation(models.Model):
|
||||||
class StudyLocation(models.Model):
|
class StudyLocation(models.Model):
|
||||||
site = models.ForeignKey(Site)
|
site = models.ForeignKey(Site)
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
code = models.CharField(max_length=10, blank=True)
|
code = models.CharField(max_length=10)
|
||||||
study_location_type = models.CharField(max_length=50, blank=True)
|
study_location_type = models.CharField(max_length=50, blank=True)
|
||||||
treatment_type = models.CharField(max_length=100, blank=True)
|
treatment_type = models.CharField(max_length=100, blank=True)
|
||||||
municipal_location = models.ForeignKey(MunicipalLocation,
|
municipal_location = models.ForeignKey(MunicipalLocation,
|
||||||
|
@ -61,7 +61,7 @@ class StudyLocation(models.Model):
|
||||||
slug = AutoSlugField(populate_from='name')
|
slug = AutoSlugField(populate_from='name')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.code
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ('site', 'name')
|
unique_together = ('site', 'name')
|
||||||
|
|
Loading…
Add table
Reference in a new issue