Skip to content

Commit

Permalink
Merge pull request #405 from WHOIGit/sb-dev-1.7.0
Browse files Browse the repository at this point in the history
sb small fixes 1.7.0
  • Loading branch information
ethanandrews authored Jun 10, 2021
2 parents 0ee5e2e + 0ea357a commit d9b1d64
Show file tree
Hide file tree
Showing 16 changed files with 194 additions and 25 deletions.
18 changes: 18 additions & 0 deletions roundabout/assemblies/migrations/0012_auto_20210609_0619.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.3 on 2021-06-09 06:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('assemblies', '0011_auto_20201117_2030'),
]

operations = [
migrations.AlterField(
model_name='assemblydocument',
name='doc_link',
field=models.URLField(max_length=1000),
),
]
2 changes: 1 addition & 1 deletion roundabout/assemblies/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class AssemblyDocument(models.Model):
)
name = models.CharField(max_length=255, unique=False)
doc_type = models.CharField(max_length=20, choices=DOC_TYPES)
doc_link = models.CharField(max_length=1000)
doc_link = models.URLField(max_length=1000)
assembly_revision = models.ForeignKey(
AssemblyRevision,
related_name="assembly_documents",
Expand Down
18 changes: 18 additions & 0 deletions roundabout/builds/migrations/0022_auto_20210609_0619.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.3 on 2021-06-09 06:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('builds', '0021_buildhyperlink'),
]

operations = [
migrations.AlterField(
model_name='buildhyperlink',
name='url',
field=models.URLField(max_length=1000),
),
]
2 changes: 1 addition & 1 deletion roundabout/builds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def location_changed(self):

class BuildHyperlink(models.Model):
text = models.CharField(max_length=255, unique=False, blank=False, null=False)
url = models.CharField(max_length=1000)
url = models.URLField(max_length=1000)
parent = models.ForeignKey(Build, related_name='hyperlinks',
on_delete=models.CASCADE, null=False, blank=False)

Expand Down
18 changes: 18 additions & 0 deletions roundabout/calibrations/migrations/0030_auto_20210609_0619.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.3 on 2021-06-09 06:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('calibrations', '0029_coefficientnameevent_assembly_part'),
]

operations = [
migrations.AlterField(
model_name='calibrationeventhyperlink',
name='url',
field=models.URLField(max_length=1000),
),
]
2 changes: 1 addition & 1 deletion roundabout/calibrations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_valid_calibration_range(self):

class CalibrationEventHyperlink(models.Model):
text = models.CharField(max_length=255, unique=False, blank=False, null=False)
url = models.CharField(max_length=1000)
url = models.URLField(max_length=1000)
parent = models.ForeignKey(CalibrationEvent, related_name='hyperlinks',
on_delete=models.CASCADE, null=False, blank=False)

Expand Down
18 changes: 18 additions & 0 deletions roundabout/configs_constants/migrations/0024_auto_20210609_0619.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.3 on 2021-06-09 06:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('configs_constants', '0023_auto_20210426_1537'),
]

operations = [
migrations.AlterField(
model_name='configeventhyperlink',
name='url',
field=models.URLField(max_length=1000),
),
]
2 changes: 1 addition & 1 deletion roundabout/configs_constants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_latest_deployment_date(self):

class ConfigEventHyperlink(models.Model):
text = models.CharField(max_length=255, unique=False, blank=False, null=False)
url = models.CharField(max_length=1000)
url = models.URLField(max_length=1000)
parent = models.ForeignKey(ConfigEvent, related_name='hyperlinks',
on_delete=models.CASCADE, null=False, blank=False)

Expand Down
18 changes: 18 additions & 0 deletions roundabout/cruises/migrations/0020_auto_20210609_0619.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.3 on 2021-06-09 06:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('cruises', '0019_merge_20210209_1909'),
]

operations = [
migrations.AlterField(
model_name='cruisehyperlink',
name='url',
field=models.URLField(max_length=1000),
),
]
2 changes: 1 addition & 1 deletion roundabout/cruises/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def get_actions(self):

