Skip to content

Commit

Permalink
added type to stationMetadata and managed in rmapctrl and admin
Browse files Browse the repository at this point in the history
  • Loading branch information
pat1 committed Oct 6, 2023
1 parent b97a519 commit 9a1220e
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 12 deletions.
13 changes: 6 additions & 7 deletions python/rmap/stations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ class BoardAdmin(admin.ModelAdmin):
]

list_display = ('name','active','slug','category','stationmetadata')
list_editable = ('active',)
search_fields = ('name','active','slug','category','stationmetadata__name')
list_editable = ('active','category')
search_fields = ('name','active','slug','category','stationmetadata__user__username','stationmetadata__slug')

list_filter = ('active','category','stationmetadata','category')
list_filter = ('active','category','stationmetadata__user__username','stationmetadata')



Expand Down Expand Up @@ -154,12 +154,11 @@ class StationMetadataAdmin(admin.ModelAdmin):
# )


list_display = ('name','active','slug','user','ident','lat','lon','network','mqttrootpath','mqttmaintpath','category')
list_display = ('name','active','slug','user','ident','lat','lon','network','category','type')
list_display_links = ('name', 'slug')
list_editable = ('active','user','ident','lat','lon')
list_editable = ('active','user','ident','lat','lon','category','type')
search_fields = ['name','slug','user__username','ident','network']

list_filter = ('user','ident','network','mqttrootpath','mqttmaintpath','category')
list_filter = ('user','ident','network','mqttrootpath','mqttmaintpath','category','type')


admin.site.register(StationMetadata, StationMetadataAdmin)
Expand Down
11 changes: 11 additions & 0 deletions python/rmap/stations/fixtures/template_stations.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"network": "fixed",
"mqttrootpath": "report",
"mqttmaintpath": "maint",
"type": "stimav4",
"category": "template"
}
},
Expand Down Expand Up @@ -765,6 +766,7 @@
"network": "fixed",
"mqttrootpath": "report",
"mqttmaintpath": "maint",
"type": "stimav4",
"category": "template"
}
},
Expand Down Expand Up @@ -1405,6 +1407,7 @@
"network": "fixed",
"mqttrootpath": "report",
"mqttmaintpath": "maint",
"type": "stimav4",
"category": "template"
}
},
Expand Down Expand Up @@ -1798,6 +1801,7 @@
"network": "fixed",
"mqttrootpath": "sample",
"mqttmaintpath": "maint",
"type": "stimav2",
"category": "template"
}
},
Expand Down Expand Up @@ -1947,6 +1951,7 @@
"network": "fixed",
"mqttrootpath": "sample",
"mqttmaintpath": "maint",
"type": "manual",
"category": "template"
}
},
Expand Down Expand Up @@ -2002,6 +2007,7 @@
"network": "locali",
"mqttrootpath": "report",
"mqttmaintpath": "maint",
"type": "stimav3",
"category": "template"
}
},
Expand Down Expand Up @@ -2418,6 +2424,7 @@
"network": "claster",
"mqttrootpath": "report",
"mqttmaintpath": "maint",
"type": "stimav3",
"category": "template"
}
},
Expand Down Expand Up @@ -2659,6 +2666,7 @@
"network": "locali",
"mqttrootpath": "report",
"mqttmaintpath": "maint",
"type": "stimav3",
"category": "template"
}
},
Expand Down Expand Up @@ -3075,6 +3083,7 @@
"network": "fixed",
"mqttrootpath": "report",
"mqttmaintpath": "maint",
"type": "stimav4",
"category": "template"
}
},
Expand Down Expand Up @@ -3579,6 +3588,7 @@
"network": "fixed",
"mqttrootpath": "report",
"mqttmaintpath": "maint",
"type": "stimav4",
"category": "template"
}
},
Expand Down Expand Up @@ -4144,6 +4154,7 @@
"network": "fixed",
"mqttrootpath": "report",
"mqttmaintpath": "maint",
"type": "stimav4",
"category": "template"
}
},
Expand Down
18 changes: 18 additions & 0 deletions python/rmap/stations/migrations/0037_stationmetadata_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.17 on 2023-10-06 06:57

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('stations', '0036_auto_20230710_0909'),
]

