@@ -248,7 +248,7 @@ def queryset(self, request, queryset):
248248 return queryset
249249
250250
251- class LocationSiteAdmin (admin .GeoModelAdmin ):
251+ class LocationSiteAdmin (admin .GISModelAdmin ):
252252 change_list_template = 'admin/location_site_changelist.html'
253253 form = LocationSiteForm
254254 default_zoom = 5
@@ -483,16 +483,18 @@ class IUCNStatusAdmin(OrderedModelAdmin):
483483 )
484484
485485 def iucn_colour (self , obj ):
486- return format_html ('<div style="background:%s; ' \
487- 'width: 50px; height: 15px;"></div>' % obj .colour )
486+ return format_html (
487+ '<div style="background:{}; width: 50px; height: 15px;"></div>' ,
488+ obj .colour )
488489
489490 def total_species (self , obj ):
490491 total_taxa = Taxonomy .objects .filter (
491492 iucn_status = obj
492493 ).count ()
493494 return format_html (
494- f'<a href="/admin/bims/taxonomy/?iucn_status__id__exact={ obj .id } ">'
495- f'{ total_taxa } </a>'
495+ '<a href="/admin/bims/taxonomy/?iucn_status__id__exact={}">'
496+ '{}</a>' ,
497+ obj .id , total_taxa
496498 )
497499
498500 iucn_colour .allow_tags = True
@@ -974,9 +976,9 @@ def merge_users(self, request, queryset):
974976 merge_users .short_description = 'Merge users'
975977
976978 def sass_accredited_status (self , obj ):
977- false_response = format_html (
979+ false_response = mark_safe (
978980 '<img src="/static/admin/img/icon-no.svg" alt="False">' )
979- true_response = format_html (
981+ true_response = mark_safe (
980982 '<img src="/static/admin/img/icon-yes.svg" alt="True">' )
981983
982984 def role (self , obj ):
@@ -995,9 +997,9 @@ def sass_accredited_status(self, obj, **kwargs):
995997 false_response = 'False'
996998 true_response = 'True'
997999 else :
998- false_response = format_html (
1000+ false_response = mark_safe (
9991001 '<img src="/static/admin/img/icon-no.svg" alt="False">' )
1000- true_response = format_html (
1002+ true_response = mark_safe (
10011003 '<img src="/static/admin/img/icon-yes.svg" alt="True">' )
10021004 try :
10031005 profile = BimsProfile .objects .get (user = obj )
@@ -1018,9 +1020,9 @@ def signed_up(self, obj, **kwargs):
10181020 false_response = 'False'
10191021 true_response = 'True'
10201022 else :
1021- false_response = format_html (
1023+ false_response = mark_safe (
10221024 '<img src="/static/admin/img/icon-no.svg" alt="False">' )
1023- true_response = format_html (
1025+ true_response = mark_safe (
10241026 '<img src="/static/admin/img/icon-yes.svg" alt="True">' )
10251027 if not obj .email :
10261028 return false_response
@@ -1078,13 +1080,15 @@ def response_add(self, request, obj, post_url_continue=None):
10781080 request , obj , post_url_continue )
10791081
10801082 def changelist_view (self , request , extra_context = None ):
1081- test = request .META ['HTTP_REFERER' ].split (request .META ['PATH_INFO' ])
1082- if test [- 1 ] and not test [- 1 ].startswith ('?' ):
1083- if 'signed_up' not in request .GET :
1084- q = request .GET .copy ()
1085- q ['signed_up' ] = 'True'
1086- request .GET = q
1087- request .META ['QUERY_STRING' ] = request .GET .urlencode ()
1083+ referer = request .META .get ('HTTP_REFERER' , '' )
1084+ if referer :
1085+ test = referer .split (request .META ['PATH_INFO' ])
1086+ if test [- 1 ] and not test [- 1 ].startswith ('?' ):
1087+ if 'signed_up' not in request .GET :
1088+ q = request .GET .copy ()
1089+ q ['signed_up' ] = 'True'
1090+ request .GET = q
1091+ request .META ['QUERY_STRING' ] = request .GET .urlencode ()
10881092 return super ().changelist_view (request , extra_context = extra_context )
10891093
10901094class BaseMapLayerAdmin (OrderedModelAdmin ):
@@ -1336,8 +1340,7 @@ class TaxonGroupAdmin(admin.ModelAdmin):
13361340 'category' ,
13371341 )
13381342 filter_horizontal = (
1339- 'taxonomies' ,
1340- 'experts'
1343+ 'experts' ,
13411344 )
13421345 raw_id_fields = (
13431346 'gbif_parent_species' ,
@@ -1836,9 +1839,9 @@ def taxon_group_list(self, obj: Biotope):
18361839
18371840 def used_in_SASS (self , obj : Biotope ):
18381841 if obj .sassbiotopefraction_set .all ().exists ():
1839- return format_html (
1842+ return mark_safe (
18401843 '<img src="/static/admin/img/icon-yes.svg" alt="True">' )
1841- return format_html (
1844+ return mark_safe (
18421845 '<img src="/static/admin/img/icon-no.svg" alt="False">' )
18431846
18441847 list_display = (
0 commit comments