-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from ODM2/release/0.5.0
Release/0.5.0
- Loading branch information
Showing
44 changed files
with
4,084 additions
and
3,206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,11 @@ | |
"host": "-optional", | ||
"recaptcha_secret_key": "-optional", | ||
"recaptcha_user_key": "-optional", | ||
"email_sender": "[email protected]", | ||
"password_email_sender": "[email protected]", | ||
"email_host": "mail.usu.edu", | ||
"influx_query": "{hostname_with_url_and_auth_and_db}&q=SELECT%20%2A%20FROM%20%22uuid_{result_uuid}%22%20WHERE%20%22time%22%20%3E=%20%27{last_measurement}%27-{days_of_data}d", | ||
"tsa_url": "http://data.envirodiy.org/tsa/", | ||
"sensor_data_period": "3", | ||
"databases": [ | ||
{ | ||
"name": "default", | ||
|
@@ -24,5 +27,11 @@ | |
"host": "", | ||
"port": "" | ||
} | ||
] | ||
], | ||
"hydroshare_oauth": { | ||
"client_id": "client_id_here", | ||
"client_secret": "client_secret_here", | ||
"redirect_uri": "http://localhost:8000/oauth/hydroshare/", | ||
"response_type": "code" | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,67 @@ | ||
from django.contrib import admin | ||
|
||
from dataloader.models import * | ||
|
||
|
||
# Register your models here. | ||
from dataloaderinterface.models import SiteRegistration, SiteSensor | ||
|
||
|
||
def update_sensor_data(obj, form, sensor_fields): | ||
old_object = obj.__class__.objects.get(pk=obj.pk) | ||
old_data = {field: getattr(old_object, field) for field in sensor_fields if field in form.changed_data} | ||
new_data = {field: getattr(obj, field) for field in sensor_fields if field in form.changed_data} | ||
SiteSensor.objects.filter(**old_data).update(**new_data) | ||
|
||
|
||
@admin.register(SiteSensor) | ||
class SiteSensorAdmin(admin.ModelAdmin): | ||
pass | ||
|
||
|
||
@admin.register(SiteRegistration) | ||
class SiteRegistrationAdmin(admin.ModelAdmin): | ||
pass | ||
|
||
|
||
@admin.register(Organization) | ||
class OrganizationAdmin(admin.ModelAdmin): | ||
pass | ||
|
||
|
||
@admin.register(EquipmentModel) | ||
class EquipmentModelAdmin(admin.ModelAdmin): | ||
sensor_fields = ['model_name', 'model_manufacturer'] | ||
|
||
def save_model(self, request, obj, form, change): | ||
if change: | ||
update_sensor_data(obj, form, self.sensor_fields) | ||
|
||
super(EquipmentModelAdmin, self).save_model(request, obj, form, change) | ||
|
||
|
||
@admin.register(Variable) | ||
class VariableAdmin(admin.ModelAdmin): | ||
sensor_fields = ['variable_name', 'variable_code'] | ||
|
||
def save_model(self, request, obj, form, change): | ||
if change: | ||
update_sensor_data(obj, form, self.sensor_fields) | ||
|
||
super(VariableAdmin, self).save_model(request, obj, form, change) | ||
|
||
|
||
@admin.register(Unit) | ||
class UnitAdmin(admin.ModelAdmin): | ||
sensor_fields = ['unit_name', 'unit_abbreviation'] | ||
|
||
def save_model(self, request, obj, form, change): | ||
if change: | ||
update_sensor_data(obj, form, self.sensor_fields) | ||
|
||
super(UnitAdmin, self).save_model(request, obj, form, change) | ||
|
||
|
||
@admin.register(InstrumentOutputVariable) | ||
class InstrumentOutputVariableAdmin(admin.ModelAdmin): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/dataloaderinterface/management/commands/add_last_measurement_utc_datetime.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from datetime import timedelta | ||
from django.core.management.base import BaseCommand | ||
|
||
from dataloaderinterface.models import SiteSensor | ||
|
||
|
||
class Command(BaseCommand): | ||
help = '' | ||
|
||
def handle(self, *args, **options): | ||
sensors = SiteSensor.objects.filter(last_measurement_datetime__isnull=False) | ||
for sensor in sensors: | ||
sensor.last_measurement_utc_datetime = sensor.last_measurement_datetime - timedelta(hours=sensor.last_measurement_utc_offset) | ||
sensor.save(update_fields=['last_measurement_utc_datetime']) | ||
print('Last measurement utc datetime added to all sensors.') |
Oops, something went wrong.