2014-09-17 10:53:25 -06:00
|
|
|
from django.contrib import admin
|
|
|
|
|
2015-07-23 09:18:01 -06:00
|
|
|
from network.base.models import (Antenna, Satellite, Station, Transmitter,
|
2017-09-11 04:33:49 -06:00
|
|
|
Observation, Mode, Tle, Rig, DemodData)
|
2018-09-24 02:20:02 -06:00
|
|
|
from network.base.utils import export_as_csv
|
2014-09-17 10:53:25 -06:00
|
|
|
|
|
|
|
|
2015-09-09 02:12:36 -06:00
|
|
|
@admin.register(Rig)
|
|
|
|
class RigAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('name', 'rictld_number')
|
|
|
|
list_filter = ('name', )
|
|
|
|
|
2016-05-05 08:50:11 -06:00
|
|
|
|
2015-08-14 07:55:43 -06:00
|
|
|
@admin.register(Mode)
|
|
|
|
class ModeAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('name', )
|
|
|
|
readonly_fields = ('name', )
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Antenna)
|
2014-09-17 10:53:25 -06:00
|
|
|
class AntennaAdmin(admin.ModelAdmin):
|
2018-08-17 03:23:44 -06:00
|
|
|
list_display = ('id', '__unicode__', 'antenna_count', 'station_list', )
|
|
|
|
list_filter = ('band', 'antenna_type', )
|
|
|
|
|
|
|
|
def antenna_count(self, obj):
|
|
|
|
return obj.stations.all().count()
|
|
|
|
|
|
|
|
def station_list(self, obj):
|
|
|
|
return ",\n".join([str(s.id) for s in obj.stations.all()])
|
2014-09-17 10:53:25 -06:00
|
|
|
|
|
|
|
|
2015-08-14 07:55:43 -06:00
|
|
|
@admin.register(Station)
|
2014-09-17 10:53:25 -06:00
|
|
|
class StationAdmin(admin.ModelAdmin):
|
2018-09-24 02:20:02 -06:00
|
|
|
list_display = ('id', 'name', 'owner', 'get_email', 'lng', 'lat', 'qthlocator',
|
|
|
|
'client_version', 'created_date', 'state')
|
2018-08-27 06:25:27 -06:00
|
|
|
list_filter = ('status', 'created', 'client_version')
|
2015-05-06 04:06:00 -06:00
|
|
|
|
2018-09-24 02:20:02 -06:00
|
|
|
actions = [export_as_csv]
|
|
|
|
export_as_csv.short_description = "Export selected as CSV"
|
|
|
|
|
2015-05-06 04:06:00 -06:00
|
|
|
def created_date(self, obj):
|
|
|
|
return obj.created.strftime('%d.%m.%Y, %H:%M')
|
2014-09-17 10:53:25 -06:00
|
|
|
|
2018-09-24 02:20:02 -06:00
|
|
|
def get_email(self, obj):
|
|
|
|
return obj.owner.email
|
|
|
|
get_email.admin_order_field = 'email'
|
|
|
|
get_email.short_description = 'Owner Email'
|
|
|
|
|
2014-09-17 10:53:25 -06:00
|
|
|
|
2015-08-14 07:55:43 -06:00
|
|
|
@admin.register(Satellite)
|
2014-09-17 10:53:25 -06:00
|
|
|
class SatelliteAdmin(admin.ModelAdmin):
|
2016-03-26 08:51:02 -06:00
|
|
|
list_display = ('name', 'norad_cat_id')
|
2016-01-22 10:48:07 -07:00
|
|
|
readonly_fields = ('name', 'names', 'image')
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Tle)
|
|
|
|
class TleAdmin(admin.ModelAdmin):
|
2018-12-02 09:05:36 -07:00
|
|
|
list_display = ('satellite_name', 'tle0', 'tle1', 'updated_date')
|
|
|
|
list_filter = ('satellite__name',)
|
2015-05-06 04:06:00 -06:00
|
|
|
|
|
|
|
def updated_date(self, obj):
|
|
|
|
return obj.updated.strftime('%d.%m.%Y, %H:%M')
|
2014-09-17 10:53:25 -06:00
|
|
|
|
2018-12-02 09:05:36 -07:00
|
|
|
def satellite_name(self, obj):
|
|
|
|
return obj.satellite.name
|
|
|
|
|
2014-09-17 10:53:25 -06:00
|
|
|
|
2015-08-14 07:55:43 -06:00
|
|
|
@admin.register(Transmitter)
|
2015-07-23 09:18:01 -06:00
|
|
|
class TransmitterAdmin(admin.ModelAdmin):
|
2015-05-09 03:50:07 -06:00
|
|
|
list_display = ('uuid', 'description', 'satellite', 'uplink_low',
|
2014-10-16 07:42:44 -06:00
|
|
|
'uplink_high', 'downlink_low', 'downlink_high')
|
2015-05-09 03:50:07 -06:00
|
|
|
search_fields = ('satellite', 'uuid')
|
2016-05-08 07:47:49 -06:00
|
|
|
list_filter = ('mode', 'invert')
|
2015-08-14 07:55:43 -06:00
|
|
|
readonly_fields = ('uuid', 'description', 'satellite', 'uplink_low', 'uplink_high',
|
|
|
|
'downlink_low', 'downlink_high', 'baud', 'invert', 'alive', 'mode')
|
2015-05-06 04:06:00 -06:00
|
|
|
|
|
|
|
|
2017-09-26 11:16:41 -06:00
|
|
|
class DataDemodInline(admin.TabularInline):
|
|
|
|
model = DemodData
|
|
|
|
|
|
|
|
|
2015-08-14 07:55:43 -06:00
|
|
|
@admin.register(Observation)
|
2015-05-06 04:06:00 -06:00
|
|
|
class ObservationAdmin(admin.ModelAdmin):
|
2015-07-23 09:18:01 -06:00
|
|
|
list_display = ('id', 'author', 'satellite', 'transmitter', 'start_date', 'end_date')
|
2015-05-06 04:06:00 -06:00
|
|
|
list_filter = ('start', 'end')
|
|
|
|
search_fields = ('satellite', 'author')
|
2017-09-26 11:16:41 -06:00
|
|
|
inlines = [
|
|
|
|
DataDemodInline,
|
|
|
|
]
|
2014-09-17 10:53:25 -06:00
|
|
|
|
2015-05-06 04:06:00 -06:00
|
|
|
def start_date(self, obj):
|
|
|
|
return obj.start.strftime('%d.%m.%Y, %H:%M')
|
2014-09-17 15:26:51 -06:00
|
|
|
|
2015-05-06 04:06:00 -06:00
|
|
|
def end_date(self, obj):
|
|
|
|
return obj.end.strftime('%d.%m.%Y, %H:%M')
|