|
53 | 53 | from schemas.well_inventory import WellInventoryRow |
54 | 54 | from services.contact_helper import add_contact |
55 | 55 | from services.exceptions_helper import PydanticStyleException |
56 | | -from services.thing_helper import add_thing, modify_well_descriptor_tables |
| 56 | +from services.thing_helper import add_thing |
57 | 57 | from services.util import transform_srid, convert_ft_to_m |
58 | 58 |
|
59 | 59 | router = APIRouter(prefix="/well-inventory-csv") |
@@ -93,34 +93,33 @@ def _make_contact(model: WellInventoryRow, well: Thing, idx) -> dict: |
93 | 93 | addresses = [] |
94 | 94 | name = getattr(model, f"contact_{idx}_name") |
95 | 95 | if name: |
96 | | - for j in (1, 2): |
97 | | - for i in (1, 2): |
98 | | - email = getattr(model, f"contact_{j}_email_{i}") |
99 | | - etype = getattr(model, f"contact_{j}_email_{i}_type") |
100 | | - if email and etype: |
101 | | - emails.append({"email": email, "email_type": etype}) |
102 | | - phone = getattr(model, f"contact_{j}_phone_{i}") |
103 | | - ptype = getattr(model, f"contact_{j}_phone_{i}_type") |
104 | | - if phone and ptype: |
105 | | - phones.append({"phone_number": phone, "phone_type": ptype}) |
106 | | - |
107 | | - address_line_1 = getattr(model, f"contact_{j}_address_{i}_line_1") |
108 | | - address_line_2 = getattr(model, f"contact_{j}_address_{i}_line_2") |
109 | | - city = getattr(model, f"contact_{j}_address_{i}_city") |
110 | | - state = getattr(model, f"contact_{j}_address_{i}_state") |
111 | | - postal_code = getattr(model, f"contact_{j}_address_{i}_postal_code") |
112 | | - address_type = getattr(model, f"contact_{j}_address_{i}_type") |
113 | | - if address_line_1 and city and state and postal_code and address_type: |
114 | | - addresses.append( |
115 | | - { |
116 | | - "address_line_1": address_line_1, |
117 | | - "address_line_2": address_line_2, |
118 | | - "city": city, |
119 | | - "state": state, |
120 | | - "postal_code": postal_code, |
121 | | - "address_type": address_type, |
122 | | - } |
123 | | - ) |
| 96 | + for i in (1, 2): |
| 97 | + email = getattr(model, f"contact_{idx}_email_{i}") |
| 98 | + etype = getattr(model, f"contact_{idx}_email_{i}_type") |
| 99 | + if email and etype: |
| 100 | + emails.append({"email": email, "email_type": etype}) |
| 101 | + phone = getattr(model, f"contact_{idx}_phone_{i}") |
| 102 | + ptype = getattr(model, f"contact_{idx}_phone_{i}_type") |
| 103 | + if phone and ptype: |
| 104 | + phones.append({"phone_number": phone, "phone_type": ptype}) |
| 105 | + |
| 106 | + address_line_1 = getattr(model, f"contact_{idx}_address_{i}_line_1") |
| 107 | + address_line_2 = getattr(model, f"contact_{idx}_address_{i}_line_2") |
| 108 | + city = getattr(model, f"contact_{idx}_address_{i}_city") |
| 109 | + state = getattr(model, f"contact_{idx}_address_{i}_state") |
| 110 | + postal_code = getattr(model, f"contact_{idx}_address_{i}_postal_code") |
| 111 | + address_type = getattr(model, f"contact_{idx}_address_{i}_type") |
| 112 | + if address_line_1 and city and state and postal_code and address_type: |
| 113 | + addresses.append( |
| 114 | + { |
| 115 | + "address_line_1": address_line_1, |
| 116 | + "address_line_2": address_line_2, |
| 117 | + "city": city, |
| 118 | + "state": state, |
| 119 | + "postal_code": postal_code, |
| 120 | + "address_type": address_type, |
| 121 | + } |
| 122 | + ) |
124 | 123 |
|
125 | 124 | return { |
126 | 125 | "thing_id": well.id, |
@@ -439,7 +438,6 @@ def _add_csv_row(session: Session, group: Group, model: WellInventoryRow, user) |
439 | 438 | well = add_thing( |
440 | 439 | session=session, data=well_data, user=user, thing_type="water well" |
441 | 440 | ) |
442 | | - modify_well_descriptor_tables(session, well, data, user) |
443 | 441 | session.refresh(well) |
444 | 442 |
|
445 | 443 | # add field event |
|
0 commit comments