Skip to content

Commit

Permalink
added biochem tables to user settings. removed biochem_table from mis…
Browse files Browse the repository at this point in the history
…sion
  • Loading branch information
upsonp committed Jun 27, 2024
1 parent 4dedaeb commit 90d879b
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 16 deletions.
4 changes: 1 addition & 3 deletions core/form_mission_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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

Expand Down Expand Up @@ -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')),
Expand Down
22 changes: 22 additions & 0 deletions core/migrations/0007_remove_mission_biochem_table_and_more.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
4 changes: 0 additions & 4 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
@@ -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'),
),
]
12 changes: 9 additions & 3 deletions settingsdb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'

Expand Down Expand Up @@ -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"))
Expand All @@ -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)
Expand All @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions settingsdb/templates/settingsdb/partials/mission_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
<th class="col">Name</th>
<th class="col">Start Date</th>
<th class="col">End Date</th>
<th class="col">Biochem Table</th>
<th class="col-auto">{# mission details #}</th>
</tr>
</thead>
Expand All @@ -34,7 +33,6 @@
<td>{{ mission.name }}</td>
<td>{% if mission.start_date %}{{ mission.start_date }}{% endif %}</td>
<td>{% if mission.end_date %}{{ mission.end_date }}{% endif %}</td>
<td>{{ mission.biochem_table }}</td>

{% if mission.requires_migration %}
<td>
Expand Down
7 changes: 3 additions & 4 deletions settingsdb/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 90d879b

Please sign in to comment.