Esempio n. 1
0
    def get(self, request):
        options = {}

        province_codes = ProvinceStateCodeSerializer(
            instance=ProvinceStateCode.objects.all(), many=True)
        activity_codes = WellActivityCodeSerializer(
            instance=WellActivityCode.objects.all(), many=True)
        well_class_codes = WellClassCodeSerializer(
            instance=WellClassCode.objects.prefetch_related(
                "wellsubclasscode_set"),
            many=True)
        intended_water_use_codes = IntendedWaterUseCodeSerializer(
            instance=IntendedWaterUseCode.objects.all(), many=True)
        casing_codes = CasingCodeSerializer(instance=CasingCode.objects.all(),
                                            many=True)
        casing_material = CasingMaterialSerializer(
            instance=CasingMaterialCode.objects.all(), many=True)
        decommission_materials = DecommissionMaterialCodeSerializer(
            instance=DecommissionMaterialCode.objects.all(), many=True)
        decommission_methods = DecommissionMethodCodeSerializer(
            instance=DecommissionMethodCode.objects.all(), many=True)
        filter_pack_material = FilterPackMaterialCodeSerializer(
            instance=FilterPackMaterialCode.objects.all(), many=True)
        filter_pack_material_size = FilterPackMaterialSizeCodeSerializer(
            instance=FilterPackMaterialSizeCode.objects.all(), many=True)
        land_district_codes = LandDistrictSerializer(
            instance=LandDistrictCode.objects.all(), many=True)
        liner_material_codes = LinerMaterialCodeSerializer(
            instance=LinerMaterialCode.objects.all(), many=True)
        ground_elevation_method_codes = GroundElevationMethodCodeSerializer(
            instance=GroundElevationMethodCode.objects.all(), many=True)
        drilling_method_codes = DrillingMethodCodeSerializer(
            instance=DrillingMethodCode.objects.all(), many=True)
        surface_seal_method_codes = SurfaceSealMethodCodeSerializer(
            instance=SurfaceSealMethodCode.objects.all(), many=True)
        surface_seal_material_codes = SurfaceSealMaterialCodeSerializer(
            instance=SurfaceSealMaterialCode.objects.all(), many=True)
        surficial_material_codes = SurficialMaterialCodeSerializer(
            instance=SurficialMaterialCode.objects.all(), many=True)
        screen_intake_methods = ScreenIntakeMethodSerializer(
            instance=ScreenIntakeMethodCode.objects.all(), many=True)
        screen_types = ScreenTypeCodeSerializer(
            instance=ScreenTypeCode.objects.all(), many=True)
        screen_materials = ScreenMaterialCodeSerializer(
            instance=ScreenMaterialCode.objects.all(), many=True)
        screen_openings = ScreenOpeningCodeSerializer(
            instance=ScreenOpeningCode.objects.all(), many=True)
        screen_bottoms = ScreenBottomCodeSerializer(
            instance=ScreenBottomCode.objects.all(), many=True)
        screen_assemblies = ScreenAssemblyTypeCodeSerializer(
            instance=ScreenAssemblyTypeCode.objects.all(), many=True)
        development_methods = DevelopmentMethodCodeSerializer(
            instance=DevelopmentMethodCode.objects.all(), many=True)
        yield_estimation_methods = YieldEstimationMethodCodeSerializer(
            instance=YieldEstimationMethodCode.objects.all(), many=True)
        water_quality_characteristics = WaterQualityCharacteristicSerializer(
            instance=WaterQualityCharacteristic.objects.all(), many=True)
        water_quality_colours = WaterQualityColourSerializer(
            instance=WaterQualityColour.objects.all(), many=True)
        well_status_codes = WellStatusCodeSerializer(
            instance=WellStatusCode.objects.all(), many=True)
        coordinate_acquisition_codes = CoordinateAcquisitionCodeSerializer(
            instance=CoordinateAcquisitionCode.objects.all(), many=True)

        root = urljoin('/', app_root, 'api/v1/')
        for item in activity_codes.data:
            if item['code'] not in ('LEGACY'):
                item['path'] = reverse(item['code'])[len(root):]

        options["province_codes"] = province_codes.data
        options["activity_types"] = activity_codes.data
        options[
            "coordinate_acquisition_codes"] = coordinate_acquisition_codes.data
        options["well_classes"] = well_class_codes.data
        options["intended_water_uses"] = intended_water_use_codes.data
        options["casing_codes"] = casing_codes.data
        options["casing_materials"] = casing_material.data
        options["decommission_materials"] = decommission_materials.data
        options["decommission_methods"] = decommission_methods.data
        options["filter_pack_material"] = filter_pack_material.data
        options["filter_pack_material_size"] = filter_pack_material_size.data
        options["land_district_codes"] = land_district_codes.data
        options["liner_material_codes"] = liner_material_codes.data
        options["screen_intake_methods"] = screen_intake_methods.data
        options[
            "ground_elevation_methods"] = ground_elevation_method_codes.data
        options["drilling_methods"] = drilling_method_codes.data
        options["surface_seal_methods"] = surface_seal_method_codes.data
        options["surface_seal_materials"] = surface_seal_material_codes.data
        options["surficial_material_codes"] = surficial_material_codes.data
        options["screen_types"] = screen_types.data
        options["screen_materials"] = screen_materials.data
        options["screen_openings"] = screen_openings.data
        options["screen_bottoms"] = screen_bottoms.data
        options["screen_assemblies"] = screen_assemblies.data
        options["development_methods"] = development_methods.data
        options["yield_estimation_methods"] = yield_estimation_methods.data
        options[
            "water_quality_characteristics"] = water_quality_characteristics.data
        options["water_quality_colours"] = water_quality_colours.data
        options["well_status_codes"] = well_status_codes.data

        return Response(options)
