From 90d879bf933cf4544e01b25349a24908c68a0321 Mon Sep 17 00:00:00 2001 From: Upson Date: Thu, 27 Jun 2024 10:13:32 -0300 Subject: [PATCH] added biochem tables to user settings. removed biochem_table from mission --- core/form_mission_settings.py | 4 +-- ...7_remove_mission_biochem_table_and_more.py | 22 +++++++++++++ core/models.py | 4 --- ...nection_bc_discrete_data_edits_and_more.py | 33 +++++++++++++++++++ settingsdb/models.py | 12 +++++-- .../settingsdb/partials/mission_table.html | 2 -- settingsdb/views.py | 7 ++-- 7 files changed, 68 insertions(+), 16 deletions(-) create mode 100644 core/migrations/0007_remove_mission_biochem_table_and_more.py create mode 100644 settingsdb/migrations/0009_bcdatabaseconnection_bc_discrete_data_edits_and_more.py diff --git a/core/form_mission_settings.py b/core/form_mission_settings.py index 3a5b613..b51b678 100644 --- a/core/form_mission_settings.py +++ b/core/form_mission_settings.py @@ -35,7 +35,7 @@ class MissionSettingsForm(forms.ModelForm): class Meta: model = models.Mission - fields = ['name', 'geographic_region', 'mission_descriptor', 'biochem_table', 'data_center', 'lead_scientist', + fields = ['name', 'geographic_region', 'mission_descriptor', 'data_center', 'lead_scientist', 'start_date', 'end_date', 'platform', 'protocol', 'collector_comments', 'data_manager_comments'] def __init__(self, *args, **kwargs): @@ -53,7 +53,6 @@ def __init__(self, *args, **kwargs): self.fields['global_geographic_region'].required = False self.fields['mission_descriptor'].required = False - self.fields['biochem_table'].required = False self.fields['lead_scientist'].required = False self.fields['data_center'].required = False @@ -182,7 +181,6 @@ def __init__(self, *args, **kwargs): ), Row( Column(Field('data_center')), - Column(Field('biochem_table')), ), Row(Field('collector_comments')), Row(Field('data_manager_comments')), diff --git a/core/migrations/0007_remove_mission_biochem_table_and_more.py b/core/migrations/0007_remove_mission_biochem_table_and_more.py new file mode 100644 index 0000000..5fd838f --- /dev/null +++ b/core/migrations/0007_remove_mission_biochem_table_and_more.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2 on 2024-06-27 13:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0006_biochemupload_status'), + ] + + operations = [ + migrations.RemoveField( + model_name='mission', + name='biochem_table', + ), + migrations.AlterField( + model_name='biochemupload', + name='modified_date', + field=models.DateTimeField(auto_now=True, help_text='The last time this sensor/sample was loaded', null=True, verbose_name='Modified Date'), + ), + ] diff --git a/core/models.py b/core/models.py index 080ec92..c683603 100644 --- a/core/models.py +++ b/core/models.py @@ -49,10 +49,6 @@ class Mission(models.Model): data_center = models.ForeignKey(bio_models.BCDataCenter, verbose_name=_("Data Center"), default=20, on_delete=models.DO_NOTHING) - biochem_table = models.CharField(verbose_name=_("Root BioChem Table Name"), max_length=100, null=True, blank=True, - help_text=_("How BioChem staging tables will be named without pre or post fixes. " - "If blank, mission descriptor will be used.")) - # this is provided for convince so the user won't have to re-enter the directory repeatedly. It may differ based # on being 'At-sea' where data is collected or on land where collected data is loaded to BioChem bottle_directory = models.FilePathField(verbose_name=_("BTL Directory"), diff --git a/settingsdb/migrations/0009_bcdatabaseconnection_bc_discrete_data_edits_and_more.py b/settingsdb/migrations/0009_bcdatabaseconnection_bc_discrete_data_edits_and_more.py new file mode 100644 index 0000000..0f1e827 --- /dev/null +++ b/settingsdb/migrations/0009_bcdatabaseconnection_bc_discrete_data_edits_and_more.py @@ -0,0 +1,33 @@ +# Generated by Django 4.2 on 2024-06-27 12:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('settingsdb', '0008_sampletypeconfig_limit_field'), + ] + + operations = [ + migrations.AddField( + model_name='bcdatabaseconnection', + name='bc_discrete_data_edits', + field=models.CharField(default='BCDISCRETEDATAEDITS', max_length=60, verbose_name='BCD Table Name'), + ), + migrations.AddField( + model_name='bcdatabaseconnection', + name='bc_discrete_station_edits', + field=models.CharField(default='BCDISCRETESTATNEDITS', max_length=60, verbose_name='BCD Table Name'), + ), + migrations.AddField( + model_name='bcdatabaseconnection', + name='bc_plankton_data_edits', + field=models.CharField(default='BCPLANKTONDATAEDITS', max_length=60, verbose_name='BCD Table Name'), + ), + migrations.AddField( + model_name='bcdatabaseconnection', + name='bc_plankton_station_edits', + field=models.CharField(default='BCPLANKTONSTATNEDITS', max_length=60, verbose_name='BCD Table Name'), + ), + ] diff --git a/settingsdb/models.py b/settingsdb/models.py index 99b9f85..5ffd13e 100644 --- a/settingsdb/models.py +++ b/settingsdb/models.py @@ -113,6 +113,15 @@ class BcDatabaseConnection(models.Model): uploader = models.CharField(verbose_name=_("Uploader Name"), max_length=20, blank=True, null=True, help_text=_("If not Account Name")) + bc_discrete_data_edits = models.CharField(verbose_name=_("BCD Table Name"), max_length=60, + default='BCDISCRETEDATAEDITS') + bc_discrete_station_edits = models.CharField(verbose_name=_("BCD Table Name"), max_length=60, + default='BCDISCRETESTATNEDITS') + bc_plankton_data_edits = models.CharField(verbose_name=_("BCD Table Name"), max_length=60, + default='BCPLANKTONDATAEDITS') + bc_plankton_station_edits = models.CharField(verbose_name=_("BCD Table Name"), max_length=60, + default='BCPLANKTONSTATNEDITS') + def __str__(self): return f'{self.account_name} - {self.name}' @@ -141,7 +150,6 @@ def connect(self, password): # File configuration should be used by parsers that will create entries for what fields they require class FileConfiguration(models.Model): - file_type = models.CharField(max_length=20) required_field = models.CharField(max_length=50, verbose_name=_("Required Field"), help_text=_("This is a field the parser will require to set DART table values")) @@ -152,7 +160,6 @@ class FileConfiguration(models.Model): class GlobalStation(models.Model): - name = models.CharField(verbose_name=_("Station Name"), max_length=20, unique=True) latitude = models.FloatField(verbose_name=_("Latitude"), blank=True, null=True) @@ -165,7 +172,6 @@ def __str__(self): class GlobalGeographicRegion(models.Model): - name = models.CharField(verbose_name=_("Geographic Region Name"), max_length=100, unique=True) def __str__(self): diff --git a/settingsdb/templates/settingsdb/partials/mission_table.html b/settingsdb/templates/settingsdb/partials/mission_table.html index 85423b3..32081d3 100644 --- a/settingsdb/templates/settingsdb/partials/mission_table.html +++ b/settingsdb/templates/settingsdb/partials/mission_table.html @@ -21,7 +21,6 @@ Name Start Date End Date - Biochem Table {# mission details #} @@ -34,7 +33,6 @@ {{ mission.name }} {% if mission.start_date %}{{ mission.start_date }}{% endif %} {% if mission.end_date %}{{ mission.end_date }}{% endif %} - {{ mission.biochem_table }} {% if mission.requires_migration %} diff --git a/settingsdb/views.py b/settingsdb/views.py index fbdc0b8..cf167af 100644 --- a/settingsdb/views.py +++ b/settingsdb/views.py @@ -103,14 +103,13 @@ def get_mission_dictionary(db_dir): if models.Mission.objects.using(database).exists(): if not utils.is_database_synchronized(database): version = getattr(models.Mission.objects.using(database).first(), 'dart_version', None) - missions[database] = {'name': database, 'biochem_table': '', - 'requires_migration': 'true', 'version': version} + missions[database] = {'name': database, 'requires_migration': 'true', 'version': version} else: mission = models.Mission.objects.using(database).first() missions[database] = mission except Exception as ex: logger.exception(ex) - logger.error(_("Cound not open database, it appears to be corrupted") + " : " + database) + logger.error(_("Could not open database, it appears to be corrupted") + " : " + database) for connection in connections.all(): if connection.alias != 'default': @@ -151,7 +150,7 @@ class MissionFilterView(GenericTemplateView): filterset_class = filters.MissionFilter new_url = reverse_lazy("core:mission_new") home_url = "" - fields = ["id", "name", "biochem_table"] + fields = ["id", "name"] def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs)