From d53e5a87c0ee6282ebaedb43ab96f0c31dbe00df Mon Sep 17 00:00:00 2001 From: Luna Morris <127158867+lunamoonmoon@users.noreply.github.com> Date: Wed, 20 Nov 2024 10:44:30 -0800 Subject: [PATCH] feat(frontend): #2274 Private Toggle for Aquifer Parameters on Well Details Page (#178) Co-authored-by: raarielgrace --- .../migrations/0150_auto_20241108_2357.py | 123 ++++++++++++++++++ backend/wells/models.py | 5 + backend/wells/serializers.py | 3 + backend/wells/views.py | 8 ++ frontend/src/common/constants.js | 1 + .../SubmissionForm/AquiferParameters.vue | 4 + frontend/src/wells/views/WellDetail.vue | 8 +- 7 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 backend/wells/migrations/0150_auto_20241108_2357.py diff --git a/backend/wells/migrations/0150_auto_20241108_2357.py b/backend/wells/migrations/0150_auto_20241108_2357.py new file mode 100644 index 000000000..0c38f9dfd --- /dev/null +++ b/backend/wells/migrations/0150_auto_20241108_2357.py @@ -0,0 +1,123 @@ +# Generated by Django 3.2.4 on 2024-11-08 23:57 + +from django.db import migrations, models +import django.db.models.deletion +import uuid + + +class Migration(migrations.Migration): + + dependencies = [ + ('submissions', '0001_initial'), + ('wells', '0149_add_well_status_to_view'), + ] + + operations = [ + migrations.CreateModel( + name='WellLicence', + fields=[ + ('id', models.IntegerField(primary_key=True, serialize=False)), + ('well_id', models.IntegerField()), + ('waterrightslicence_id', models.IntegerField()), + ], + options={ + 'db_table': 'well_licences', + 'managed': False, + }, + ), + migrations.AddField( + model_name='aquiferparameters', + name='private', + field=models.BooleanField(choices=[(False, 'No'), (True, 'Yes')], default=False), + ), + migrations.AlterField( + model_name='activitysubmission', + name='artesian_conditions', + field=models.BooleanField(null=True, verbose_name='Artesian Conditions'), + ), + migrations.AlterField( + model_name='activitysubmission', + name='artesian_pressure', + field=models.DecimalField(blank=True, decimal_places=2, max_digits=7, null=True, verbose_name='Artesian Pressure'), + ), + migrations.AlterField( + model_name='activitysubmission', + name='artesian_pressure_head', + field=models.DecimalField(blank=True, decimal_places=2, max_digits=7, null=True, verbose_name='Artesian Pressure head'), + ), + migrations.AlterField( + model_name='activitysubmission', + name='well_activity_type', + field=models.ForeignKey(db_column='well_activity_code', null=True, on_delete=django.db.models.deletion.PROTECT, to='submissions.wellactivitycode', verbose_name='Type of Work'), + ), + migrations.AlterField( + model_name='activitysubmission', + name='well_orientation', + field=models.BooleanField(choices=[(True, 'vertical'), (False, 'horizontal')], null=True, verbose_name='Orientation of Well'), + ), + migrations.AlterField( + model_name='activitysubmission', + name='well_publication_status', + field=models.ForeignKey(db_column='well_publication_status_code', default='Published', null=True, on_delete=django.db.models.deletion.PROTECT, to='wells.wellpublicationstatuscode', verbose_name='Well Publication Status'), + ), + migrations.AlterField( + model_name='aquiferparameters', + name='analysis_method', + field=models.ForeignKey(blank=True, db_column='analysis_method_code', null=True, on_delete=django.db.models.deletion.PROTECT, to='wells.analysismethodcode', verbose_name='Analysis Method'), + ), + migrations.AlterField( + model_name='aquiferparameters', + name='aquifer_parameters_guid', + field=models.UUIDField(default=uuid.uuid4, editable=False), + ), + migrations.AlterField( + model_name='aquiferparameters', + name='pumping_test_description', + field=models.ForeignKey(blank=True, db_column='pumping_test_description_code', null=True, on_delete=django.db.models.deletion.PROTECT, to='wells.pumpingtestdescriptioncode', verbose_name='Testing Type'), + ), + migrations.AlterField( + model_name='fieldsprovided', + name='alternative_specs_submitted', + field=models.BooleanField(default=False), + ), + migrations.AlterField( + model_name='fieldsprovided', + name='hydro_fracturing_performed', + field=models.BooleanField(default=False), + ), + migrations.AlterField( + model_name='well', + name='artesian_conditions', + field=models.BooleanField(default=False, verbose_name='Artesian Conditions'), + ), + migrations.AlterField( + model_name='well', + name='artesian_pressure_head', + field=models.DecimalField(blank=True, decimal_places=2, max_digits=7, null=True, verbose_name='Artesian Pressure head'), + ), + migrations.AlterField( + model_name='well', + name='cross_referenced_by', + field=models.CharField(blank=True, max_length=100, null=True, verbose_name='Internal team member who cross referenced well.'), + ), + migrations.AlterField( + model_name='well', + name='cross_referenced_date', + field=models.DateTimeField(null=True, verbose_name='Cross Referenced Date'), + ), + migrations.AlterField( + model_name='well', + name='distance_to_pid', + field=models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True, verbose_name='Distance to PID'), + ), + migrations.AlterField( + model_name='well', + name='geocode_distance', + field=models.DecimalField(blank=True, decimal_places=2, max_digits=12, null=True, verbose_name='Geocode Distance'), + ), + migrations.AlterField( + model_name='well', + name='natural_resource_region', + field=models.CharField(blank=True, max_length=250, null=True, verbose_name='Natural Resource Region'), + ), + ] diff --git a/backend/wells/models.py b/backend/wells/models.py index 12770ce37..6d66b4b0e 100644 --- a/backend/wells/models.py +++ b/backend/wells/models.py @@ -2533,6 +2533,10 @@ class AquiferParameters(AuditModel): db_comment='Valid codes for the boundaries observed in ' 'pumping test analysis. i.e. CH, NF.') + private = models.BooleanField( + default=False, choices=((False, 'No'), (True, 'Yes')) + ) + storativity = models.DecimalField( max_digits=8, decimal_places=7, blank=True, null=True, verbose_name='Storativity') @@ -2574,6 +2578,7 @@ class Meta: "pumping_test_description_code":"Identification of the testing method (e.g.basic pumping test, pumping test with monitoring wells, single-well-response/slug test, constant head).", "test_duration":"The duration of the hydraulic testing period. For consistency, do not include the recovery period.", "boundary_effect_code":"Valid codes for the boundaries observed in pumping test analysis. i.e. CH, NF.", + "private":"If a hydrogeological consultant has not provided permission with a signed data sharing agreement to share their interpretations publicly.", "storativity":"Storativity estimated from hydraulic testing (dimensionless).", "transmissivity":"Transmissivity estimated from hydraulic testing.", "hydraulic_conductivity":"Hydraulic conductivity estimated from hydraulic testing in metres per second.", diff --git a/backend/wells/serializers.py b/backend/wells/serializers.py index 0bf8c20c0..0d06c90fc 100644 --- a/backend/wells/serializers.py +++ b/backend/wells/serializers.py @@ -196,6 +196,7 @@ class Meta: 'pumping_test_description', 'test_duration', 'boundary_effect', + 'private', 'storativity', 'transmissivity', 'hydraulic_conductivity', @@ -217,6 +218,7 @@ class Meta: 'pumping_test_description', 'test_duration', 'boundary_effect', + 'private', 'storativity', 'transmissivity', 'hydraulic_conductivity', @@ -236,6 +238,7 @@ class Meta: 'pumping_test_description', 'test_duration', 'boundary_effect', + 'private', 'storativity', 'transmissivity', 'hydraulic_conductivity', diff --git a/backend/wells/views.py b/backend/wells/views.py index 846e5f762..6a48c0c94 100644 --- a/backend/wells/views.py +++ b/backend/wells/views.py @@ -126,6 +126,14 @@ def get(self, request, *args, **kwargs): response = super().get(self, request, *args, **kwargs) if not(request.user.groups.filter(name=WELLS_VIEWER_ROLE).exists()): response.data.pop('internal_comments') + + """ Removes aquifer paramaters marked private for users without the edit role """ + if not request.user.groups.filter(name=WELLS_EDIT_ROLE).exists(): + aquifer_params = response.data.get('aquifer_parameters_set', []) + response.data['aquifer_parameters_set'] = [ + param for param in aquifer_params if not param.get('private', False) + ] + return response diff --git a/frontend/src/common/constants.js b/frontend/src/common/constants.js index 7f5cdb17b..b009f8907 100644 --- a/frontend/src/common/constants.js +++ b/frontend/src/common/constants.js @@ -51,6 +51,7 @@ export const TOOLTIP_TEXT = { pumping_test_information: { pumping_test: 'Describes the type of test (step, recovery, constant rate pumping test) and type of well (pumping well, observation well).', boundary_effect: 'Describe the specific conditions that are to be imposed at the boundaries of a groundwater flow region such as a recharge (river, lake) boundary or a barrier (impermeable rock) boundary where the assumption that the aquifer is of infinite extent is no longer valid.', + private: 'Information is private if a hydrogeological consultant has not provided permission (a signed data sharing agreement) to share their interpretations publicly.', storativity: 'Storativity (S) is a dimensionless measure of the volume of water that will be discharged from an aquifer per unit area of the aquifer and per unit reduction in hydraulic head.', transmissivity: 'Describes the ability of the aquifer to transmit groundwater throughout its entire saturated thickness, is measured as the rate at which groundwater can flow through an aquifer section of unit width under a unit hydraulic gradient.', hydraulic_conductivity: 'A measure of how easily water can pass through soil or rock.', diff --git a/frontend/src/submissions/components/SubmissionForm/AquiferParameters.vue b/frontend/src/submissions/components/SubmissionForm/AquiferParameters.vue index 21475fe02..952d73b75 100644 --- a/frontend/src/submissions/components/SubmissionForm/AquiferParameters.vue +++ b/frontend/src/submissions/components/SubmissionForm/AquiferParameters.vue @@ -36,6 +36,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); Test Description Test Duration (min) Boundary Effect + This Information is Private @@ -84,6 +85,9 @@ Licensed under the Apache License, Version 2.0 (the "License"); :errors="errors['boundary_effect']" :loaded="fieldsLoaded['boundary_effect']"/> + + + Analysis Method diff --git a/frontend/src/wells/views/WellDetail.vue b/frontend/src/wells/views/WellDetail.vue index 3b6098b5a..8d8c969ab 100644 --- a/frontend/src/wells/views/WellDetail.vue +++ b/frontend/src/wells/views/WellDetail.vue @@ -498,7 +498,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); { key: 'specific_capacity', label: 'Specific Capacity (L/s/m)' }, { key: 'analysis_method', label: 'Analysis Method' }, { key: 'comments', label: 'Comments' }, - { key: 'internal_comments', label: 'Internal Comments' } + ( userRoles.wells.edit ? [{ key: 'private', label: 'Private' }] : []) ]" show-empty> + +