404 lines
12 KiB
Python
404 lines
12 KiB
Python
from django.contrib import admin
|
|
from django.utils.html import format_html
|
|
from .models import *
|
|
from django.forms import TextInput
|
|
|
|
|
|
class PeopleResourceInline(admin.TabularInline):
|
|
model = PeopleResource
|
|
|
|
|
|
class PeopleRangeInline(admin.TabularInline):
|
|
model = PeopleRange
|
|
|
|
|
|
class PersonAdmin(admin.ModelAdmin):
|
|
inlines = [
|
|
PeopleResourceInline,
|
|
PeopleRangeInline
|
|
]
|
|
readonly_fields = ['id']
|
|
search_fields = ['title', 'first_name', 'last_name', 'organisation', 'position', 'country__short_name', 'contact_email']
|
|
fieldsets = (
|
|
(None, {
|
|
'fields': (
|
|
('id'),
|
|
('mr_mrs', 'title','full_name', 'position'),
|
|
('first_name', 'last_name', 'search_name', 'status'),
|
|
('contact_email', 'email_2', 'skype', 'professional_phone'),
|
|
'organization',
|
|
'personal_url',
|
|
'biography',
|
|
'field_of_expertise',
|
|
'geographic_area_of_expertise')
|
|
}),
|
|
('Research Scale', {
|
|
'classes': ('collapse',),
|
|
'fields': (('field_site', 'transect', 'mountain_top', 'mountain_range', 'landscape', 'regional', 'national',),
|
|
'_global'),
|
|
}),
|
|
('Methods and tools', {
|
|
'classes': ('collapse',),
|
|
'fields': (('biological_field_sampling', 'data_mining', 'remote_sensing',
|
|
'gis', 'spatial_analysis', 'statistical_analysis', 'modelling'),
|
|
('assessment', 'meta_analysis', 'synthesis', 'qualitative_ssm', 'genetic_analyses'))
|
|
}),
|
|
('Taxonomic groups', {
|
|
'classes': ('collapse',),
|
|
'fields': (('birds', 'mammals', 'reptiles', 'amphibians', 'fish', 'insects', 'molluscs', 'crustaceans',
|
|
'arachnids'), ('angiosperms', 'gymnosperms', 'fungi', 'algae', 'microbes')),
|
|
}),
|
|
('Others', {
|
|
'classes': ('collapse',),
|
|
'fields': ('orcid', 'web_of_science', 'twitter', 'instagram', 'updated',
|
|
('news_letter', 'profile_on_web'),
|
|
'entry_date',
|
|
'country',
|
|
'gmba_function'
|
|
),
|
|
}),
|
|
)
|
|
list_display = ['id', 'full_name', 'country', 'organization']
|
|
list_editable = ['full_name', 'country', 'organization']
|
|
list_display_links = ['id']
|
|
|
|
|
|
class ResourceKeywordInline(admin.TabularInline):
|
|
model = ResourceKeyword
|
|
|
|
|
|
class ResourceRangeInline(admin.TabularInline):
|
|
model = ResourceRange
|
|
|
|
|
|
class ResourcePeopleInline(admin.TabularInline):
|
|
model = PeopleResource
|
|
formfield_overrides = {
|
|
models.CharField: {'widget': TextInput(attrs={'size': '20'})}
|
|
}
|
|
|
|
|
|
class ResourceAdmin(admin.ModelAdmin):
|
|
inlines = [
|
|
ResourceKeywordInline,
|
|
ResourceRangeInline,
|
|
ResourcePeopleInline
|
|
]
|
|
search_fields = ['title', 'url', 'citation', 'abstract']
|
|
readonly_fields = ['id']
|
|
list_display = ['title', 'citation', 'type']
|
|
fieldsets = (
|
|
(None, {
|
|
'fields': (
|
|
('id', 'stars'),
|
|
'title',
|
|
'citation',
|
|
('type',),
|
|
('url',),
|
|
('lat', 'lon'),
|
|
'doi',
|
|
'wiki_data_id',
|
|
'inventory',
|
|
'abstract',
|
|
'author_keywords'
|
|
)
|
|
}),
|
|
('Research network', {
|
|
'classes': ('collapse',),
|
|
'fields': (('gloria', 'gnomo', 'lter', 'ltser', 'miren', 'team'),),
|
|
}),
|
|
|
|
('PEGASuS', {
|
|
'classes': ('collapse',),
|
|
'fields': (
|
|
('PEGASuS_polygon_ID', 'PEGASuS_Polygon_comments', 'PEGASuS_Assessment_ID',
|
|
'PEGASuS_Check_map_with_author',),)
|
|
}),
|
|
)
|
|
|
|
|
|
class RangeNameTranslationInline(admin.TabularInline):
|
|
model = RangeNameTranslation
|
|
|
|
|
|
class RangeCountryInline(admin.TabularInline):
|
|
model = RangeCountry
|
|
|
|
|
|
class RangeAdmin(admin.ModelAdmin):
|
|
inlines = [
|
|
RangeNameTranslationInline,
|
|
RangeCountryInline
|
|
]
|
|
readonly_fields = ('id',)
|
|
search_fields = ['name', 'range_name', 'range_name_ascii',
|
|
'level', 'level', 'level_1', 'level_2', 'level_3', 'peak_name', 'comments', 'source',
|
|
'name_fr', 'name_de', 'name_es', 'name_pt', 'name_cn', 'name_ru', 'name_tr']
|
|
fieldsets = (
|
|
(None, {
|
|
'fields': (
|
|
('gmba_v2_id', 'range_name', 'range_name_language', 'map_unit'),
|
|
('range_name_map', 'select_300', 'checked'),
|
|
('range_name_ascii', 'GMBA_v1_id'),
|
|
('latitude', 'longitude'),
|
|
('mother_range', 'wiki_data_id', 'area'),
|
|
('feature', 'range_alternate_id', 'gmba_narrow'),
|
|
'source',
|
|
'id',
|
|
)
|
|
}),
|
|
('Range Name Translation', {
|
|
'classes': ('collapse',),
|
|
'fields': (
|
|
('name_fr', 'name_de', 'name_es', 'name_pt'),
|
|
('name_ru', 'name_tr', 'name_cn')
|
|
)
|
|
}),
|
|
('Range Countries', {
|
|
'classes': ('collapse',),
|
|
'fields': ('countries',),
|
|
}),
|
|
('Comments', {
|
|
'classes': ('collapse',),
|
|
'fields': ('comments',),
|
|
})
|
|
)
|
|
list_display = ['range_name', 'countries', 'mother_range']
|
|
|
|
|
|
class PeopleOrganizationInline(admin.TabularInline):
|
|
model = Person
|
|
exclude = ['source_id', 'organisation', 'field_indexer']
|
|
fields = ('title', 'full_name', 'contact_email', 'position')
|
|
|
|
|
|
class OrganizationAdmin(admin.ModelAdmin):
|
|
inlines = [
|
|
PeopleOrganizationInline,
|
|
]
|
|
readonly_fields = ('org_num1',)
|
|
search_fields = ['organisation_search', 'org_alpha_search', 'organisation_2', 'organisation_3', 'subject']
|
|
list_display = ['organisation_english', 'country', 'city']
|
|
fieldsets = (
|
|
(None, {
|
|
'fields': (
|
|
'org_num1',
|
|
('acronym', 'category', 'subject'),
|
|
'organisation_english',
|
|
('organisation_2', 'organisation_3'),
|
|
'organisation_original',
|
|
)
|
|
}),
|
|
('Address', {
|
|
'classes': ('collapse',),
|
|
'fields': (
|
|
('street', 'postcode', 'city'),
|
|
('po_box', 'country', 'lat_long'),
|
|
)
|
|
}),
|
|
('Other details', {
|
|
'classes': ('collapse',),
|
|
'fields': (('tel', 'email'),
|
|
'url',
|
|
'tags',
|
|
),
|
|
})
|
|
)
|
|
|
|
def org_url(self, instance):
|
|
return format_html('<a href="{0}" target="_blank">{1}</a>',
|
|
str(instance.url).strip("#"),
|
|
str(instance.url).strip("#"))
|
|
|
|
|
|
class FieldAdmin(admin.ModelAdmin):
|
|
search_fields = ['name']
|
|
|
|
|
|
class CountriesAdmin(admin.ModelAdmin):
|
|
search_fields = ['short_name', 'formal_name', 'membership_within_un_system', 'continent', 'eu_ms', 'eea_ms', 'iso3',
|
|
'iso2']
|
|
|
|
|
|
class GMBA_SpeciesGroupAdmin(admin.ModelAdmin):
|
|
search_fields = ['species_group']
|
|
|
|
|
|
class LanguageAdmin(admin.ModelAdmin):
|
|
search_fields = ['language']
|
|
|
|
|
|
class PeopleStatusAdmin(admin.ModelAdmin):
|
|
search_fields = ['status']
|
|
|
|
|
|
class RangeTypeAdmin(admin.ModelAdmin):
|
|
search_fields = ['range_type']
|
|
|
|
|
|
class RedListCategoryAdmin(admin.ModelAdmin):
|
|
search_fields = ['red_list_category']
|
|
|
|
|
|
class SourceAdmin(admin.ModelAdmin):
|
|
search_fields = ['source']
|
|
|
|
|
|
class TaxonStatusAdmin(admin.ModelAdmin):
|
|
search_fields = ['taxon_status']
|
|
|
|
|
|
class TaxonUnitAdmin(admin.ModelAdmin):
|
|
search_fields = ['taxon_status']
|
|
|
|
|
|
class TrendsQuantityAdmin(admin.ModelAdmin):
|
|
search_fields = ['trend']
|
|
|
|
|
|
class TrendsQualityAdmin(admin.ModelAdmin):
|
|
search_fields = ['trend']
|
|
|
|
|
|
class RepositoryAdmin(admin.ModelAdmin):
|
|
search_fields = ['repository_name', 'repository_url']
|
|
|
|
|
|
class GMBAFunctionAdmin(admin.ModelAdmin):
|
|
search_fields = ['gmba_function']
|
|
|
|
|
|
class RangeOnlineInfoAdmin(admin.ModelAdmin):
|
|
search_fields = ['info_source']
|
|
|
|
|
|
class PeaksAdmin(admin.ModelAdmin):
|
|
search_fields = ['point_name', 'link']
|
|
|
|
|
|
class SearchAdmin(admin.ModelAdmin):
|
|
search_fields = ['search_string', 'search_date', 'result']
|
|
list_display = ['search_string', 'search_date', 'result']
|
|
|
|
def search_string(self, obj):
|
|
return str(obj.search_string) if obj else '--'
|
|
|
|
def search_date(self, obj):
|
|
return str(obj.search_date) if obj else '--'
|
|
|
|
def result(self, obj):
|
|
return str(obj.result) if obj else '--'
|
|
|
|
|
|
class SpeciesAdmin(admin.ModelAdmin):
|
|
search_fields = ['scientific_name', 'class_', 'english_name', 'url']
|
|
|
|
|
|
class TaxonRangeAdmin(admin.ModelAdmin):
|
|
model = TaxonRange
|
|
search_fields = ['range__range_name', 'taxon', 'subrange_or_region', 'distribution', 'source', 'remarks']
|
|
list_display = ['range_name', 'taxon']
|
|
|
|
def range_name(self, obj):
|
|
return str(obj.range.range_name) if obj and obj.range and obj.range.range_name else 'None'
|
|
|
|
def taxon(self, obj):
|
|
return str(obj.taxon) if obj.taxon else 'None'
|
|
|
|
|
|
class RangeNameTranslationAdmin(admin.ModelAdmin):
|
|
model = RangeNameTranslation
|
|
search_fields = ['range__range_name', 'language__language']
|
|
list_display = ['range_name', 'language_translation']
|
|
|
|
def range_name(self, obj):
|
|
return str(obj.range.range_name)
|
|
|
|
def country_name(self, obj):
|
|
return str(obj.language.language) if obj.language else 'None'
|
|
|
|
|
|
class PeopleRangeAdmin(admin.ModelAdmin):
|
|
model = MountainRange
|
|
list_display = ['person', 'range_name', ]
|
|
|
|
def range_name(self, obj):
|
|
return str(obj.range.name)
|
|
|
|
|
|
class PeopleResourceAdmin(admin.ModelAdmin):
|
|
fields = ('person', 'resource', 'p_r_role')
|
|
list_display = ['person', 'resource', 'role']
|
|
search_fields = ['person__full_name', 'resource__title', 'p_r_role__role']
|
|
|
|
|
|
class SpeciesRangeAdmin(admin.ModelAdmin):
|
|
model = SpeciesRange
|
|
search_fields = ['scientific_name__scientific_name', 'range__range_name']
|
|
list_display = ['scientific_name', 'range_name']
|
|
|
|
def scientific_name(self, obj):
|
|
return str(obj.scientific_name.scientific_name) if obj and obj.scientific_name and obj.scientific_name.scientific_name else '--'
|
|
|
|
def range_name(self, obj):
|
|
return str(obj.range) if obj.range else '--'
|
|
|
|
|
|
class RangeCountryAdmin(admin.ModelAdmin):
|
|
model = RangeCountry
|
|
search_fields = ['range__range_name', 'country__short_name']
|
|
list_display = ['range_name', 'country_name']
|
|
|
|
def range_name(self, obj):
|
|
return str(obj.range.range_name)
|
|
|
|
def country_name(self, obj):
|
|
return str(obj.country.short_name) if obj.country else 'None'
|
|
|
|
|
|
# Register your models here.
|
|
admin.site.register(Person, PersonAdmin)
|
|
admin.site.register(Resource, ResourceAdmin)
|
|
admin.site.register(MountainRange, RangeAdmin)
|
|
# admin.site.register(Method)
|
|
# admin.site.register(Scale)
|
|
# admin.site.register(Taxon)
|
|
# admin.site.register(Field, FieldAdmin)
|
|
|
|
|
|
# LU models
|
|
# admin.site.register(Country, CountriesAdmin)
|
|
# admin.site.register(GMBA_SpeciesGroup, GMBA_SpeciesGroupAdmin)
|
|
# admin.site.register(Language, LanguageAdmin)
|
|
# admin.site.register(PeopleStatus, PeopleStatusAdmin)
|
|
# admin.site.register(RangeType, RangeTypeAdmin)
|
|
# admin.site.register(RedListCategory, RedListCategoryAdmin)
|
|
# admin.site.register(Source, SourceAdmin)
|
|
# admin.site.register(TaxonStatus, TaxonStatusAdmin)
|
|
# admin.site.register(TaxonUnit, TaxonUnitAdmin)
|
|
# admin.site.register(TrendsQuality, TrendsQualityAdmin)
|
|
# admin.site.register(TrendsQuantity, TrendsQuantityAdmin)
|
|
|
|
# Others
|
|
# admin.site.register(Repository, RepositoryAdmin)
|
|
# admin.site.register(GMBA_function, GMBAFunctionAdmin)
|
|
admin.site.register(Organisation, OrganizationAdmin)
|
|
# admin.site.register(RangeOnlineInfo, RangeOnlineInfoAdmin)
|
|
|
|
# admin.site.register(RangeNameTranslation, RangeNameTranslationAdmin)
|
|
# admin.site.register(AddElevation)
|
|
# admin.site.register(GMBA_V2_Centroid)
|
|
# admin.site.register(ImportGeom210915)
|
|
# admin.site.register(Peak, PeaksAdmin)
|
|
# admin.site.register(Search, SearchAdmin)
|
|
# admin.site.register(TaxaPeople)
|
|
# # admin.site.register(RangesPeople)
|
|
# # admin.site.register(ResourcesPeople)
|
|
# admin.site.register(ScalesPeople)
|
|
# admin.site.register(Species, SpeciesAdmin)
|
|
# admin.site.register(PeopleFunction)
|
|
# admin.site.register(SpeciesRange, SpeciesRangeAdmin)
|
|
# admin.site.register(RangesPeople, PeopleRangeAdmin)
|
|
# admin.site.register(TaxonRange, TaxonRangeAdmin)
|
|
# admin.site.register(PeopleResource, PeopleResourceAdmin)
|
|
# admin.site.register(RangeCountry, RangeCountryAdmin)
|