operations = [
migrations.AddField(
model_name='stationmetadata',
name='type',
field=models.CharField(choices=[('unknown', 'Unknow model'), ('manual', 'Human observer'), ('stimav2', 'Stima version 2'), ('stimav3', 'Stima version 3'), ('stimav4', 'Stima version 4')], default='unknown', help_text='Type of the station', max_length=50),
),
]
11 changes: 11 additions & 0 deletions python/rmap/stations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,14 @@ class StationMetadata(models.Model):
('unknown','Unknown & Missing'),
)

STATION_TYPE_CHOICES = (
('unknown','Unknow model'),
('manual', 'Human observer'),
('stimav2','Stima version 2'),
('stimav3','Stima version 3'),
('stimav4','Stima version 4'),
)

name = models.CharField(max_length=255,default="My station",help_text=_("station name"))
active = models.BooleanField(_("Active"),default=True,help_text=_("Activate the station for measurements"))
slug = models.SlugField(unique=False, help_text=_('Auto-generated from name.'))
Expand All @@ -918,7 +926,10 @@ class StationMetadata(models.Model):
mqttrootpath = models.CharField(max_length=100,default="sample",null=False,blank=False,help_text=_("root mqtt path for publish"))
mqttmaintpath = models.CharField(max_length=100,default="maint",null=False,blank=False,help_text=_("maint mqtt path for publish"))
category = models.CharField(max_length=50,default="unknown",choices=STATION_CATEGORY_CHOICES,help_text=_("Category of the station"))
type = models.CharField(max_length=50,default="unknown",choices=STATION_TYPE_CHOICES,help_text=_("Type of the station"))



def lon_lat(self):
if self.lon is None:
return "None_None"
Expand Down
10 changes: 5 additions & 5 deletions python/rmapctrl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def ctrl(cwd):
p.add_option("--exportmqttsha", action="store_true",dest="exportmqttsha", help="export mqtt (station) hashed password to stdout", default=False)
p.add_option("--exportmqttpskkey", action="store_true",dest="exportmqttpskkey", help="export mqtt (station) psk key to stdout", default=False)
p.add_option("--exportmqttacl", action="store_true",dest="exportmqttacl", help="export hashed mqtt acl (topic) to stdout", default=False)
p.add_option('--rpc_mqtt_admin_fdownload',action="store_true", help="firmware download request to admin RPC over MQTT")
p.add_option('--rpc_mqtt_admin_fdownload_v4',action="store_true", help="firmware download request to admin RPC over MQTT for Stima V4")
p.add_option('--username', default=None, help="work on station managed by this username")
p.add_option('--station_slug', default=None, help="work on station defined by this slug")
p.add_option('--purge_rpc',action="store_true", help="remove non active RPC (submitted and completed")
Expand All @@ -66,9 +66,9 @@ def ctrl(cwd):
not options.exportmqttpskkey and\
not options.exportmqttacl and\
not options.purge_rpc and\
not options.rpc_mqtt_admin_fdownload):
not options.rpc_mqtt_admin_fdownload_v4):
p.print_help()
raise optparse.OptionValueError("you have to set one of --syncdb --collectdb --dumpdata --loaddata --rpc_mqtt_admin_fdownload --purge_rpc or one of the export options")
raise optparse.OptionValueError("you have to set one of --syncdb --collectdb --dumpdata --loaddata --rpc_mqtt_admin_fdownload_v4 --purge_rpc or one of the export options")


if (options.changeuser):
Expand Down Expand Up @@ -199,7 +199,7 @@ def ctrl(cwd):
management.call_command("loaddata",options.loaddata)


if (options.rpc_mqtt_admin_fdownload):
if (options.rpc_mqtt_admin_fdownload_v4):
from django.contrib.auth.models import User
from rmap.stations.models import StationMetadata
if (options.username):
Expand All @@ -211,7 +211,7 @@ def ctrl(cwd):
if (options.station_slug):
stationmetadatas=(StationMetadata.objects.filter(user__username=u.username,slug=options.station_slug),)
else:
stationmetadatas=StationMetadata.objects.filter(user__username=u.username)
stationmetadatas=StationMetadata.objects.filter(user__username=u.username,type="stimav4")

for mystationmetadata in stationmetadatas:
if mystationmetadata.active:
Expand Down

0 comments on commit 9a1220e

Please sign in to comment.