def _transmogrify_settling_ponds(now_app, now_sub, mms_now_sub): pondsreclamation = mms_now_sub.pondsreclamation or now_sub.pondsreclamation pondsreclamationcost = mms_now_sub.pondsreclamationcost or now_sub.pondsreclamationcost pondstotaldistarea = now_sub.pondstotaldistarea pondsexfiltratedtoground = mms_now_sub.pondsexfiltratedtoground or now_sub.pondsexfiltratedtoground pondsrecycled = mms_now_sub.pondsrecycled or now_sub.pondsrecycled pondsdischargedtoenv = mms_now_sub.pondsdischargedtoenv or now_sub.pondsdischargedtoenv if pondsreclamation or pondsreclamationcost or pondstotaldistarea or pondsexfiltratedtoground or pondsrecycled or pondsdischargedtoenv: settling_pond = app_models.SettlingPond( reclamation_description=pondsreclamation, reclamation_cost=pondsreclamationcost, total_disturbed_area=pondstotaldistarea, total_disturbed_area_unit_type_code='HA', is_ponds_exfiltrated=pondsexfiltratedtoground == 'Yes', is_ponds_recycled=pondsrecycled == 'Yes', is_ponds_discharged=pondsdischargedtoenv == 'Yes') proposed_settling_pond = now_sub.proposed_settling_pond for proposed in proposed_settling_pond: proposed_detail = app_models.SettlingPondDetail( activity_type_description=proposed.pondid, water_source_description=proposed.watersource, construction_plan=proposed.constructionmethod, width=proposed.width, length=proposed.length, depth=proposed.depth, disturbed_area=proposed.disturbedarea, timber_volume=proposed.timbervolume) etl_detail = app_models.ETLActivityDetail(settlingpondid=proposed.settlingpondid) proposed_detail._etl_activity_details.append(etl_detail) proposed_xref = app_models.ActivitySummaryDetailXref( summary=settling_pond, detail=proposed_detail, is_existing=False) existing_settling_pond = now_sub.existing_settling_pond for existing in existing_settling_pond: existing_etl = app_models.ETLActivityDetail.query.filter_by( settlingpondid=existing.settlingpondid).first() if existing_etl: existing_detail = existing_etl.activity_detail else: existing_detail = app_models.SettlingPondDetail( activity_type_description=existing.pondid, water_source_description=existing.watersource, construction_plan=existing.constructionmethod, width=existing.width, length=existing.length, depth=existing.depth, disturbed_area=existing.disturbedarea, timber_volume=existing.timbervolume) etl_detail = app_models.ETLActivityDetail(settlingpondid=existing.settlingpondid) existing_detail._etl_activity_details.append(etl_detail) existing_xref = app_models.ActivitySummaryDetailXref( summary=settling_pond, detail=existing_detail, is_existing=True) now_app.settling_pond = settling_pond return
def _transmogrify_placer_operations(now_app, now_sub, mms_now_sub): placerundergroundoperations = now_sub.placerundergroundoperations placerhandoperations = now_sub.placerhandoperations placerreclamationarea = now_sub.placerreclamationarea placerreclamation = mms_now_sub.placerreclamation or now_sub.placerreclamation placerreclamationcost = mms_now_sub.placerreclamationcost or now_sub.placerreclamationcost expaccesstotaldistarea = now_sub.expaccesstotaldistarea if placerundergroundoperations or placerhandoperations or placerreclamationarea or placerreclamation or placerreclamationcost: placer = app_models.PlacerOperation( reclamation_description=placerreclamation, reclamation_cost=placerreclamationcost, total_disturbed_area=placerreclamationarea, total_disturbed_area_unit_type_code='HA', is_underground=placerundergroundoperations == 'Yes', is_hand_operation=placerhandoperations == 'Yes') if (len(mms_now_sub.proposed_placer_activity) > 0): proposed_placer_activity = mms_now_sub.proposed_placer_activity else: proposed_placer_activity = now_sub.proposed_placer_activity for proposed in proposed_placer_activity: proposed_detail = app_models.PlacerOperationDetail( activity_type_description=proposed.type, disturbed_area=proposed.disturbedarea, timber_volume=proposed.timbervolume, width=getattr(proposed, 'width', None), length=getattr(proposed, 'length', None), depth=getattr(proposed, 'depth', None), quantity=proposed.quantity) etl_detail = app_models.ETLActivityDetail(placeractivityid=proposed.placeractivityid) proposed_detail._etl_activity_details.append(etl_detail) proposed_xref = app_models.ActivitySummaryDetailXref( summary=placer, detail=proposed_detail, is_existing=False) if (len(mms_now_sub.existing_placer_activity) > 0): existing_placer_activity = mms_now_sub.existing_placer_activity else: existing_placer_activity = now_sub.existing_placer_activity for existing in existing_placer_activity: existing_etl = app_models.ETLActivityDetail.query.filter_by( placeractivityid=existing.placeractivityid).first() if existing_etl: existing_detail = existing_etl.activity_detail else: existing_detail = app_models.PlacerOperationDetail( activity_type_description=existing.type, disturbed_area=existing.disturbedarea, timber_volume=existing.timbervolume, width=getattr(existing, 'width', None), length=getattr(existing, 'length', None), depth=getattr(existing, 'depth', None), quantity=existing.quantity) etl_detail = app_models.ETLActivityDetail( placeractivityid=existing.placeractivityid) existing_detail._etl_activity_details.append(etl_detail) existing_xref = app_models.ActivitySummaryDetailXref( summary=placer, detail=existing_detail, is_existing=True) for e in now_sub.placer_equip: equipment = _transmogrify_equipment(e) placer.equipment.append(equipment) now_app.placer_operation = placer return