diff --git a/bims/enums/ecosystem_type.py b/bims/enums/ecosystem_type.py
index 90765e838..28e2344ee 100644
--- a/bims/enums/ecosystem_type.py
+++ b/bims/enums/ecosystem_type.py
@@ -7,3 +7,13 @@
(ECOSYSTEM_WETLAND, ECOSYSTEM_WETLAND),
(ECOSYSTEM_OPEN_WATERBODY, ECOSYSTEM_OPEN_WATERBODY)
)
+
+HYDROPERIOD_INUNDATED = 'Inundated'
+HYDROPERIOD_SATURATED = 'Saturated at surface'
+HYDROPERIOD_DRY = 'Dry at surface'
+
+HYDROPERIOD_CHOICES = (
+ (HYDROPERIOD_INUNDATED, HYDROPERIOD_INUNDATED),
+ (HYDROPERIOD_SATURATED, HYDROPERIOD_SATURATED),
+ (HYDROPERIOD_DRY, HYDROPERIOD_DRY),
+)
diff --git a/bims/migrations/0345_biologicalcollectionrecord_hydroperiod_and_more.py b/bims/migrations/0345_biologicalcollectionrecord_hydroperiod_and_more.py
new file mode 100644
index 000000000..9b6d3435e
--- /dev/null
+++ b/bims/migrations/0345_biologicalcollectionrecord_hydroperiod_and_more.py
@@ -0,0 +1,25 @@
+# Generated by Django 4.1.10 on 2023-08-24 07:37
+
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('bims', '0344_alter_bimsdocument_authors_notification'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='biologicalcollectionrecord',
+ name='hydroperiod',
+ field=models.CharField(blank=True, choices=[('Inundated', 'Inundated'), ('Saturated at surface', 'Saturated at surface'), ('Dry at surface', 'Dry at surface')], default='', max_length=255),
+ ),
+ migrations.AlterField(
+ model_name='notification',
+ name='name',
+ field=models.CharField(choices=[('SITE_VISIT_VALIDATION', 'Site visit is ready to be validated'), ('SITE_VALIDATION', 'Site is ready to be validated'), ('DOWNLOAD_REQUEST', 'Download request notification'), ('ACCOUNT_CREATED', 'Account created email notification'), ('SASS_CREATED', 'SASS created email notification'), ('NEW_TAXONOMY', 'New taxonomy email notification')], max_length=255, unique=True),
+ ),
+ ]
diff --git a/bims/migrations/0346_alter_bimsdocument_authors_and_more.py b/bims/migrations/0346_alter_bimsdocument_authors_and_more.py
new file mode 100644
index 000000000..7706d2194
--- /dev/null
+++ b/bims/migrations/0346_alter_bimsdocument_authors_and_more.py
@@ -0,0 +1,20 @@
+# Generated by Django 4.1.10 on 2023-08-24 08:12
+
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('bims', '0345_biologicalcollectionrecord_hydroperiod_and_more'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='biologicalcollectionrecord',
+ name='hydroperiod',
+ field=models.CharField(blank=True, choices=[('Inundated', 'Inundated'), ('Saturated at surface', 'Saturated at surface'), ('Dry at surface', 'Dry at surface')], default='', max_length=255, null=True),
+ ),
+ ]
diff --git a/bims/models/biological_collection_record.py b/bims/models/biological_collection_record.py
index 2f0d4a364..4a352c39e 100644
--- a/bims/models/biological_collection_record.py
+++ b/bims/models/biological_collection_record.py
@@ -20,7 +20,9 @@
from bims.enums.taxonomic_group_category import TaxonomicGroupCategory
from bims.models.bims_document import BimsDocument
from bims.models.survey import Survey
-from bims.enums.ecosystem_type import ECOSYSTEM_TYPE_CHOICES
+from bims.enums.ecosystem_type import (
+ ECOSYSTEM_TYPE_CHOICES, HYDROPERIOD_CHOICES
+)
from td_biblio.models import Entry
@@ -268,6 +270,14 @@ class BiologicalCollectionRecord(AbstractValidation):
blank=True
)
+ hydroperiod = models.CharField(
+ max_length=255,
+ choices=HYDROPERIOD_CHOICES,
+ blank=True,
+ null=True,
+ default=''
+ )
+
biotope = models.ForeignKey(
'bims.Biotope',
null=True,
diff --git a/bims/templates/collections_form_page.html b/bims/templates/collections_form_page.html
index 44300b032..8e498fb84 100644
--- a/bims/templates/collections_form_page.html
+++ b/bims/templates/collections_form_page.html
@@ -167,10 +167,25 @@
Add {{ taxon_group_name }} data for site {% if location_site_code %}{{ locat
value="{{ user.id }}">
+ {% if location_site.ecosystem_type == 'Wetland' %}
+
+ {% endif %}
+ {% if object.site.ecosystem_type == 'Wetland' %}
+
+ {% endif %}
+ {% if object.site.ecosystem_type == 'Wetland' %}
+
+ {% endif %}
Broad
- Biotope
+ Biotope / Habitat
diff --git a/bims/views/collections_form.py b/bims/views/collections_form.py
index 7fbf5416e..133eaa253 100644
--- a/bims/views/collections_form.py
+++ b/bims/views/collections_form.py
@@ -34,6 +34,7 @@
from bims.enums.taxonomic_rank import TaxonomicRank
from bims.views.mixin.session_form.mixin import SessionFormMixin
from bims.models.algae_data import AlgaeData
+from bims.enums.ecosystem_type import HYDROPERIOD_CHOICES
logger = logging.getLogger('bims')
@@ -46,6 +47,7 @@ def add_survey_occurrences(self, post_data, site_image = None) -> Survey:
date_string = post_data.get('date', None)
owner_id = post_data.get('owner_id', '').strip()
biotope_id = post_data.get('biotope', None)
+ hydroperiod = post_data.get('hydroperiod', None)
specific_biotope_id = post_data.get('specific_biotope', None)
substratum_id = post_data.get('substratum', None)
sampling_method_id = post_data.get('sampling_method', None)
@@ -259,7 +261,8 @@ def add_survey_occurrences(self, post_data, site_image = None) -> Survey:
abundance_type=abundance_type,
survey=self.survey,
record_type=record_type,
- source_reference=source_reference
+ source_reference=source_reference,
+ hydroperiod=hydroperiod
)
)
collection_record_ids.append(collection_record.id)
@@ -362,6 +365,7 @@ def get_context_data(self, **kwargs):
context = super(CollectionFormView, self).get_context_data(**kwargs)
if not self.location_site:
return context
+ context['location_site'] = self.location_site
context['geoserver_public_location'] = get_key(
'GEOSERVER_PUBLIC_LOCATION')
context['location_site_name'] = self.location_site.name
@@ -369,6 +373,7 @@ def get_context_data(self, **kwargs):
context['location_site_lat'] = self.location_site.get_centroid().y
context['location_site_long'] = self.location_site.get_centroid().x
context['site_id'] = self.location_site.id
+ context['hydroperiod_choices'] = HYDROPERIOD_CHOICES
try:
context['bing_key'] = BaseMapLayer.objects.get(source_type='bing').key
diff --git a/bims/views/site_visit/base.py b/bims/views/site_visit/base.py
index a3d5f23c9..2f86234b4 100644
--- a/bims/views/site_visit/base.py
+++ b/bims/views/site_visit/base.py
@@ -8,6 +8,7 @@
from bims.models.chemical_record import ChemicalRecord
from bims.models.chem import Chem
from bims.models.basemap_layer import BaseMapLayer
+from bims.enums.ecosystem_type import HYDROPERIOD_CHOICES
class SiteVisitBaseView(View):
@@ -19,6 +20,12 @@ def taxon_group(self):
return self.collection_records[0].module_group
return None
+ def hydroperiod(self):
+ """Get hydroperiod data from one of the occurrences"""
+ if self.collection_records.exists():
+ return self.collection_records.first().hydroperiod
+ return ''
+
def owner(self):
"""Get owner of the site visit"""
if self.object.owner:
@@ -157,6 +164,8 @@ def get_context_data(self, **kwargs):
context['sampling_effort_value'] = sampling_effort_value
context['sampling_effort_unit'] = sampling_effort_unit
context['abundance_type'] = self.abundance_type()
+ context['hydroperiod_choices'] = HYDROPERIOD_CHOICES
+ context['hydroperiod'] = self.hydroperiod()
context['broad_biotope_list'] = (
Biotope.objects.broad_biotope_list(
diff --git a/bims/views/site_visit/update.py b/bims/views/site_visit/update.py
index 6e87454b8..4e16de4de 100644
--- a/bims/views/site_visit/update.py
+++ b/bims/views/site_visit/update.py
@@ -91,6 +91,7 @@ def form_valid(self, form):
taxa_id_list = form.data.get('taxa-id-list', '')
owner_id = form.data.get('owner_id', None)
collector_id = form.data.get('collector_id', None)
+ hydroperiod = form.data.get('hydroperiod', '')
owner = None
collector_user = None
if owner_id:
@@ -136,7 +137,8 @@ def form_valid(self, form):
sampling_method_id=form.data.get('sampling_method', None),
abundance_type=form.data.get('abundance_type', ''),
owner=owner,
- collector_user=collector_user
+ collector_user=collector_user,
+ hydroperiod=hydroperiod
)
# Remove deleted collection records
@@ -199,7 +201,8 @@ def form_valid(self, form):
survey=self.object,
record_type=self._form_data(
form, 'record_type', ''
- )
+ ),
+ hydroperiod=hydroperiod
)
)
if status: