-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.py
35 lines (25 loc) · 877 Bytes
/
admin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from django.contrib import admin
from .models import *
from django.utils.safestring import mark_safe
from django.template.loader import render_to_string
from leaflet.admin import LeafletGeoAdmin
class AreaAdmin(LeafletGeoAdmin):
pass
class ProductAdmin(admin.ModelAdmin):
list_display = ("title", "footprint")
class WeekAdmin(admin.ModelAdmin):
list_display = ("name", "week")
def name(self, item):
return str(item)
def week(self, item):
return item.week
def ndvi_image(self, obj):
return render_to_string('thumb.html',{
'image': obj.as_jpeg_thumb(obj.ndvi)
})
ndvi_image.allow_tags = True
admin.site.register(SatelliteImage, ProductAdmin)
admin.site.register(Area, AreaAdmin)
admin.site.register(Week, WeekAdmin)
admin.site.register(AnalysisType)
admin.site.register(Analysis)