Skip to content

Commit 89d13d1

Browse files
authored
Merge pull request #450 from DataIntegrationGroup/BDMS-520-1-1-Cleanup-2.0
BDMS-520-1-1-Cleanup-2.0
2 parents 0736b5b + 1ba2c73 commit 89d13d1

26 files changed

Lines changed: 869 additions & 406 deletions

admin/config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
SurfaceWaterPhotosAdmin,
5454
ThingAdmin,
5555
TransducerObservationAdmin,
56+
WaterLevelsContinuousPressureDailyAdmin,
5657
WeatherPhotosAdmin,
5758
WeatherDataAdmin,
5859
FieldParametersAdmin,
@@ -80,6 +81,7 @@
8081
NMA_Soil_Rock_Results,
8182
NMA_Stratigraphy,
8283
NMA_SurfaceWaterData,
84+
NMA_WaterLevelsContinuous_Pressure_Daily,
8385
NMA_WeatherPhotos,
8486
NMA_SurfaceWaterPhotos,
8587
NMA_WeatherData,
@@ -192,6 +194,13 @@ def create_admin(app):
192194
# Transducer observations
193195
admin.add_view(TransducerObservationAdmin(TransducerObservation))
194196

197+
# Water Levels - Continuous (legacy)
198+
admin.add_view(
199+
WaterLevelsContinuousPressureDailyAdmin(
200+
NMA_WaterLevelsContinuous_Pressure_Daily
201+
)
202+
)
203+
195204
# Weather
196205
admin.add_view(WeatherPhotosAdmin(NMA_WeatherPhotos))
197206

admin/views/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
from admin.views.surface_water_photos import SurfaceWaterPhotosAdmin
5353
from admin.views.thing import ThingAdmin
5454
from admin.views.transducer_observation import TransducerObservationAdmin
55+
from admin.views.waterlevelscontinuous_pressure_daily import (
56+
WaterLevelsContinuousPressureDailyAdmin,
57+
)
5558
from admin.views.weather_photos import WeatherPhotosAdmin
5659
from admin.views.weather_data import WeatherDataAdmin
5760

@@ -88,6 +91,7 @@
8891
"SurfaceWaterPhotosAdmin",
8992
"ThingAdmin",
9093
"TransducerObservationAdmin",
94+
"WaterLevelsContinuousPressureDailyAdmin",
9195
"WeatherPhotosAdmin",
9296
"WeatherDataAdmin",
9397
]
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# ===============================================================================
2+
# Copyright 2026
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# ===============================================================================
16+
"""
17+
WaterLevelsContinuousPressureDailyAdmin view for legacy NMA_WaterLevelsContinuous_Pressure_Daily.
18+
"""
19+
20+
from starlette.requests import Request
21+
22+
from admin.views.base import OcotilloModelView
23+
24+
25+
class WaterLevelsContinuousPressureDailyAdmin(OcotilloModelView):
26+
"""
27+
Admin view for NMA_WaterLevelsContinuous_Pressure_Daily model.
28+
"""
29+
30+
# ========== Basic Configuration ==========
31+
name = "NMA Water Levels Continuous Pressure Daily"
32+
label = "NMA Water Levels Continuous Pressure Daily"
33+
icon = "fa fa-tachometer-alt"
34+
35+
def can_create(self, request: Request) -> bool:
36+
return False
37+
38+
def can_edit(self, request: Request) -> bool:
39+
return False
40+
41+
def can_delete(self, request: Request) -> bool:
42+
return False
43+
44+
# ========== List View ==========
45+
list_fields = [
46+
"global_id",
47+
"object_id",
48+
"well_id",
49+
"point_id",
50+
"date_measured",
51+
"temperature_water",
52+
"water_head",
53+
"water_head_adjusted",
54+
"depth_to_water_bgs",
55+
"measurement_method",
56+
"data_source",
57+
"measuring_agency",
58+
"qced",
59+
"notes",
60+
"created",
61+
"updated",
62+
"processed_by",
63+
"checked_by",
64+
"cond_dl_ms_cm",
65+
]
66+
67+
sortable_fields = [
68+
"global_id",
69+
"object_id",
70+
"well_id",
71+
"point_id",
72+
"date_measured",
73+
"water_head",
74+
"depth_to_water_bgs",
75+
"measurement_method",
76+
"data_source",
77+
"measuring_agency",
78+
"qced",
79+
"created",
80+
"updated",
81+
"processed_by",
82+
"checked_by",
83+
"cond_dl_ms_cm",
84+
]
85+
86+
fields_default_sort = [("date_measured", True)]
87+
88+
searchable_fields = [
89+
"global_id",
90+
"well_id",
91+
"point_id",
92+
"date_measured",
93+
"measurement_method",
94+
"data_source",
95+
"measuring_agency",
96+
"notes",
97+
]
98+
99+
page_size = 50
100+
page_size_options = [25, 50, 100, 200]
101+
102+
# ========== Detail View ==========
103+
fields = [
104+
"global_id",
105+
"object_id",
106+
"well_id",
107+
"point_id",
108+
"date_measured",
109+
"temperature_water",
110+
"water_head",
111+
"water_head_adjusted",
112+
"depth_to_water_bgs",
113+
"measurement_method",
114+
"data_source",
115+
"measuring_agency",
116+
"qced",
117+
"notes",
118+
"created",
119+
"updated",
120+
"processed_by",
121+
"checked_by",
122+
"cond_dl_ms_cm",
123+
]
124+
125+
field_labels = {
126+
"global_id": "GlobalID",
127+
"object_id": "OBJECTID",
128+
"well_id": "WellID",
129+
"point_id": "PointID",
130+
"date_measured": "Date Measured",
131+
"temperature_water": "Temperature Water",
132+
"water_head": "Water Head",
133+
"water_head_adjusted": "Water Head Adjusted",
134+
"depth_to_water_bgs": "Depth To Water (BGS)",
135+
"measurement_method": "Measurement Method",
136+
"data_source": "Data Source",
137+
"measuring_agency": "Measuring Agency",
138+
"qced": "QCed",
139+
"notes": "Notes",
140+
"created": "Created",
141+
"updated": "Updated",
142+
"processed_by": "Processed By",
143+
"checked_by": "Checked By",
144+
"cond_dl_ms_cm": "CONDDL (mS/cm)",
145+
}
146+
147+
148+
# ============= EOF =============================================