class CruiseHyperlink(models.Model):
text = models.CharField(max_length=255, unique=False)
url = models.CharField(max_length=1000)
url = models.URLField(max_length=1000)
parent = models.ForeignKey(
Cruise,
related_name="hyperlinks",
Expand Down
2 changes: 2 additions & 0 deletions roundabout/exports/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class ExportCalibrationEvents(ZipExport):
@classmethod
def build_zip(cls, zf, objs, subdir=None):
objs = objs.select_related('inventory__part__part_type').exclude(inventory__part__part_type__ccc_toggle=False)
objs = objs.select_related('inventory__location').exclude(inventory__location__root_type='Trash')
objs = objs.prefetch_related('inventory', 'inventory__fieldvalues', 'inventory__fieldvalues__field')

for cal in objs:
Expand Down Expand Up @@ -231,6 +232,7 @@ class ExportConfigEvents(ZipExport):
@classmethod
def build_zip(cls, zf, objs, subdir=None):
objs = objs.select_related('inventory__part__part_type').exclude(inventory__part__part_type__ccc_toggle=False)
objs = objs.select_related('inventory__location').exclude(inventory__location__root_type='Trash')
objs = objs.prefetch_related('inventory', 'inventory__fieldvalues', 'inventory__fieldvalues__field')

for confconst in objs:
Expand Down
18 changes: 18 additions & 0 deletions roundabout/inventory/migrations/0068_auto_20210609_0619.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.3 on 2021-06-09 06:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('inventory', '0067_merge_20210429_1740'),
]

operations = [
migrations.AlterField(
model_name='inventoryhyperlink',
name='url',
field=models.URLField(max_length=1000),
),
]
2 changes: 1 addition & 1 deletion roundabout/inventory/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def get_latest_deployment(self):

