Skip to content

Commit

Permalink
Merge pull request #278 from UCHIC/django-elijah-dev
Browse files Browse the repository at this point in the history
Feature added for #236
  • Loading branch information
Elijahwalkerwest authored Mar 30, 2018
2 parents 552f8c1 + b457881 commit 7601d53
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ function setOtherActions() {
$('.InstrumentCalibration .maintenance').not('option').parents('tr').remove();
actionTypeElem = $('.InstrumentCalibration [name="actiontypecv"]');
actionTypeElem.select2('val', 'Instrument calibration');
$('.InstrumentCalibration [name="equipmentused"]').removeAttr('multiple');
$('.InstrumentCalibration [name="equipmentused"]').select2();
actionTypeElem.parents('tr').hide();
} else if (mainForm.hasClass('EquipmentDeployment')) {
var site = $('.EquipmentDeployment').find('[name="site_id"]').val();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@ <h1>Calibrations
{% if equipment_name %} for Equipment {{ equipment_name.equipmentserialnumber }}
{% endif %}</h1>
</div>
{% if equipment_name %}
<div class="col-xs-12 col-sm-6 col-md-3 pull-right">
<a class="btn btn-primary btn-block new-btn" href="{% url 'create_action_from_equipment' 'InstrumentCalibration' equipment_name.equipmentid%}">New
Calibration</a>
</div>
{% else %}
<div class="col-xs-12 col-sm-6 col-md-3 pull-right">
<a class="btn btn-primary btn-block new-btn" href="{% url 'create_action' 'InstrumentCalibration' %}">New
Calibration</a>
</div>
{% endif %}
</div>
<table class="data-table">
<thead>
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 @@ -74,6 +74,8 @@
name='create_action_from_visit'),
url(r'^actions/create-action/for_site/(?P<action_type>\w+)/(?:(?P<site_id>\d+)/)?$', edit_views.edit_action,
name='create_action_for_site'),
url(r'^actions/create-action/from_equipment/(?P<action_type>\w+)/(?:(?P<equipment_id>\d+)/)?$', edit_views.edit_action,
name='create_action_from_equipment'),

url(r'^actions/create-retrieval/(?:(?P<retrieval_id>\d+)/)?$', edit_views.edit_retrieval, name='create_retrieval'),
url(r'^actions/create-retrieval/from_deployment/(?:(?P<deployment_id>\d+)/)?$', edit_views.edit_retrieval,
Expand Down
12 changes: 11 additions & 1 deletion src/sensordatainterface/views/edit_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ def edit_site_visit_summary(request, action_id):


@login_required(login_url=LOGIN_URL)
def edit_action(request, action_type, action_id=None, visit_id=None, site_id=None):
def edit_action(request, action_type, action_id=None, visit_id=None, site_id=None, equipment_id=None):
action = 'create'
child_relationship = CvRelationshiptype.objects.get(term='isChildOf')

Expand Down Expand Up @@ -1179,6 +1179,16 @@ def edit_action(request, action_type, action_id=None, visit_id=None, site_id=Non

return response

elif equipment_id:
equipment_used = Equipment.objects.filter(pk=equipment_id)
site_visit_form = SiteVisitChoiceForm()
action_form = ActionForm(
initial={'begindatetime': datetime.now(),
'begindatetimeutcoffset': -7,
'enddatetimeutcoffset': -7,
'equipmentused': equipment_used
}
)
elif action_id:
action = 'update'
child_action = Action.objects.get(pk=action_id)
Expand Down

0 comments on commit 7601d53

Please sign in to comment.