Commit 5bf65ed1 authored by Rune Åvar Ødegård's avatar Rune Åvar Ødegård
Browse files

Added logger ID

parent 5a77f3fc
......@@ -6,4 +6,5 @@ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="update_v1.sql" relativeToChangelogFile="true"/>
<include file="update_v2.sql" relativeToChangelogFile="true"/>
<include file="update_v3.sql" relativeToChangelogFile="true"/>
<include file="update_v4.sql" relativeToChangelogFile="true"/>
</databaseChangeLog>
\ No newline at end of file
ALTER TABLE public.sampling_points
ADD COLUMN logger_id character varying(255);
\ No newline at end of file
......@@ -22,7 +22,8 @@ class UpdateHandler:
{'name': 'distance_source', 'required': True, 'type': str},
{'name': 'change_aei_stations', 'required': True, 'type': str},
{'name': 'begin_position', 'required': True, 'type': str},
{'name': 'end_position', 'required': True, 'type': str}
{'name': 'end_position', 'required': True, 'type': str},
{'name': 'logger_id', 'required': True, 'type': str}
]
return rules
......@@ -30,8 +31,13 @@ class UpdateHandler:
def handle(p):
sql = """
INSERT INTO sampling_points
(id, media_monitored, station_id, measurement_regime, mobile, assessment_type, station_classification, used_aqd, main_emission_sources, traffic_emissions, heating_emissions, industrial_emissions, distance_source, change_aei_stations, begin_position, end_position)
VALUES (%(id)s, %(media_monitored)s, %(station_id)s, %(measurement_regime)s, %(mobile)s, %(assessment_type)s, %(station_classification)s, %(used_aqd)s, %(main_emission_sources)s, %(traffic_emissions)s, %(heating_emissions)s, %(industrial_emissions)s, %(distance_source)s, %(change_aei_stations)s, %(begin_position)s, %(end_position)s)
(id, media_monitored, station_id, measurement_regime, mobile, assessment_type, station_classification, used_aqd,
main_emission_sources, traffic_emissions, heating_emissions, industrial_emissions, distance_source,
change_aei_stations, begin_position, end_position, logger_id)
VALUES (%(id)s, %(media_monitored)s, %(station_id)s, %(measurement_regime)s, %(mobile)s,
%(assessment_type)s, %(station_classification)s, %(used_aqd)s, %(main_emission_sources)s,
%(traffic_emissions)s, %(heating_emissions)s, %(industrial_emissions)s, %(distance_source)s,
%(change_aei_stations)s, %(begin_position)s, %(end_position)s, %(logger_id)s)
ON CONFLICT (id) DO
UPDATE SET media_monitored=%(media_monitored)s,
station_id=%(station_id)s,
......@@ -47,7 +53,8 @@ class UpdateHandler:
distance_source=%(distance_source)s,
change_aei_stations=%(change_aei_stations)s,
begin_position=%(begin_position)s,
end_position=%(end_position)s
end_position=%(end_position)s,
logger_id=%(logger_id)s
"""
rows = Db.execute(sql, p)
return rows
......@@ -208,7 +208,17 @@
></l-input>
</div>
</div>
<div class="w-full flex mb-4">
<div class="w-1/2">
<b>Logger ID</b>
<br />
<l-input
placeholder="Enter 'Logger ID' (if using push logger functionality) (text)"
v-model="editObj.logger_id"
inputClass="text-2xs"
></l-input>
</div>
</div>
<div class="flex w-full justify-between">
<l-button type="success" @click="onSave">Save changes</l-button>
<l-button type="danger" @click="close">Cancel</l-button>
......
......@@ -35,6 +35,7 @@
<hot-column title="Change Aei Stations" data="change_aei_stations" read-only="true"></hot-column>
<hot-column title="Begin Position" data="begin_position" read-only="true"></hot-column>
<hot-column title="End Position" data="end_position" read-only="true"></hot-column>
<hot-column title="Logger ID" data="logger_id" read-only="true"></hot-column>
</hot-table>
<l-l-edit
:showing="edit"
......
......@@ -70,8 +70,8 @@ class ModelBinder:
model = list(reader)
except Exception as e:
if e is "":
raise BadRequest("Could not parse csv file. Make sure file is utf-8 format")
raise BadRequest(e)
raise BadRequest("Could not parse csv file. Make sure file is utf-8 format")
raise BadRequest(e.args)
# Replace empty strings with None so null columns can be inserted in db
for m in model:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment