Fixing storage location code
This commit is contained in:
parent
e5a3edb75e
commit
e397e96dab
4 changed files with 17 additions and 17 deletions
ccdb
|
@ -68,17 +68,16 @@ class StudyLocationAdmin(admin.ModelAdmin):
|
|||
|
||||
|
||||
class StorageLocationAdmin(admin.ModelAdmin):
|
||||
list_display = ('__str__', 'facility', 'building', 'room', 'freezer', 'temp_c',
|
||||
list_display = ('code', 'facility', 'building', 'room', 'freezer', 'temp_c',
|
||||
'description', 'sort_order')
|
||||
list_display_links = ('__str__',)
|
||||
search_fields = ('facility', 'building', 'room', 'freezer', 'temp_c',
|
||||
'description')
|
||||
list_display_links = ('code',)
|
||||
search_fields = ('code', 'facility', 'building', 'room', 'freezer',
|
||||
'temp_c', 'description')
|
||||
list_per_page = 25
|
||||
fields = ('facility', 'building', 'room', 'freezer', 'temp_c',
|
||||
fields = ('code', 'facility', 'building', 'room', 'freezer', 'temp_c',
|
||||
'description', 'sort_order')
|
||||
|
||||
|
||||
|
||||
admin.site.register(Region, RegionAdmin)
|
||||
admin.site.register(Site, SiteAdmin)
|
||||
admin.site.register(MunicipalLocation, MunicipalLocationAdmin)
|
||||
|
|
|
@ -60,6 +60,7 @@ class Migration(migrations.Migration):
|
|||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('facility', models.CharField(max_length=100)),
|
||||
('building', models.CharField(max_length=100)),
|
||||
('code', models.CharField(max_length=100)),
|
||||
('room', models.CharField(max_length=50, blank=True)),
|
||||
('freezer', models.CharField(max_length=50, blank=True)),
|
||||
('temp_c', models.IntegerField(null=True, blank=True)),
|
||||
|
|
|
@ -70,6 +70,7 @@ class StudyLocation(models.Model):
|
|||
|
||||
|
||||
class StorageLocation(models.Model):
|
||||
code = models.CharField(max_length=100)
|
||||
facility = models.CharField(max_length=100)
|
||||
building = models.CharField(max_length=100)
|
||||
room = models.CharField(max_length=50, blank=True)
|
||||
|
@ -79,16 +80,7 @@ class StorageLocation(models.Model):
|
|||
sort_order = models.IntegerField(blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
bldg = "".join(e[0].upper() for e in self.building.split())
|
||||
temp_c = '20'
|
||||
if self.temp_c:
|
||||
temp_c = self.temp_c
|
||||
|
||||
freezer = 'No Freezer'
|
||||
if self.freezer:
|
||||
freezer = self.freezer
|
||||
|
||||
return " ".join([bldg, str(temp_c)+'C', str(freezer)])
|
||||
return self.code
|
||||
|
||||
class Meta:
|
||||
ordering = ['sort_order']
|
||||
|
|
|
@ -139,7 +139,15 @@ def _import_data():
|
|||
|
||||
# Storage Location
|
||||
for r in c.execute('SELECT * FROM tbl_lu_storage_locations;'):
|
||||
bldg = "".join(e[0].upper() for e in r[2].split())
|
||||
temp_c = '20'
|
||||
if r[5]:
|
||||
temp_c = r[5]
|
||||
freezer = 'No Freezer'
|
||||
if r[4]:
|
||||
freezer = r[4]
|
||||
code = " ".join([bldg, str(temp_c)+'C', str(freezer)])
|
||||
sl = StorageLocation(id=r[0], facility=r[1], building=r[2],
|
||||
room=r[3], freezer=r[4], temp_c=r[5],
|
||||
room=r[3], freezer=r[4], temp_c=r[5], code=code,
|
||||
description=r[6], sort_order=r[7])
|
||||
sl.save()
|
||||
|
|
Loading…
Add table
Reference in a new issue