Set up admin for project-level items
This commit is contained in:
parent
510568d53b
commit
db8d52ef68
3 changed files with 47 additions and 22 deletions
|
@ -1,7 +1,8 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from .models import CollectionType, CollectionMethod, Flaw, ADFGPermit, \
|
from .models import (CollectionType, CollectionMethod, Flaw, ADFGPermit,
|
||||||
DatasheetAttachment, CollectionTrap
|
DatasheetAttachment, CollectionTrap, Collection)
|
||||||
|
from ..species.models import CollectionSpecies
|
||||||
|
|
||||||
|
|
||||||
class CollectionTypeAdmin(admin.ModelAdmin):
|
class CollectionTypeAdmin(admin.ModelAdmin):
|
||||||
|
@ -52,9 +53,24 @@ class CollectionTrapAdmin(admin.ModelAdmin):
|
||||||
'time_opened', 'date_closed', 'time_closed')
|
'time_opened', 'date_closed', 'time_closed')
|
||||||
|
|
||||||
|
|
||||||
|
class CollectionSpeciesInlineAdmin(admin.TabularInline):
|
||||||
|
model = CollectionSpecies
|
||||||
|
|
||||||
|
|
||||||
|
class CollectionAdmin(admin.ModelAdmin):
|
||||||
|
inlines = (CollectionSpeciesInlineAdmin, )
|
||||||
|
list_display = ('project', 'study_location', 'collection_end_date',
|
||||||
|
'collection_type', 'collection_method')
|
||||||
|
list_display_links = ('project', 'study_location', 'collection_end_date',
|
||||||
|
'collection_type', 'collection_method')
|
||||||
|
list_filter = ('project', 'study_location', 'collection_type',
|
||||||
|
'collection_method')
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(CollectionType, CollectionTypeAdmin)
|
admin.site.register(CollectionType, CollectionTypeAdmin)
|
||||||
admin.site.register(CollectionMethod, CollectionMethodAdmin)
|
admin.site.register(CollectionMethod, CollectionMethodAdmin)
|
||||||
admin.site.register(Flaw, FlawAdmin)
|
admin.site.register(Flaw, FlawAdmin)
|
||||||
admin.site.register(ADFGPermit, ADFGPermitAdmin)
|
admin.site.register(ADFGPermit, ADFGPermitAdmin)
|
||||||
admin.site.register(DatasheetAttachment, DatasheetAttachmentAdmin)
|
admin.site.register(DatasheetAttachment, DatasheetAttachmentAdmin)
|
||||||
admin.site.register(CollectionTrap, CollectionTrapAdmin)
|
admin.site.register(CollectionTrap, CollectionTrapAdmin)
|
||||||
|
admin.site.register(Collection, CollectionAdmin)
|
||||||
|
|
|
@ -56,15 +56,18 @@ class Collection(models.Model):
|
||||||
project = models.ForeignKey('projects.Project', related_name='collections')
|
project = models.ForeignKey('projects.Project', related_name='collections')
|
||||||
study_location = models.ForeignKey('locations.StudyLocation',
|
study_location = models.ForeignKey('locations.StudyLocation',
|
||||||
related_name='collections')
|
related_name='collections')
|
||||||
collection_type = models.ForeignKey(CollectionType, related_name='collections')
|
collection_type = models.ForeignKey(CollectionType,
|
||||||
collection_method = models.ForeignKey(CollectionMethod, related_name='collections')
|
related_name='collections')
|
||||||
|
collection_method = models.ForeignKey(CollectionMethod,
|
||||||
|
related_name='collections')
|
||||||
number_of_traps = models.IntegerField(blank=True, null=True)
|
number_of_traps = models.IntegerField(blank=True, null=True)
|
||||||
collection_start_date = models.DateField(blank=True, null=True)
|
collection_start_date = models.DateField(blank=True, null=True)
|
||||||
collection_start_time = models.TimeField(blank=True, null=True)
|
collection_start_time = models.TimeField(blank=True, null=True)
|
||||||
collection_end_date = models.DateField(blank=True, null=True)
|
collection_end_date = models.DateField(blank=True, null=True)
|
||||||
collection_end_time = models.TimeField(blank=True, null=True)
|
collection_end_time = models.TimeField(blank=True, null=True)
|
||||||
storage_location = models.ForeignKey('locations.StorageLocation', blank=True,
|
storage_location = models.ForeignKey('locations.StorageLocation',
|
||||||
null=True, related_name='collections')
|
blank=True, null=True,
|
||||||
|
related_name='collections')
|
||||||
specimen_state = models.CharField(max_length=50, blank=True)
|
specimen_state = models.CharField(max_length=50, blank=True)
|
||||||
process_type = models.ForeignKey('processing.ProcessType', blank=True,
|
process_type = models.ForeignKey('processing.ProcessType', blank=True,
|
||||||
null=True, related_name='collections')
|
null=True, related_name='collections')
|
||||||
|
@ -72,12 +75,14 @@ class Collection(models.Model):
|
||||||
related_name='collections')
|
related_name='collections')
|
||||||
adfg_permit = models.ForeignKey(ADFGPermit, blank=True, null=True,
|
adfg_permit = models.ForeignKey(ADFGPermit, blank=True, null=True,
|
||||||
related_name='collections')
|
related_name='collections')
|
||||||
flaw = models.ForeignKey(Flaw, blank=True, null=True, related_name='collections')
|
flaw = models.ForeignKey(Flaw, blank=True, null=True,
|
||||||
|
related_name='collections')
|
||||||
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.collection_end_date, self.study_location,
|
self.collection_end_date,
|
||||||
|
self.study_location,
|
||||||
self.collection_type)
|
self.collection_type)
|
||||||
super(Collection, self).save(*args, **kwargs)
|
super(Collection, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
@ -86,7 +91,8 @@ 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']
|
ordering = ['project', 'collection_end_date']
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,8 +111,10 @@ class CollectionTrap(models.Model):
|
||||||
time_closed = models.TimeField()
|
time_closed = models.TimeField()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{} # Traps: {} {} {}".format(
|
return "{} # Traps: {} {} {}".format(self.collection,
|
||||||
self.collection, self.number_of_traps, self.date_opened, self.date_closed)
|
self.number_of_traps,
|
||||||
|
self.date_opened,
|
||||||
|
self.date_closed)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ('collection', 'date_opened', 'time_opened',
|
unique_together = ('collection', 'date_opened', 'time_opened',
|
||||||
|
|
|
@ -9,7 +9,8 @@ class ProjectGrantInline(admin.TabularInline):
|
||||||
|
|
||||||
|
|
||||||
class ProjectAdmin(admin.ModelAdmin):
|
class ProjectAdmin(admin.ModelAdmin):
|
||||||
list_display = ('name', 'code', 'iacuc_number', 'description', 'sort_order')
|
list_display = ('name', 'code', 'iacuc_number', 'description',
|
||||||
|
'sort_order')
|
||||||
list_display_links = ('name',)
|
list_display_links = ('name',)
|
||||||
search_fields = ('name', 'code', 'iacuc_number', 'description')
|
search_fields = ('name', 'code', 'iacuc_number', 'description')
|
||||||
list_per_page = 25
|
list_per_page = 25
|
||||||
|
@ -27,13 +28,13 @@ class GrantAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
|
|
||||||
class GrantReportAdmin(admin.ModelAdmin):
|
class GrantReportAdmin(admin.ModelAdmin):
|
||||||
list_display = ('grant_title', 'title', 'report_type', 'description', 'due_date',
|
list_display = ('grant_title', 'title', 'report_type', 'description',
|
||||||
'submitted_date', 'attachment', 'sort_order')
|
'due_date', 'submitted_date', 'attachment', 'sort_order')
|
||||||
list_display_links = ('title',)
|
list_display_links = ('title',)
|
||||||
search_fields = ('grant__title', 'title', 'report_type', 'description', 'due_date',
|
search_fields = ('grant__title', 'title', 'report_type', 'description',
|
||||||
'submitted_date', 'attachment')
|
'due_date', 'submitted_date', 'attachment')
|
||||||
list_per_page = 25
|
list_per_page = 25
|
||||||
fields = ('title', 'report_type', 'description', 'due_date',
|
fields = ('grant', 'title', 'report_type', 'description', 'due_date',
|
||||||
'submitted_date', 'attachment', 'sort_order')
|
'submitted_date', 'attachment', 'sort_order')
|
||||||
|
|
||||||
def grant_title(self, obj):
|
def grant_title(self, obj):
|
||||||
|
|
Loading…
Add table
Reference in a new issue