Resource: Show inline dependent data

This commit is contained in:
PCoder 2021-11-28 18:50:51 +05:30
parent 5568764933
commit a6c7c9e2e7
3 changed files with 60 additions and 27 deletions

View file

@ -62,7 +62,24 @@ class PersonAdmin(admin.ModelAdmin):
list_display_links = ['id'] list_display_links = ['id']
class ResourceKeywordInline(admin.TabularInline):
model = ResourceKeyword
class ResourceRangeInline(admin.TabularInline):
model = ResourceRange
class ResourcePeopleInline(admin.TabularInline):
model = ResourcesPeople
class ResourceAdmin(admin.ModelAdmin): class ResourceAdmin(admin.ModelAdmin):
inlines = [
ResourceKeywordInline,
ResourceRangeInline,
ResourcePeopleInline
]
search_fields = ['title', 'url', 'citation', 'abstract'] search_fields = ['title', 'url', 'citation', 'abstract']
readonly_fields = ['id'] readonly_fields = ['id']
list_display = ['title', 'citation', 'type'] list_display = ['title', 'citation', 'type']
@ -77,16 +94,15 @@ class ResourceAdmin(admin.ModelAdmin):
('lat', 'lon'), ('lat', 'lon'),
'doi', 'doi',
'wiki_data_id', 'wiki_data_id',
'inventory',
'abstract'
) )
}), }),
('Boolean fields', { ('Research network', {
'classes': ('collapse',), 'classes': ('collapse',),
'fields': (('gloria', 'gnomo', 'lter', 'ltser', 'miren', 'team', 'inventory'),), 'fields': (('gloria', 'gnomo', 'lter', 'ltser', 'miren', 'team'),),
}),
('Keywords', {
'classes': ('collapse',),
'fields': (),
}), }),
('PEGASuS', { ('PEGASuS', {
'classes': ('collapse',), 'classes': ('collapse',),
'fields': ( 'fields': (

View file

@ -0,0 +1,18 @@
# Generated by Django 3.2.5 on 2021-11-28 13:20
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0039_auto_20211128_0811'),
]
operations = [
migrations.AlterField(
model_name='resource',
name='type',
field=models.TextField(blank=True, choices=[('', 'Atlas'), ('Book', 'Book'), ('Book chapter', 'Book chapter'), ('Case study', 'Case study'), ('Conservation project', 'Conservation project'), ('Dataset', 'Dataset'), ('Development project', 'Development project'), ('Journal article', 'Journal article'), ('LTER', 'LTER'), ('Map', 'Map'), ('Network', 'Network'), ('PEGASuS', 'PEGASuS'), ('Presentation', 'Presentation'), ('Report', 'Report'), ('Research project', 'Research project'), ('Research Site', 'Research Site'), ('Thesis', 'Thesis'), ('Video', 'Video'), ('Website', 'Website'), ('Working Group', 'Working Group')], null=True),
),
]

View file

@ -162,27 +162,26 @@ class Resource(models.Model):
("*****", "*****"), ("*****", "*****"),
) )
TYPE_CHOICES = ( TYPE_CHOICES = (
("" ,"" ), ("", "Atlas"),
("Atlas" ,"Atlas" ), ("Book", "Book"),
("Book" ,"Book" ), ("Book chapter", "Book chapter"),
("Book chapter" ,"Book chapter" ), ("Case study", "Case study"),
("Case study" ,"Case study" ), ("Conservation project", "Conservation project"),
("Conservation project","Conservation project"), ("Dataset", "Dataset"),
("Dataset" ,"Dataset" ), ("Development project", "Development project"),
("Development project" ,"Development project" ), ("Journal article", "Journal article"),
("Journal article" ,"Journal article" ), ("LTER", "LTER"),
("LTER" ,"LTER" ), ("Map", "Map"),
("Map" ,"Map" ), ("Network", "Network"),
("Network" ,"Network" ), ("PEGASuS", "PEGASuS"),
("PEGASuS" ,"PEGASuS" ), ("Presentation", "Presentation"),
("Presentation" ,"Presentation" ), ("Report", "Report"),
("Report" ,"Report" ), ("Research project", "Research project"),
("Research project" ,"Research project" ), ("Research Site", "Research Site"),
("Research Site" ,"Research Site" ), ("Thesis", "Thesis"),
("Thesis" ,"Thesis" ), ("Video", "Video"),
("Video" ,"Video" ), ("Website", "Website"),
("Website" ,"Website" ), ("Working Group", "Working Group"),
("Working Group" ,"Working Group" ),
) )
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)