alembic/env.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@
55

66
from alembic import context
77
from dotenv import load_dotenv
8-
from services.util import get_bool_env
98
from sqlalchemy import create_engine, engine_from_config, pool, text
109

10+
from services.util import get_bool_env
11+
1112
# this is the Alembic Config object, which provides
1213
# access to the values within the .ini file in use.
1314
config = context.config
1415
alembic_logger = logging.getLogger("alembic.env")
1516

1617
# Interpret the config file for Python logging.
1718
# This line sets up loggers basically.
18-
if config.config_file_name is not None:
19+
if config.config_file_name is not None and os.environ.get(
20+
"ALEMBIC_USE_FILE_CONFIG", "0"
21+
) not in {"0", "false", "False"}:
1922
fileConfig(config.config_file_name, disable_existing_loggers=False)
23+
else:
24+
root_logger = logging.getLogger()
25+
alembic_logger = logging.getLogger("alembic")
26+
alembic_logger.handlers = root_logger.handlers[:]
27+
alembic_logger.setLevel(root_logger.level)
28+
alembic_logger.propagate = False
2029

2130
# add your model's MetaData object here
2231
# for 'autogenerate' support

alembic/versions/3cb924ca51fd_refactor_nma_tables_to_integer_pks.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88

99
from typing import Sequence, Union
1010

11-
from alembic import op
12-
import geoalchemy2
1311
import sqlalchemy as sa
14-
import sqlalchemy_utils
12+
from alembic import op
1513
from sqlalchemy.dialects import postgresql
1614