class InventoryHyperlink(models.Model):
text = models.CharField(max_length=255, unique=False, blank=False, null=False)
url = models.CharField(max_length=1000)
url = models.URLField(max_length=1000)
parent = models.ForeignKey(
Inventory,
related_name="hyperlinks",
Expand Down
4 changes: 2 additions & 2 deletions roundabout/search/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def render_object(self,record):
class CalibrationTable(SearchTable):
class Meta(SearchTable.Meta):
model = CalibrationEvent
fields = ['inventory__serial_number','inventory__part__name','calibration_date','deployment','approved','user_approver__all__name','user_draft__all__name','created_at']
fields = ['inventory__serial_number','inventory__part__name','inventory__location','calibration_date','deployment','approved','user_approver__all__name','user_draft__all__name','created_at']
base_shown_cols = ['inventory__serial_number','calibration_date','approved']

inventory__serial_number = Column(verbose_name='Inventory SN', attrs={'style':'white-space: nowrap;'},
Expand All @@ -300,7 +300,7 @@ class Meta(SearchTable.Meta):
class ConfigConstTable(SearchTable):
class Meta(SearchTable.Meta):
model = ConfigEvent
fields = ['inventory__serial_number','inventory__part__name','config_type','configuration_date','deployment','approved','user_approver__all__name','user_draft__all__name','created_at']
fields = ['inventory__serial_number','inventory__part__name','inventory__location','config_type','configuration_date','deployment','approved','user_approver__all__name','user_draft__all__name','created_at']
base_shown_cols = ['inventory__serial_number','configuration_date','config_type','approved']

inventory__serial_number = Column(verbose_name='Inventory SN', attrs={'style':'white-space: nowrap;'},
Expand Down
18 changes: 13 additions & 5 deletions roundabout/search/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ def get_table_kwargs(self, field_exceptions=[]):
class InventoryTableView(GenericSearchTableView):
model = Inventory
table_class = InventoryTable
query_prefetch = ['fieldvalues', 'fieldvalues__field', 'part', 'actions', 'actions__user', 'actions__location']
query_prefetch = ['fieldvalues', 'fieldvalues__field', 'part', 'actions',
'actions__user', 'actions__location', 'build', 'calibration_events']
avail_udf = set()
choice_fields = {'actions__latest__action_type': Action.ACTION_TYPES}

Expand All @@ -445,7 +446,7 @@ def get_avail_fields():
dict(value="old_serial_number", text="Old Serial Number", legal_lookup='STR_LOOKUP'),
dict(value="location__name", text="Location", legal_lookup='STR_LOOKUP'),
dict(value="build__assembly__name", text="Build Name", legal_lookup='STR_LOOKUP'),
dict(value="build__build_number ", text="Build Number", legal_lookup='STR_LOOKUP'),
dict(value="build__build_number", text="Build Number", legal_lookup='STR_LOOKUP'),
dict(value="created_at", text="Date Created", legal_lookup='DATE_LOOKUP'),
dict(value="updated_at", text="Date Modified", legal_lookup='DATE_LOOKUP'),
dict(value="build__is_deployed", text="is-build-deployed?", legal_lookup='BOOL_LOOKUP'),
Expand Down Expand Up @@ -684,7 +685,8 @@ def get_context_data(self, **kwargs):
class ActionTableView(GenericSearchTableView):
model = Action
table_class = ActionTable
query_prefetch = ['user','inventory','inventory__part','cruise','build','build__assembly_revision__assembly','deployment']
query_prefetch = ['user','inventory','inventory__part','cruise',
'build','build__assembly_revision__assembly','deployment']
choice_fields = {'action_type': Action.ACTION_TYPES}

@staticmethod
Expand Down Expand Up @@ -714,12 +716,15 @@ def get_context_data(self, **kwargs):
class CalibrationTableView(GenericSearchTableView):
model = CoefficientValueSet
table_class = CalibrationTable
query_prefetch = ['coefficient_name','calibration_event','calibration_event__inventory','calibration_event__inventory__part','calibration_event__user_approver','calibration_event__user_draft']
query_prefetch = ['coefficient_name','calibration_event','calibration_event__inventory',
'calibration_event__inventory__part','calibration_event__inventory__location',
'calibration_event__user_approver','calibration_event__user_draft']

@staticmethod
def get_avail_fields():
avail_fields = [dict(value="calibration_event__inventory__serial_number", text="Inventory: SN", legal_lookup='STR_LOOKUP'),
dict(value="calibration_event__inventory__part__name", text="Inventory: Name", legal_lookup='STR_LOOKUP'),
dict(value="calibration_event__inventory__location__name", text="Inventory: Location", legal_lookup='STR_LOOKUP'),
dict(value="coefficient_name__calibration_name", text="Coefficient Name", legal_lookup='STR_LOOKUP'),
dict(value="calibration_event__calibration_date", text="Calibration Event: Date", legal_lookup='DATE_LOOKUP'),
dict(value="calibration_event__user_approver__any__username", text="Calibration Event: Approvers", legal_lookup='ITER_LOOKUP'),
Expand Down Expand Up @@ -758,12 +763,15 @@ def get_table_kwargs(self):
class ConfigConstTableView(GenericSearchTableView):
model = ConfigValue
table_class = ConfigConstTable
query_prefetch = ['config_name','config_event','config_event__inventory','config_event__inventory__part','config_event__user_approver','config_event__user_draft']
query_prefetch = ['config_name','config_event','config_event__inventory',
'config_event__inventory__part','config_event__inventory__location',
'config_event__user_approver','config_event__user_draft']

@staticmethod
def get_avail_fields():
avail_fields = [dict(value="config_event__inventory__serial_number", text="Inventory: SN", legal_lookup='STR_LOOKUP'),
dict(value="config_event__inventory__part__name", text="Inventory: Name", legal_lookup='STR_LOOKUP'),
dict(value="config_event__inventory__location__name", text="Inventory: Location", legal_lookup='STR_LOOKUP'),
dict(value="config_name__name", text="Config/Const Name", legal_lookup='STR_LOOKUP'),
dict(value="config_event__configuration_date", text="Config/Const Event: Date", legal_lookup='DATE_LOOKUP'),
dict(value="config_event__user_approver__any__username", text="Config/Const Event: Approvers", legal_lookup='ITER_LOOKUP'),
Expand Down
75 changes: 63 additions & 12 deletions roundabout/templates/exports/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,78 @@
{% block title %}Exports{% endblock %}

{% block content %}
<div class="container">

<h2>Bulk Exports</h2>
<p>Use this interface to bulk download certain DB content</p>

<div class="row">
<div class="col-md-5">
<br><a type=button class="btn btn-primary" href="{% url 'exports:cruises' %}">Export Cruises</a>
<a type=button class="btn btn-primary" href="{% url 'exports:cruises' %}?ci">CI</a>
<div class="col-3"><p><a type=button class="btn btn-primary" href="{% url 'exports:vessels' %}">Export Vessels</a></p></div>
<div class="col-9"><p>Downloads a shiplist.csv file</p></div>
</div>

<br><br><a type=button class="btn btn-primary" href="{% url 'exports:vessels' %}">Export Vessels</a>
<a type=button class="btn btn-primary" href="{% url 'exports:vessels' %}?ci">CI</a>
<div class="row">
<div class="col-3"><p><a type=button class="btn btn-primary" href="{% url 'exports:cruises' %}">Export Cruises</a></p></div>
<div class="col-9"><p>Downloads a CruiseInformation.csv file</p></div>
</div>

<div class="row">
<div class="col-3"><p><a type=button class="btn btn-primary" href="{% url 'exports:deployments' %}">Export Deployments</a></p></div>
<div class="col-9"><p>Downloads a zip of deployment csv files</p></div>
</div>

<br><br><a type=button class="btn btn-primary" href="{% url 'exports:deployments' %}">Export Deployments</a>
<div class="row">
<div class="col-3"><p><a type=button class="btn btn-primary" href="{% url 'exports:calibrations' %}">Export Calibrations</a></p></div>
<div class="col-9"><p>Downloads a zip of calibration csv files</p></div>
</div>

<br><br><a type=button class="btn btn-primary" href="{% url 'exports:calibrations' %}">Export Calibrations</a>
<br><br><a type=button class="btn btn-primary" href="{% url 'exports:configconsts' %}">Export Configurations & Constants</a>
<br><br><a type=button class="btn btn-primary" href="{% url 'exports:calibrations_with_configs' %}">Export Calibrations with<br>Configurations and Constants [CI]</a>
<div class="row">
<div class="col-3"><p><a type=button class="btn btn-primary" href="{% url 'exports:configconsts' %}">Export Configurations & Constants</a></p></div>
<div class="col-9"><p>Downloads a zip of configuration event csv files (incl. constants)</p></div>
</div>

<br><br><a type=button class="btn btn-primary" href="{% url 'exports:CI' %}">Export All [CI]</a>
<hr>

</div>
<div class="col-md-7">
<h2>Bulk Exports: CI spec</h2>
<p>Exports for CI require specific schema and requirements so as to match the OOI CI Asset Management GitHub CSVs.</p>

<div class="row">
<div class="col-3"><p><a type=button class="btn btn-primary" href="{% url 'exports:CI' %}">Export All <span class="text-monospace">[CI]</span></a></p></div>
<div class="col-9"><p>Exports all the below assets to a single zip file named Asset-Management.zip</p></div>
</div>

<div class="row">
<div class="col-3"><p><a type=button class="btn btn-primary" href="{% url 'exports:vessels' %}?ci">Export Vessels <span class="text-monospace">[CI]</span></a></p></div>
<div class="col-9"><p>Vessels Export is congruous with its respective export function above, with the exception of an ommitted "Notes" column.</p></div>
</div>

<div class="row">
<div class="col-3"><p><a type=button class="btn btn-primary" href="{% url 'exports:cruises' %}?ci">Export Cruises <span class="text-monospace">[CI]</span></a></p></div>
<div class="col-9"><p>Cruises Export is congruous with its respective export function above, with the exception of ommitted "Friendly Name" and "Destination" columns.</p></div>
</div>

<div class="row">
<div class="col-3"><p><a type=button class="btn btn-primary" href="{% url 'exports:deployments' %}">Export Deployments</a></p></div>
<div class="col-9"><p>Deployment Exports is congruous its respective export function above.</p></div>
</div>

<div class="row">
<div class="col-3"><p><a type=button class="btn btn-primary" href="{% url 'exports:calibrations_with_configs' %}">Export Calibrations with Configurations and Constants</a></p></div>
<div class="col-9"><p>This export function is highly specialized. The CalibrationEvents_withConfigs.zip will contain zero or more CI CCC csv files, and a CalibrationsWithConfigs_EXPORTLOG.txt logfile.</p>
<p>CCC events that pass <span class="font-italic">all</span> the following Requirements must feature:</p>
<ul>
<li>CCCs must be reviewed/approved by at least two Users</li>
<li>CCCs defined for a Part must be found for the associated Inventory item</li>
<li>Inventory must have an associated Assembly part and not be in the Trash location</li>
<li>Calibration events must be dated before their associated configuration events</li>
<li>"Export with Calibrations" flag must be checked for Configurations and Constants for the Part</li>
</ul>
<p>In addition to CCC files, a CalibrationsWithConfigs_EXPORTLOG.txt log file describing the process of vetting CCC files for download is included. If you are not seeing a CCC file you were expectiong, check the CalibrationsWithConfigs_EXPORTLOG.txt for your expected file; it may well tell you why it did not export.</p>
<p>CalibrationsWithConfigs_EXPORTLOG.txt is not part of the OOI Asset Management GitHub CSV schema and so, before comparison, it will have to be removed so as not to create an error.</p>
</div>
</div>

</div>

</div>
{% endblock %}

0 comments on commit d9b1d64

Please sign in to comment.