Skip to content

Commit

Permalink
Fix for #232
Browse files Browse the repository at this point in the history
  • Loading branch information
Elijahwalkerwest committed May 1, 2018
1 parent bbe06d5 commit 30f61a9
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 12 deletions.
61 changes: 61 additions & 0 deletions src/sensordatainterface/templates/equipment/models/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,68 @@
</tbody>
</table>
</div>


{% endblock %}
{% block variables %}
{# <div class="row col-xs-12 col-sm-12 col-md-12 col-lg-12 side-dependent-table"#}
{# style="display: none">#}
{# <div class="row">#}
{# <div class="col-sm-12 col-xs-12 col-md-8"><h4>Instrument Measured Variable</h4></div>#}
{# <div class="col-sm-12 col-xs-12 col-md-4 pull-right">#}
{# <a class="btn btn-block btn-primary"#}
{# href="{% url 'create_output_variable_deployment' samplingfeature.samplingfeatureid equipment.bridgeid %}">New#}
{# Deployment Measured Variable</a>#}
{# </div>#}
{# </div>#}

<div class="row">
<div class="col-md-9"><h3>Variables for this Model</h3></div>
</div>
<hr class="divider">

<div class="row">
<div class="row">
<div class="col-sm-12 col-xs-12 col-md-4 pull-right">
<a class="btn btn-block btn-primary"
href="{% url 'create_output_variable_equipmentmodel' Model.equipmentmodelid %}">New
Measured Variable</a>
</div>
</div>
<table class="data-table">
<thead>
<tr>
<th>Variable Code</th>
<th>Variable Name</th>
<th>Model Name</th>
<th>Method Code</th>
<th>Method Name</th>
</tr>
</thead>
<tbody>

{% for variable in Model.instrumentoutputvariable.all %}
{% if variable.modelid.isinstrument %}
<tr>
<td>
{# <a href="{% url 'measured_variable_detail' variable.instrumentoutputvariableid Deployment.bridgeid samplingfeature.samplingfeatureid %}">#}
{{ variable.variableid.variablecode }}
{# </a>#}
</td>
<td>{{ variable.variableid.variablenamecv_id}}</td>
<td>{{ Model.modelname }}</td>
<td>{{ variable.instrumentmethodid.methodcode }}</td>
<td>{{ variable.instrumentmethodid.methodname }}</td>
</tr>
{% endif %}
{%endfor%}

</tbody>
</table>
</div>
{% endblock %}

{# </div>#}

<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAGtObe6Ic1FeiDvC9Oxt3oWc-HWk8wuTk&sensor=false">
Expand Down
5 changes: 3 additions & 2 deletions src/sensordatainterface/urls/detail_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
context_object_name='Model',
model=EquipmentModel,
slug_field='equipmentmodelid',
queryset=EquipmentModel.objects.prefetch_related('instrumentoutputvariable'),
template_name='equipment/models/details.html'),
name='models_detail'),

Expand All @@ -107,8 +108,8 @@

# Following detail urls are not in the main navigation (i.e. in the navbar)
# Measured Variable detail
url(
r'^sites/measured-variable-detail/(?P<pk>[-_\w]+)/(?P<equipmentused>[-_\w]+)/(?P<featureaction>[-_\w]+)/$',

url(r'^sites/measured-variable-detail/(?P<pk>[-_\w]+)/(?P<equipmentused>[-_\w]+)/(?P<featureaction>[-_\w]+)/$',
DeploymentMeasVariableDetailView.as_view(),
name='measured_variable_detail'),

Expand Down
2 changes: 2 additions & 0 deletions src/sensordatainterface/urls/edit_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

url(r'^inventory/create-sensor-output-variable/(?:(?P<outputvar_id>\d+)/)?$', edit_views.edit_output_variable,
name='create_output_variable'),
url(r'^inventory/create-sensor-output-variable/model/(?:(?P<model_id>\d+)/)?$', edit_views.edit_output_variable,
name='create_output_variable_equipmentmodel'),
url(r'^inventory/delete-sensor-output-variable/(?P<outputvar_id>\d+)/$', edit_views.delete_output_variable,
name='delete_output_variable'),

Expand Down
30 changes: 20 additions & 10 deletions src/sensordatainterface/views/edit_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,16 +482,26 @@ def delete_calibration_method(request, method_id):


@login_required(login_url=LOGIN_URL)
def edit_output_variable(request, outputvar_id):
modifications = {
'instrumentmethodid': ['instrumentmethodid', 'methodid'],
'modelid': ['modelid'],
'variableid': ['variableid'],
'instrumentrawoutputunitsid': ['instrumentrawoutputunitsid', 'unitsid'],
}
arguments = [request, InstrumentOutputVariable.objects, OutputVariableForm, modifications,
'Instrument Output Variables', 'output_variable_detail', 'instrumentoutputvariableid', outputvar_id,
'equipment/sensor-output-variables/output-variable-form.html']
def edit_output_variable(request, outputvar_id=None, model_id=None):

if model_id:
modifications = {
'modelid': ['equipmentmodelid'],
}
arguments = [request, EquipmentModel.objects, OutputVariableForm, modifications,
'Instrument Output Variables', 'output_variable_detail', 'instrumentoutputvariableid',
model_id,
'equipment/sensor-output-variables/output-variable-form.html']
else:
modifications = {
'instrumentmethodid': ['instrumentmethodid', 'methodid'],
'modelid': ['modelid'],
'variableid': ['variableid'],
'instrumentrawoutputunitsid': ['instrumentrawoutputunitsid', 'unitsid'],
}
arguments = [request, InstrumentOutputVariable.objects, OutputVariableForm, modifications,
'Instrument Output Variables', 'output_variable_detail', 'instrumentoutputvariableid', outputvar_id,
'equipment/sensor-output-variables/output-variable-form.html']

return edit_models(*arguments)

Expand Down

0 comments on commit 30f61a9

Please sign in to comment.