1715
# revision identifiers, used by Alembic.
@@ -509,15 +507,13 @@ def upgrade() -> None:
509507
existing_type=sa.VARCHAR(),
510508
comment="To audit the original NM_Aquifer LocationID if it was transferred over",
511509
existing_nullable=True,
512-
autoincrement=False,
513510
)
514511
op.alter_column(
515512
"thing_version",
516513
"nma_formation_zone",
517514
existing_type=sa.VARCHAR(length=25),
518515
comment="Raw FormationZone value from legacy WellData (NM_Aquifer).",
519516
existing_nullable=True,
520-
autoincrement=False,
521517
)
522518
op.alter_column(
523519
"transducer_observation",
@@ -558,7 +554,6 @@ def downgrade() -> None:
558554
comment=None,
559555
existing_comment="Raw FormationZone value from legacy WellData (NM_Aquifer).",
560556
existing_nullable=True,
561-
autoincrement=False,
562557
)
563558
op.alter_column(
564559
"thing_version",

alembic/versions/43bc34504ee6_merge_migrations_after_staging_merge.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
"""merge_migrations_after_staging_merge
22
33
Revision ID: 43bc34504ee6
4-
Revises: 3cb924ca51fd, e123456789ab
4+
Revises: 3cb924ca51fd
55
Create Date: 2026-01-30 11:52:41.932306
66
77
"""
88

99
from typing import Sequence, Union
1010

11-
from alembic import op
12-
import geoalchemy2
13-
import sqlalchemy as sa
14-
import sqlalchemy_utils
15-
1611
# revision identifiers, used by Alembic.
1712
revision: str = "43bc34504ee6"
18-
down_revision: Union[str, Sequence[str], None] = ("3cb924ca51fd", "e123456789ab")
13+
down_revision: Union[str, Sequence[str], None] = "3cb924ca51fd"
1914
branch_labels: Union[str, Sequence[str], None] = None
2015
depends_on: Union[str, Sequence[str], None] = None
2116

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""Add unique index for NGWMN well construction
2+
3+
Revision ID: 50d1c2a3b4c5
4+
Revises: 43bc34504ee6
5+
Create Date: 2026-01-31 00:27:12.204176
6+
7+
"""
8+
9+
from typing import Sequence, Union
10+
11+
from alembic import op
12+
13+
# revision identifiers, used by Alembic.
14+
revision: str = "50d1c2a3b4c5"
15+
down_revision: Union[str, Sequence[str], None] = "43bc34504ee6"
16+
branch_labels: Union[str, Sequence[str], None] = None
17+
depends_on: Union[str, Sequence[str], None] = None
18+
19+
20+
INDEX_NAME = "uq_ngwmn_wc_point_casing_screen"
21+
TABLE_NAME = "NMA_view_NGWMN_WellConstruction"
22+
23+
24+
def upgrade() -> None:
25+
op.create_index(
26+
INDEX_NAME,
27+
TABLE_NAME,
28+
["PointID", "CasingTop", "ScreenTop"],
29+
unique=True,
30+
)
31+
32+
33+
def downgrade() -> None:
34+
op.drop_index(INDEX_NAME, table_name=TABLE_NAME)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""Add nma_WCLab_ID column to NMA_MinorTraceChemistry
2+
3+
Revision ID: 71a4c6b3d2e8
4+
Revises: 50d1c2a3b4c5
5+
Create Date: 2026-01-31 01:05:00.000000
6+
7+
"""
8+
9+
from typing import Sequence, Union
10+
11+
import sqlalchemy as sa
12+
from alembic import op
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = "71a4c6b3d2e8"
16+
down_revision: Union[str, Sequence[str], None] = "50d1c2a3b4c5"
17+
branch_labels: Union[str, Sequence[str], None] = None
18+
depends_on: Union[str, Sequence[str], None] = None
19+
20+
21+
def upgrade() -> None:
22+
op.add_column(
23+
"NMA_MinorTraceChemistry",
24+
sa.Column("nma_WCLab_ID", sa.String(length=25), nullable=True),
25+
)
26+
27+
28+
def downgrade() -> None:
29+
op.drop_column("NMA_MinorTraceChemistry", "nma_WCLab_ID")

alembic/versions/76e3ae8b99cb_enforce_thing_fk_for_nma_legacy_models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""enforce_thing_fk_for_nma_legacy_models
22
33
Revision ID: 76e3ae8b99cb
4-
Revises: c1d2e3f4a5b6
4+
Revises: e123456789ab
55
Create Date: 2026-01-26 11:56:28.744603
66
77
Issue: #363
@@ -17,12 +17,12 @@
1717

1818
from typing import Sequence, Union
1919

20-
from alembic import op
2120
import sqlalchemy as sa
21+
from alembic import op
2222

2323
# revision identifiers, used by Alembic.
2424
revision: str = "76e3ae8b99cb"
25-
down_revision: Union[str, Sequence[str], None] = "c1d2e3f4a5b6"
25+
down_revision: Union[str, Sequence[str], None] = "e123456789ab"
2626
branch_labels: Union[str, Sequence[str], None] = None
2727
depends_on: Union[str, Sequence[str], None] = None
2828

alembic/versions/e123456789ab_add_observation_data_quality.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""add nma_data_quality to observation
22
33
Revision ID: e123456789ab
4-
Revises: b12e3919077e
4+
Revises: f0c9d8e7b6a5
55
Create Date: 2026-02-05 12:00:00.000000
66
77
"""
@@ -13,7 +13,7 @@
1313

1414
# revision identifiers, used by Alembic.
1515
revision: str = "e123456789ab"
16-
down_revision: Union[str, Sequence[str], None] = "b12e3919077e"
16+
down_revision: Union[str, Sequence[str], None] = "f0c9d8e7b6a5"
1717
branch_labels: Union[str, Sequence[str], None] = None
1818
depends_on: Union[str, Sequence[str], None] = None
1919

0 commit comments

Comments
 (0)