Merge pull request '10105/improve-person-detail-load-time' (#3) from 10105/improve-person-detail-load-time into master
Reviewed-on: #3
This commit is contained in:
commit
b3d43f802d
2 changed files with 29 additions and 2 deletions
29
app/admin.py
29
app/admin.py
|
@ -2,14 +2,19 @@ from django.contrib import admin
|
||||||
from django.utils.html import format_html
|
from django.utils.html import format_html
|
||||||
from .models import *
|
from .models import *
|
||||||
from django.forms import TextInput
|
from django.forms import TextInput
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
class PeopleResourceInline(admin.TabularInline):
|
class PeopleResourceInline(admin.TabularInline):
|
||||||
|
autocomplete_fields = ['resource']
|
||||||
model = PeopleResource
|
model = PeopleResource
|
||||||
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
class PeopleRangeInline(admin.TabularInline):
|
class PeopleRangeInline(admin.TabularInline):
|
||||||
|
autocomplete_fields = ['range']
|
||||||
model = PeopleRange
|
model = PeopleRange
|
||||||
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
class PersonAdmin(admin.ModelAdmin):
|
class PersonAdmin(admin.ModelAdmin):
|
||||||
|
@ -60,19 +65,26 @@ class PersonAdmin(admin.ModelAdmin):
|
||||||
)
|
)
|
||||||
list_display = ['id', 'full_name', 'organization']
|
list_display = ['id', 'full_name', 'organization']
|
||||||
autocomplete_fields = ['organization']
|
autocomplete_fields = ['organization']
|
||||||
|
list_per_page = settings.ADMIN_LIST_PER_PAGE
|
||||||
# list_display_links = ['id']
|
# list_display_links = ['id']
|
||||||
|
|
||||||
|
|
||||||
class ResourceKeywordInline(admin.TabularInline):
|
class ResourceKeywordInline(admin.TabularInline):
|
||||||
|
autocomplete_fields = ['keyword']
|
||||||
model = ResourceKeyword
|
model = ResourceKeyword
|
||||||
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
class ResourceRangeInline(admin.TabularInline):
|
class ResourceRangeInline(admin.TabularInline):
|
||||||
|
autocomplete_fields = ['range_name']
|
||||||
model = ResourceRange
|
model = ResourceRange
|
||||||
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
class ResourcePeopleInline(admin.TabularInline):
|
class ResourcePeopleInline(admin.TabularInline):
|
||||||
|
autocomplete_fields = ['person']
|
||||||
model = PeopleResource
|
model = PeopleResource
|
||||||
|
extra = 0
|
||||||
formfield_overrides = {
|
formfield_overrides = {
|
||||||
models.CharField: {'widget': TextInput(attrs={'size': '20'})}
|
models.CharField: {'widget': TextInput(attrs={'size': '20'})}
|
||||||
}
|
}
|
||||||
|
@ -116,17 +128,23 @@ class ResourceAdmin(admin.ModelAdmin):
|
||||||
'PEGASuS_Check_map_with_author',),)
|
'PEGASuS_Check_map_with_author',),)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
list_per_page = settings.ADMIN_LIST_PER_PAGE
|
||||||
|
|
||||||
|
|
||||||
class RangeNameTranslationInline(admin.TabularInline):
|
class RangeNameTranslationInline(admin.TabularInline):
|
||||||
|
autocomplete_fields = ['language_translation']
|
||||||
model = RangeNameTranslation
|
model = RangeNameTranslation
|
||||||
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
class RangeCountryInline(admin.TabularInline):
|
class RangeCountryInline(admin.TabularInline):
|
||||||
|
autocomplete_fields = ['country']
|
||||||
model = RangeCountry
|
model = RangeCountry
|
||||||
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
class RangeAdmin(admin.ModelAdmin):
|
class RangeAdmin(admin.ModelAdmin):
|
||||||
|
autocomplete_fields = ['mother_range']
|
||||||
inlines = [
|
inlines = [
|
||||||
RangeNameTranslationInline,
|
RangeNameTranslationInline,
|
||||||
RangeCountryInline
|
RangeCountryInline
|
||||||
|
@ -166,6 +184,7 @@ class RangeAdmin(admin.ModelAdmin):
|
||||||
)
|
)
|
||||||
list_display = ['range_name', 'mother_range', 'countries']
|
list_display = ['range_name', 'mother_range', 'countries']
|
||||||
ordering = ['range_name']
|
ordering = ['range_name']
|
||||||
|
list_per_page = settings.ADMIN_LIST_PER_PAGE
|
||||||
|
|
||||||
|
|
||||||
class PeopleOrganizationInline(admin.TabularInline):
|
class PeopleOrganizationInline(admin.TabularInline):
|
||||||
|
@ -360,10 +379,16 @@ class RangeCountryAdmin(admin.ModelAdmin):
|
||||||
return str(obj.country.short_name) if obj.country else 'None'
|
return str(obj.country.short_name) if obj.country else 'None'
|
||||||
|
|
||||||
|
|
||||||
|
class KeywordAdmin(admin.ModelAdmin):
|
||||||
|
search_fields = ['keyword']
|
||||||
|
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
admin.site.register(Person, PersonAdmin)
|
admin.site.register(Person, PersonAdmin)
|
||||||
admin.site.register(Resource, ResourceAdmin)
|
admin.site.register(Resource, ResourceAdmin)
|
||||||
admin.site.register(MountainRange, RangeAdmin)
|
admin.site.register(MountainRange, RangeAdmin)
|
||||||
|
|
||||||
|
admin.site.register(Keyword, KeywordAdmin)
|
||||||
# admin.site.register(Method)
|
# admin.site.register(Method)
|
||||||
# admin.site.register(Scale)
|
# admin.site.register(Scale)
|
||||||
# admin.site.register(Taxon)
|
# admin.site.register(Taxon)
|
||||||
|
@ -371,9 +396,9 @@ admin.site.register(MountainRange, RangeAdmin)
|
||||||
|
|
||||||
|
|
||||||
# LU models
|
# LU models
|
||||||
# admin.site.register(Country, CountriesAdmin)
|
admin.site.register(Country, CountriesAdmin)
|
||||||
# admin.site.register(GMBA_SpeciesGroup, GMBA_SpeciesGroupAdmin)
|
# admin.site.register(GMBA_SpeciesGroup, GMBA_SpeciesGroupAdmin)
|
||||||
# admin.site.register(Language, LanguageAdmin)
|
admin.site.register(Language, LanguageAdmin)
|
||||||
# admin.site.register(PeopleStatus, PeopleStatusAdmin)
|
# admin.site.register(PeopleStatus, PeopleStatusAdmin)
|
||||||
# admin.site.register(RangeType, RangeTypeAdmin)
|
# admin.site.register(RangeType, RangeTypeAdmin)
|
||||||
# admin.site.register(RedListCategory, RedListCategoryAdmin)
|
# admin.site.register(RedListCategory, RedListCategoryAdmin)
|
||||||
|
|
|
@ -118,3 +118,5 @@ STATIC_URL = '/static/'
|
||||||
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
ADMIN_LIST_PER_PAGE = os.getenv('ADMIN_LIST_PER_PAGE', 20)
|
||||||
|
|
Loading…
Reference in a new issue