2022-03-25 18:08:02 +00:00
|
|
|
from re import A
|
|
|
|
from unicodedata import name
|
2021-07-27 04:00:24 +00:00
|
|
|
from django.contrib import admin
|
2021-11-26 11:37:03 +00:00
|
|
|
from django.utils.html import format_html
|
2021-07-28 04:20:54 +00:00
|
|
|
from .models import *
|
2021-11-29 16:54:33 +00:00
|
|
|
from django.forms import TextInput
|
2022-01-05 14:13:14 +00:00
|
|
|
from django.conf import settings
|
2022-03-25 18:08:02 +00:00
|
|
|
from django.http import HttpResponse
|
|
|
|
import csv
|
2022-03-27 18:32:26 +00:00
|
|
|
from django import forms
|
|
|
|
from django.contrib.admin.widgets import AutocompleteSelect
|
2022-09-07 18:48:58 +00:00
|
|
|
|
|
|
|
|
2022-03-28 05:46:30 +00:00
|
|
|
class autocomplete_fields_form(forms.ModelForm):
|
2022-03-27 18:32:26 +00:00
|
|
|
"""This form overrides autocomplete
|
|
|
|
organization field for Person class
|
|
|
|
"""
|
2022-09-07 18:48:58 +00:00
|
|
|
|
2022-03-28 05:46:30 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(autocomplete_fields_form, self).__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
# self.fields['organization'].label = 'My new label'
|
|
|
|
|
2022-03-27 18:32:26 +00:00
|
|
|
class Meta:
|
2022-03-28 05:46:30 +00:00
|
|
|
model = Person
|
|
|
|
fields = '__all__'
|
2022-09-07 18:48:58 +00:00
|
|
|
widgets = {
|
2022-03-28 05:46:30 +00:00
|
|
|
'organization': forms.Select(attrs={'style': 'width:750px'})
|
2022-09-07 18:48:58 +00:00
|
|
|
}
|
2022-03-28 05:46:30 +00:00
|
|
|
|
2021-07-27 04:00:24 +00:00
|
|
|
|
2022-03-25 18:08:02 +00:00
|
|
|
def download_csv(modeladmin, request, queryset):
|
2022-09-07 18:48:58 +00:00
|
|
|
name = queryset[0].__class__.__name__
|
2022-03-25 18:08:02 +00:00
|
|
|
response = HttpResponse()
|
|
|
|
response['Content-Disposition'] = "attachment; filename="+name+"_table.csv"
|
|
|
|
first_row = []
|
|
|
|
for i in queryset[0]._meta.__dict__.get("fields"):
|
|
|
|
temp = str(i).split('.')
|
|
|
|
first_row.append(temp[-1])
|
2021-09-23 13:43:35 +00:00
|
|
|
|
2022-03-25 18:08:02 +00:00
|
|
|
writer = csv.writer(response)
|
|
|
|
writer.writerow(first_row)
|
|
|
|
for dic in queryset.values():
|
2022-09-07 18:48:58 +00:00
|
|
|
temp_list = (list(dic.values()))
|
2022-03-25 18:08:02 +00:00
|
|
|
writer.writerow(temp_list)
|
|
|
|
return response
|
2022-03-25 18:35:38 +00:00
|
|
|
|
2022-09-07 18:48:58 +00:00
|
|
|
|
2022-03-25 18:35:38 +00:00
|
|
|
download_csv.short_description = 'export (.csv)'
|
|
|
|
|
2022-09-07 18:48:58 +00:00
|
|
|
|
2021-11-28 05:40:19 +00:00
|
|
|
class PeopleResourceInline(admin.TabularInline):
|
2022-01-05 14:13:14 +00:00
|
|
|
autocomplete_fields = ['resource']
|
2021-11-28 05:40:19 +00:00
|
|
|
model = PeopleResource
|
2022-01-05 14:13:14 +00:00
|
|
|
extra = 0
|
2021-11-28 05:40:19 +00:00
|
|
|
|
|
|
|
|
2021-11-28 06:26:16 +00:00
|
|
|
class PeopleRangeInline(admin.TabularInline):
|
2022-01-05 14:13:14 +00:00
|
|
|
autocomplete_fields = ['range']
|
2021-11-28 06:26:16 +00:00
|
|
|
model = PeopleRange
|
2022-01-05 14:13:14 +00:00
|
|
|
extra = 0
|
2021-11-28 06:26:16 +00:00
|
|
|
|
|
|
|
|
2021-09-23 13:43:35 +00:00
|
|
|
class PersonAdmin(admin.ModelAdmin):
|
2021-11-28 05:40:19 +00:00
|
|
|
inlines = [
|
|
|
|
PeopleResourceInline,
|
2021-11-28 06:26:16 +00:00
|
|
|
PeopleRangeInline
|
2021-11-28 05:40:19 +00:00
|
|
|
]
|
2022-01-19 06:58:22 +00:00
|
|
|
readonly_fields = ['id']
|
2022-09-07 18:48:58 +00:00
|
|
|
search_fields = ['title', 'first_name', 'last_name', 'organisation',
|
|
|
|
'position', 'country__short_name', 'contact_email']
|
2021-11-22 08:27:56 +00:00
|
|
|
fieldsets = (
|
|
|
|
(None, {
|
|
|
|
'fields': (
|
2022-01-17 17:44:09 +00:00
|
|
|
('id', 'profile_on_web', 'news_letter'),
|
2022-09-07 18:48:58 +00:00
|
|
|
('mr_mrs', 'title', 'full_name', 'position'),
|
2021-11-22 08:27:56 +00:00
|
|
|
('first_name', 'last_name', 'search_name', 'status'),
|
|
|
|
('contact_email', 'email_2', 'skype', 'professional_phone'),
|
2022-01-19 06:58:22 +00:00
|
|
|
'organization',
|
2021-11-22 08:27:56 +00:00
|
|
|
'personal_url',
|
|
|
|
'biography',
|
|
|
|
'field_of_expertise',
|
|
|
|
'geographic_area_of_expertise')
|
|
|
|
}),
|
|
|
|
('Research Scale', {
|
|
|
|
'classes': ('collapse',),
|
2021-11-22 08:40:59 +00:00
|
|
|
'fields': (('field_site', 'transect', 'mountain_top', 'mountain_range', 'landscape', 'regional', 'national',),
|
2022-09-07 18:48:58 +00:00
|
|
|
'_global'),
|
2021-11-22 08:27:56 +00:00
|
|
|
}),
|
|
|
|
('Methods and tools', {
|
|
|
|
'classes': ('collapse',),
|
2021-11-22 08:40:59 +00:00
|
|
|
'fields': (('biological_field_sampling', 'data_mining', 'remote_sensing',
|
2021-11-22 08:37:28 +00:00
|
|
|
'gis', 'spatial_analysis', 'statistical_analysis', 'modelling'),
|
|
|
|
('assessment', 'meta_analysis', 'synthesis', 'qualitative_ssm', 'genetic_analyses'))
|
2021-11-22 08:27:56 +00:00
|
|
|
}),
|
|
|
|
('Taxonomic groups', {
|
|
|
|
'classes': ('collapse',),
|
2021-11-22 08:37:28 +00:00
|
|
|
'fields': (('birds', 'mammals', 'reptiles', 'amphibians', 'fish', 'insects', 'molluscs', 'crustaceans',
|
|
|
|
'arachnids'), ('angiosperms', 'gymnosperms', 'fungi', 'algae', 'microbes')),
|
2021-11-22 08:27:56 +00:00
|
|
|
}),
|
|
|
|
('Others', {
|
|
|
|
'classes': ('collapse',),
|
2022-01-17 17:44:09 +00:00
|
|
|
'fields': (
|
|
|
|
'orcid', 'web_of_science', 'twitter', 'instagram', 'updated',
|
|
|
|
'entry_date',
|
|
|
|
'country',
|
|
|
|
'gmba_function'
|
|
|
|
),
|
2021-11-22 08:27:56 +00:00
|
|
|
}),
|
|
|
|
)
|
2022-01-04 16:56:58 +00:00
|
|
|
list_display = ['id', 'full_name', 'organization']
|
2022-04-12 07:01:31 +00:00
|
|
|
|
2022-03-27 18:32:26 +00:00
|
|
|
#autocomplete_fields = ['organization']
|
2022-09-07 18:48:58 +00:00
|
|
|
form = autocomplete_fields_form # adjust width of autocomplete_fields organization
|
2022-03-27 18:32:26 +00:00
|
|
|
|
2022-01-05 14:13:14 +00:00
|
|
|
list_per_page = settings.ADMIN_LIST_PER_PAGE
|
2022-01-05 16:48:21 +00:00
|
|
|
ordering = ['full_name']
|
2022-03-25 18:08:02 +00:00
|
|
|
actions = [download_csv]
|
|
|
|
|
2022-04-12 07:01:31 +00:00
|
|
|
def get_field_queryset(self, db, db_field, request):
|
|
|
|
queryset = super().get_field_queryset(db, db_field, request)
|
|
|
|
if db_field.name == 'organization':
|
2022-09-07 18:48:58 +00:00
|
|
|
queryset = queryset.order_by(
|
|
|
|
'country', 'organisation_english', 'organisation_2', 'organisation_3', 'acronym')
|
2022-04-12 07:01:31 +00:00
|
|
|
return queryset
|
2022-09-07 18:48:58 +00:00
|
|
|
|
|
|
|
|
2021-11-28 13:20:51 +00:00
|
|
|
class ResourceKeywordInline(admin.TabularInline):
|
2022-01-05 15:21:40 +00:00
|
|
|
autocomplete_fields = ['keyword']
|
2021-11-28 13:20:51 +00:00
|
|
|
model = ResourceKeyword
|
2022-01-05 15:21:40 +00:00
|
|
|
extra = 0
|
2021-11-28 13:20:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ResourceRangeInline(admin.TabularInline):
|
2022-01-05 15:21:40 +00:00
|
|
|
autocomplete_fields = ['range_name']
|
2021-11-28 13:20:51 +00:00
|
|
|
model = ResourceRange
|
2022-01-05 15:21:40 +00:00
|
|
|
extra = 0
|
2021-11-28 13:20:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ResourcePeopleInline(admin.TabularInline):
|
2022-01-05 15:21:40 +00:00
|
|
|
autocomplete_fields = ['person']
|
2021-11-28 13:28:03 +00:00
|
|
|
model = PeopleResource
|
2022-01-05 15:21:40 +00:00
|
|
|
extra = 0
|
2021-11-29 16:54:33 +00:00
|
|
|
formfield_overrides = {
|
|
|
|
models.CharField: {'widget': TextInput(attrs={'size': '20'})}
|
|
|
|
}
|
2021-11-28 13:20:51 +00:00
|
|
|
|
|
|
|
|
2021-10-11 02:53:22 +00:00
|
|
|
class ResourceAdmin(admin.ModelAdmin):
|
2021-11-28 13:20:51 +00:00
|
|
|
inlines = [
|
|
|
|
ResourceKeywordInline,
|
|
|
|
ResourceRangeInline,
|
|
|
|
ResourcePeopleInline
|
|
|
|
]
|
2021-10-11 02:53:22 +00:00
|
|
|
search_fields = ['title', 'url', 'citation', 'abstract']
|
2021-11-26 13:17:20 +00:00
|
|
|
readonly_fields = ['id']
|
2021-11-26 12:33:30 +00:00
|
|
|
list_display = ['title', 'citation', 'type']
|
2022-01-04 16:56:58 +00:00
|
|
|
ordering = ['title']
|
2021-11-26 12:19:49 +00:00
|
|
|
fieldsets = (
|
|
|
|
(None, {
|
|
|
|
'fields': (
|
|
|
|
('id', 'stars'),
|
|
|
|
'title',
|
|
|
|
'citation',
|
|
|
|
('type',),
|
2021-11-26 13:17:20 +00:00
|
|
|
('url',),
|
2021-11-26 12:19:49 +00:00
|
|
|
('lat', 'lon'),
|
|
|
|
'doi',
|
|
|
|
'wiki_data_id',
|
2021-11-28 13:20:51 +00:00
|
|
|
'inventory',
|
2021-11-29 16:39:04 +00:00
|
|
|
'abstract',
|
|
|
|
'author_keywords'
|
2021-11-26 12:19:49 +00:00
|
|
|
)
|
2021-11-26 12:31:55 +00:00
|
|
|
}),
|
2021-11-28 13:20:51 +00:00
|
|
|
('Research network', {
|
2021-11-26 12:42:58 +00:00
|
|
|
'classes': ('collapse',),
|
2021-11-28 13:20:51 +00:00
|
|
|
'fields': (('gloria', 'gnomo', 'lter', 'ltser', 'miren', 'team'),),
|
2021-11-26 12:41:14 +00:00
|
|
|
}),
|
2021-11-28 13:20:51 +00:00
|
|
|
|
2021-11-26 12:41:14 +00:00
|
|
|
('PEGASuS', {
|
|
|
|
'classes': ('collapse',),
|
|
|
|
'fields': (
|
|
|
|
('PEGASuS_polygon_ID', 'PEGASuS_Polygon_comments', 'PEGASuS_Assessment_ID',
|
|
|
|
'PEGASuS_Check_map_with_author',),)
|
|
|
|
}),
|
2021-11-26 12:19:49 +00:00
|
|
|
)
|
2022-01-05 15:21:40 +00:00
|
|
|
list_per_page = settings.ADMIN_LIST_PER_PAGE
|
2022-03-25 18:08:02 +00:00
|
|
|
|
2022-09-07 18:48:58 +00:00
|
|
|
def get_actions(self, request):
|
|
|
|
actions = super().get_actions(request)
|
|
|
|
if 'delete_selected' in actions:
|
|
|
|
del actions['delete_selected']
|
|
|
|
return actions
|
|
|
|
|
|
|
|
def delete_resource(self, request, obj):
|
|
|
|
for o in obj.all():
|
|
|
|
resource_keyword = ResourceKeyword.objects.filter(resource=o.id)
|
|
|
|
for i in resource_keyword:
|
|
|
|
i.delete()
|
|
|
|
resource_range = ResourceRange.objects.filter(resource_title=o.id)
|
|
|
|
for i in resource_range:
|
|
|
|
i.delete()
|
|
|
|
resource_people = ResourcesPeople.objects.filter(resource=o.id)
|
|
|
|
for i in resource_people:
|
|
|
|
i.delete()
|
|
|
|
resource_people_resource = PeopleResource.objects.filter(
|
|
|
|
resource=o.id)
|
|
|
|
for i in resource_people_resource:
|
|
|
|
i.delete()
|
|
|
|
o.delete()
|
|
|
|
delete_resource.short_description = 'Delete Resource & Related Fields'
|
|
|
|
|
|
|
|
actions = [download_csv, delete_resource]
|
2021-11-26 11:33:44 +00:00
|
|
|
|
2021-10-11 02:53:22 +00:00
|
|
|
|
2021-11-28 07:36:35 +00:00
|
|
|
class RangeNameTranslationInline(admin.TabularInline):
|
2022-01-05 15:32:12 +00:00
|
|
|
autocomplete_fields = ['language_translation']
|
2021-11-28 07:36:35 +00:00
|
|
|
model = RangeNameTranslation
|
2022-01-05 15:32:12 +00:00
|
|
|
extra = 0
|
2021-11-28 07:36:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RangeCountryInline(admin.TabularInline):
|
2022-01-05 15:32:12 +00:00
|
|
|
autocomplete_fields = ['country']
|
2021-11-28 07:36:35 +00:00
|
|
|
model = RangeCountry
|
2022-01-05 15:32:12 +00:00
|
|
|
extra = 0
|
2021-11-28 07:36:35 +00:00
|
|
|
|
|
|
|
|
2021-10-11 02:53:22 +00:00
|
|
|
class RangeAdmin(admin.ModelAdmin):
|
2022-01-05 15:51:35 +00:00
|
|
|
autocomplete_fields = ['mother_range']
|
2022-01-13 05:15:47 +00:00
|
|
|
# inlines = [
|
|
|
|
# RangeNameTranslationInline,
|
|
|
|
# RangeCountryInline
|
|
|
|
# ]
|
2022-01-05 16:48:43 +00:00
|
|
|
readonly_fields = ('id', 'gmba_v2_id')
|
2021-11-26 13:42:58 +00:00
|
|
|
search_fields = ['name', 'range_name', 'range_name_ascii',
|
|
|
|
'level', 'level', 'level_1', 'level_2', 'level_3', 'peak_name', 'comments', 'source',
|
2021-11-23 00:13:43 +00:00
|
|
|
'name_fr', 'name_de', 'name_es', 'name_pt', 'name_cn', 'name_ru', 'name_tr']
|
2021-11-23 09:53:27 +00:00
|
|
|
fieldsets = (
|
|
|
|
(None, {
|
|
|
|
'fields': (
|
2022-01-13 05:24:03 +00:00
|
|
|
('gmba_v2_id', 'range_name', 'range_name_language'),
|
|
|
|
('map_unit', 'feature', 'gmba_narrow', 'select_300'),
|
|
|
|
('range_name_map', 'range_name_ascii', 'GMBA_v1_id'),
|
|
|
|
('latitude', 'longitude', 'area'),
|
|
|
|
('mother_range', 'countries', 'wiki_data_id', 'wiki_data_url'),
|
2021-11-23 09:53:27 +00:00
|
|
|
'source',
|
2021-11-25 08:25:53 +00:00
|
|
|
'id',
|
2021-11-23 09:53:27 +00:00
|
|
|
)
|
|
|
|
}),
|
|
|
|
('Range Name Translation', {
|
|
|
|
'classes': ('collapse',),
|
|
|
|
'fields': (
|
|
|
|
('name_fr', 'name_de', 'name_es', 'name_pt'),
|
2021-11-23 10:17:12 +00:00
|
|
|
('name_ru', 'name_tr', 'name_cn')
|
|
|
|
)
|
2021-11-23 09:53:27 +00:00
|
|
|
}),
|
|
|
|
('Comments', {
|
|
|
|
'classes': ('collapse',),
|
2021-11-23 10:17:12 +00:00
|
|
|
'fields': ('comments',),
|
2022-01-13 05:05:42 +00:00
|
|
|
}),
|
|
|
|
('Others', {
|
|
|
|
'fields': ('range_alternate_id', )
|
2021-11-23 09:53:27 +00:00
|
|
|
})
|
|
|
|
)
|
2022-01-04 16:56:58 +00:00
|
|
|
list_display = ['range_name', 'mother_range', 'countries']
|
|
|
|
ordering = ['range_name']
|
2022-01-05 15:32:12 +00:00
|
|
|
list_per_page = settings.ADMIN_LIST_PER_PAGE
|
2021-10-11 02:53:22 +00:00
|
|
|
|
2022-03-25 18:08:02 +00:00
|
|
|
actions = [download_csv]
|
2021-10-11 02:53:22 +00:00
|
|
|
|
2022-09-07 18:48:58 +00:00
|
|
|
|
2021-11-28 14:59:44 +00:00
|
|
|
class PeopleOrganizationInline(admin.TabularInline):
|
|
|
|
model = Person
|
2021-11-28 16:41:44 +00:00
|
|
|
exclude = ['source_id', 'organisation', 'field_indexer']
|
2021-11-29 16:33:51 +00:00
|
|
|
fields = ('title', 'full_name', 'contact_email', 'position')
|
2021-11-28 14:59:44 +00:00
|
|
|
|
|
|
|
|
2021-11-26 06:32:08 +00:00
|
|
|
class OrganizationAdmin(admin.ModelAdmin):
|
2021-11-28 14:59:44 +00:00
|
|
|
inlines = [
|
|
|
|
PeopleOrganizationInline,
|
|
|
|
]
|
|
|
|
readonly_fields = ('org_num1',)
|
2022-09-07 18:48:58 +00:00
|
|
|
search_fields = ['organisation_search', 'org_alpha_search',
|
|
|
|
'organisation_2', 'organisation_3', 'subject', 'organisation_english']
|
|
|
|
list_display = ['org_num1', 'organisation_english',
|
|
|
|
'organisation_2', 'country']
|
2021-11-26 06:32:08 +00:00
|
|
|
fieldsets = (
|
|
|
|
(None, {
|
|
|
|
'fields': (
|
2021-11-28 16:37:17 +00:00
|
|
|
'org_num1',
|
|
|
|
('acronym', 'category', 'subject'),
|
2022-01-17 18:24:29 +00:00
|
|
|
'country',
|
2022-09-07 18:48:58 +00:00
|
|
|
('organisation_english', 'tel', 'email', 'url',),
|
2021-11-26 06:32:08 +00:00
|
|
|
('organisation_2', 'organisation_3'),
|
|
|
|
'organisation_original',
|
|
|
|
)
|
|
|
|
}),
|
|
|
|
('Address', {
|
|
|
|
'classes': ('collapse',),
|
|
|
|
'fields': (
|
|
|
|
('street', 'postcode', 'city'),
|
2022-01-17 18:24:29 +00:00
|
|
|
('po_box', 'lat_long'),
|
2021-11-26 06:32:08 +00:00
|
|
|
)
|
|
|
|
}),
|
|
|
|
('Other details', {
|
|
|
|
'classes': ('collapse',),
|
2022-01-17 18:24:29 +00:00
|
|
|
'fields': (
|
2022-09-07 18:48:58 +00:00
|
|
|
'tags',
|
|
|
|
),
|
2021-11-26 06:32:08 +00:00
|
|
|
})
|
|
|
|
)
|
2022-01-05 16:48:59 +00:00
|
|
|
ordering = ['organisation_english']
|
2022-03-25 18:08:02 +00:00
|
|
|
actions = [download_csv]
|
2022-01-02 14:31:16 +00:00
|
|
|
|
2021-11-26 11:26:36 +00:00
|
|
|
def org_url(self, instance):
|
2021-11-26 11:39:02 +00:00
|
|
|
return format_html('<a href="{0}" target="_blank">{1}</a>',
|
|
|
|
str(instance.url).strip("#"),
|
|
|
|
str(instance.url).strip("#"))
|
2021-11-26 11:26:36 +00:00
|
|
|
|
2021-11-26 06:32:08 +00:00
|
|
|
|
2021-10-11 02:53:22 +00:00
|
|
|
class FieldAdmin(admin.ModelAdmin):
|
|
|
|
search_fields = ['name']
|
|
|
|
|
|
|
|
|
2021-10-29 02:33:55 +00:00
|
|
|
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']
|
|
|
|
|
|
|
|
|
2021-10-30 04:23:49 +00:00
|
|
|
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']
|
|
|
|
|
|
|
|
|
2021-11-01 04:06:49 +00:00
|
|
|
class PeaksAdmin(admin.ModelAdmin):
|
|
|
|
search_fields = ['point_name', 'link']
|
|
|
|
|
|
|
|
|
|
|
|
class SearchAdmin(admin.ModelAdmin):
|
|
|
|
search_fields = ['search_string', 'search_date', 'result']
|
2021-11-11 17:45:04 +00:00
|
|
|
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 '--'
|
2021-11-01 04:06:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class SpeciesAdmin(admin.ModelAdmin):
|
|
|
|
search_fields = ['scientific_name', 'class_', 'english_name', 'url']
|
|
|
|
|
|
|
|
|
|
|
|
class TaxonRangeAdmin(admin.ModelAdmin):
|
2021-11-11 18:06:40 +00:00
|
|
|
model = TaxonRange
|
2022-09-07 18:48:58 +00:00
|
|
|
search_fields = ['range__range_name', 'taxon',
|
|
|
|
'subrange_or_region', 'distribution', 'source', 'remarks']
|
2021-11-11 18:06:40 +00:00
|
|
|
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'
|
2021-11-01 04:06:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RangeNameTranslationAdmin(admin.ModelAdmin):
|
2021-11-11 17:29:02 +00:00
|
|
|
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'
|
2021-11-01 04:06:49 +00:00
|
|
|
|
|
|
|
|
2021-11-10 18:52:29 +00:00
|
|
|
class PeopleRangeAdmin(admin.ModelAdmin):
|
2021-11-28 06:51:08 +00:00
|
|
|
model = MountainRange
|
2021-11-10 18:52:29 +00:00
|
|
|
list_display = ['person', 'range_name', ]
|
|
|
|
|
|
|
|
def range_name(self, obj):
|
|
|
|
return str(obj.range.name)
|
|
|
|
|
|
|
|
|
2021-11-22 10:09:33 +00:00
|
|
|
class PeopleResourceAdmin(admin.ModelAdmin):
|
2021-11-22 10:57:20 +00:00
|
|
|
fields = ('person', 'resource', 'p_r_role')
|
2021-11-22 11:02:59 +00:00
|
|
|
list_display = ['person', 'resource', 'role']
|
2021-11-22 11:42:30 +00:00
|
|
|
search_fields = ['person__full_name', 'resource__title', 'p_r_role__role']
|
2021-11-22 10:09:33 +00:00
|
|
|
|
|
|
|
|
2021-11-11 17:57:43 +00:00
|
|
|
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 '--'
|
|
|
|
|
|
|
|
|
2021-11-10 18:52:29 +00:00
|
|
|
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'
|
|
|
|
|
2021-11-01 04:06:49 +00:00
|
|
|
|
2022-01-05 15:21:40 +00:00
|
|
|
class KeywordAdmin(admin.ModelAdmin):
|
|
|
|
search_fields = ['keyword']
|
|
|
|
|
|
|
|
|
2021-07-27 04:00:24 +00:00
|
|
|
# Register your models here.
|
2021-09-23 13:43:35 +00:00
|
|
|
admin.site.register(Person, PersonAdmin)
|
2021-10-11 02:53:22 +00:00
|
|
|
admin.site.register(Resource, ResourceAdmin)
|
2021-11-28 06:51:08 +00:00
|
|
|
admin.site.register(MountainRange, RangeAdmin)
|
2022-01-05 15:21:40 +00:00
|
|
|
|
|
|
|
admin.site.register(Keyword, KeywordAdmin)
|
2021-11-28 17:01:58 +00:00
|
|
|
# admin.site.register(Method)
|
|
|
|
# admin.site.register(Scale)
|
|
|
|
# admin.site.register(Taxon)
|
|
|
|
# admin.site.register(Field, FieldAdmin)
|
2022-09-07 18:48:58 +00:00
|
|
|
admin.site.disable_action('delete_selected')
|
2021-10-29 02:33:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
# LU models
|
2022-01-05 15:32:12 +00:00
|
|
|
admin.site.register(Country, CountriesAdmin)
|
2021-11-28 17:01:58 +00:00
|
|
|
# admin.site.register(GMBA_SpeciesGroup, GMBA_SpeciesGroupAdmin)
|
2022-01-05 15:32:12 +00:00
|
|
|
admin.site.register(Language, LanguageAdmin)
|
2021-11-28 17:01:58 +00:00
|
|
|
# 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)
|
2021-11-01 04:06:49 +00:00
|
|
|
|
|
|
|
# Others
|
2021-11-28 17:01:58 +00:00
|
|
|
# admin.site.register(Repository, RepositoryAdmin)
|
|
|
|
# admin.site.register(GMBA_function, GMBAFunctionAdmin)
|
2021-11-28 14:19:51 +00:00
|
|
|
admin.site.register(Organisation, OrganizationAdmin)
|
2021-11-28 17:01:58 +00:00
|
|
|
# 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)
|