Esempio n. 2
0
    def get(self, request, **kwargs):
        options = {}

        province_codes = ProvinceStateCodeSerializer(
            instance=ProvinceStateCode.objects.all(), many=True)
        activity_codes = WellActivityCodeSerializer(
            instance=WellActivityCode.objects.all(), many=True)
        well_class_codes = WellClassCodeSerializer(
            instance=WellClassCode.objects.prefetch_related(
                "wellsubclasscode_set"),
            many=True)
        intended_water_use_codes = IntendedWaterUseCodeSerializer(
            instance=IntendedWaterUseCode.objects.all(), many=True)
        casing_codes = CasingCodeSerializer(instance=CasingCode.objects.all(),
                                            many=True)
        casing_material = CasingMaterialSerializer(
            instance=CasingMaterialCode.objects.all(), many=True)
        decommission_materials = DecommissionMaterialCodeSerializer(
            instance=DecommissionMaterialCode.objects.all(), many=True)
        decommission_methods = DecommissionMethodCodeSerializer(
            instance=DecommissionMethodCode.objects.all(), many=True)
        well_disinfected_codes = WellDisinfectedCodeSerializer(
            instance=WellDisinfectedCode.objects.all(), many=True)
        well_orientation_codes = WellOrientationCodeSerializer(
            instance=WellOrientationCode.objects.all(), many=True)
        boundary_effect_codes = BoundaryEffectCodeSerializer(
            instance=BoundaryEffectCode.objects.all(), many=True)
        drive_shoe_codes = DriveShoeCodeSerializer(
            instance=DriveShoeCode.objects.all(), many=True)
        filter_pack_material = FilterPackMaterialCodeSerializer(
            instance=FilterPackMaterialCode.objects.all(), many=True)
        filter_pack_material_size = FilterPackMaterialSizeCodeSerializer(
            instance=FilterPackMaterialSizeCode.objects.all(), many=True)
        land_district_codes = LandDistrictSerializer(
            instance=LandDistrictCode.objects.all(), many=True)
        liner_material_codes = LinerMaterialCodeSerializer(
            instance=LinerMaterialCode.objects.all(), many=True)
        ground_elevation_method_codes = GroundElevationMethodCodeSerializer(
            instance=GroundElevationMethodCode.objects.all(), many=True)
        drilling_method_codes = DrillingMethodCodeSerializer(
            instance=DrillingMethodCode.objects.all(), many=True)
        surface_seal_method_codes = SurfaceSealMethodCodeSerializer(
            instance=SurfaceSealMethodCode.objects.all(), many=True)
        surface_seal_material_codes = SurfaceSealMaterialCodeSerializer(
            instance=SurfaceSealMaterialCode.objects.all(), many=True)
        surficial_material_codes = SurficialMaterialCodeSerializer(
            instance=SurficialMaterialCode.objects.all(), many=True)
        screen_intake_methods = ScreenIntakeMethodSerializer(
            instance=ScreenIntakeMethodCode.objects.all(), many=True)
        screen_types = ScreenTypeCodeSerializer(
            instance=ScreenTypeCode.objects.all(), many=True)
        screen_materials = ScreenMaterialCodeSerializer(
            instance=ScreenMaterialCode.objects.all(), many=True)
        screen_openings = ScreenOpeningCodeSerializer(
            instance=ScreenOpeningCode.objects.all(), many=True)
        screen_bottoms = ScreenBottomCodeSerializer(
            instance=ScreenBottomCode.objects.all(), many=True)
        screen_assemblies = ScreenAssemblyTypeCodeSerializer(
            instance=ScreenAssemblyTypeCode.objects.all(), many=True)
        development_methods = DevelopmentMethodCodeSerializer(
            instance=DevelopmentMethodCode.objects.all(), many=True)
        yield_estimation_methods = YieldEstimationMethodCodeSerializer(
            instance=YieldEstimationMethodCode.objects.all(), many=True)
        water_quality_characteristics = WaterQualityCharacteristicSerializer(
            instance=WaterQualityCharacteristic.objects.all(), many=True)
        water_quality_colours = WaterQualityColourSerializer(
            instance=WaterQualityColour.objects.all(), many=True)
        well_status_codes = WellStatusCodeSerializer(
            instance=WellStatusCode.objects.all(), many=True)
        well_publication_status_codes = WellPublicationStatusCodeSerializer(
            instance=WellPublicationStatusCode.objects.all(), many=True)
        coordinate_acquisition_codes = CoordinateAcquisitionCodeSerializer(
            instance=CoordinateAcquisitionCode.objects.all(), many=True)
        observation_well_status = ObservationWellStatusCodeSerializer(
            instance=ObsWellStatusCode.objects.all(), many=True)
        aquifer_lithology = AquiferLithologySerializer(
            instance=AquiferLithologyCode.objects.all(), many=True)

        lithology_hardness = LithologyHardnessSerializer(
            instance=LithologyHardnessCode.objects.all(), many=True)
        lithology_colours = LithologyColourSerializer(
            instance=LithologyColourCode.objects.all(), many=True)
        lithology_materials = LithologyMaterialSerializer(
            instance=LithologyMaterialCode.objects.all(), many=True)
        lithology_moisture = LithologyMoistureSerializer(
            instance=LithologyMoistureCode.objects.all(), many=True)
        lithology_descriptors = LithologyDescriptionCodeSerializer(
            instance=LithologyDescriptionCode.objects.all(), many=True)
        licenced_status_codes = LicencedStatusCodeSerializer(
            instance=LicencedStatusCode.objects.all(), many=True)

        root = urljoin('/', app_root, 'api/v2/')
        for item in activity_codes.data:
            if item['code'] not in ('LEGACY'):
                item['path'] = reverse(item['code'],
                                       request=request)[len(root):]

        options["province_codes"] = province_codes.data
        options["activity_types"] = activity_codes.data
        options[
            "coordinate_acquisition_codes"] = coordinate_acquisition_codes.data
        options["well_classes"] = well_class_codes.data
        options["intended_water_uses"] = intended_water_use_codes.data
        options["casing_codes"] = casing_codes.data
        options["casing_materials"] = casing_material.data
        options["decommission_materials"] = decommission_materials.data
        options["decommission_methods"] = decommission_methods.data
        options["well_disinfected_codes"] = well_disinfected_codes.data
        options["well_orientation_codes"] = well_orientation_codes.data
        options["boundary_effect_codes"] = boundary_effect_codes.data
        options["drive_shoe_codes"] = drive_shoe_codes.data
        options["filter_pack_material"] = filter_pack_material.data
        options["filter_pack_material_size"] = filter_pack_material_size.data
        options["land_district_codes"] = land_district_codes.data
        options["liner_material_codes"] = liner_material_codes.data
        options["screen_intake_methods"] = screen_intake_methods.data
        options[
            "ground_elevation_methods"] = ground_elevation_method_codes.data
        options["drilling_methods"] = drilling_method_codes.data
        options["surface_seal_methods"] = surface_seal_method_codes.data
        options["surface_seal_materials"] = surface_seal_material_codes.data
        options["surficial_material_codes"] = surficial_material_codes.data
        options["screen_types"] = screen_types.data
        options["screen_materials"] = screen_materials.data
        options["screen_openings"] = screen_openings.data
        options["screen_bottoms"] = screen_bottoms.data
        options["screen_assemblies"] = screen_assemblies.data
        options["development_methods"] = development_methods.data
        options["yield_estimation_methods"] = yield_estimation_methods.data
        options[
            "water_quality_characteristics"] = water_quality_characteristics.data
        options["water_quality_colours"] = water_quality_colours.data
        options["aquifer_lithology_codes"] = aquifer_lithology.data
        options["lithology_hardness_codes"] = lithology_hardness.data
        options["lithology_colours"] = lithology_colours.data
        options["lithology_materials"] = lithology_materials.data
        options["lithology_moisture_codes"] = lithology_moisture.data
        options["lithology_descriptors"] = lithology_descriptors.data
        options["well_status_codes"] = well_status_codes.data
        options[
            "well_publication_status_codes"] = well_publication_status_codes.data
        options["observation_well_status"] = observation_well_status.data
        options["licenced_status_codes"] = licenced_status_codes.data

        return Response(options)