Skip to content

Commit 0f6748e

Browse files
authored
Merge pull request #309 from usnistgov/7.3.7.dev
7.3.7.dev
2 parents c6fb512 + b5f2278 commit 0f6748e

File tree

8 files changed

+47
-16
lines changed

8 files changed

+47
-16
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ RUN apt-get install -y less vim
55

66
# Intall NEMO (in the current directory) and Gunicorn
77
COPY . /nemo/
8+
RUN python3 -m pip install --upgrade pip
89
RUN python3 -m pip install /nemo/ gunicorn==23.0.0
910
RUN rm --recursive --force /nemo/
1011

Dockerfile.splash_pad

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ENV PIP_ROOT_USER_ACTION=ignore
55
RUN apt-get update && apt-get upgrade -y && apt-get install -y systemctl rsync vim less
66

77
COPY . /nemo/
8+
RUN python3 -m pip install --upgrade pip
89
RUN python3 -m pip install /nemo/
910
RUN rm --recursive --force /nemo
1011

NEMO/apps/kiosk/templates/kiosk/tool_information.html

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -558,12 +558,19 @@ <h2>
558558
update_stop_button();
559559
{% if customer.active_projects|length == 1 %}update_start_button();{% endif %}
560560

561-
{% if tool.in_use %}
562-
$('body').on('dynamic-form-group-changed dynamic-form-field-changed', update_stop_button);
563-
$('body').on('change keyup', '#downtime', update_stop_button);
564-
{% else %}
565-
$('body').on('dynamic-form-group-changed dynamic-form-field-changed', update_start_button);
566-
{% endif %}
561+
$('body').on('dynamic-form-group-changed dynamic-form-field-changed', function (event, event_data)
562+
{
563+
if (event_data.questions_type === "pre")
564+
{
565+
update_start_button();
566+
}
567+
else if (event_data.questions_type === "post")
568+
{
569+
update_stop_button();
570+
}
571+
});
572+
$('body').on('change keyup', '#downtime', update_stop_button);
573+
567574
if (virtual_inputs)
568575
{
569576
$('#downtime').numpad({'readonly': false, 'hidePlusMinusButton': true, 'hideDecimalButton': true});

NEMO/middleware.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Optional
55

66
from django.conf import settings
7+
from django.contrib.auth import SESSION_KEY
78
from django.contrib.auth.middleware import RemoteUserMiddleware
89
from django.http import Http404, HttpResponseForbidden
910
from django.urls import NoReverseMatch, resolve, reverse
@@ -76,7 +77,11 @@ def process_view(self, request, view_function, view_ordered_arguments, view_name
7677
#
7778
# If the request is normal (instead of AJAX) and the user's session has expired
7879
# then the @login_required decorator will redirect them to the login page.
79-
if not request.user.is_authenticated:
80+
#
81+
# IMPORTANT: Only do this if the session indicates the user *was* logged in.
82+
# Anonymous/public users can have sessions too (CSRF, messages), and should not be blocked.
83+
session_had_login = SESSION_KEY in request.session
84+
if session_had_login and not request.user.is_authenticated:
8085
return HttpResponseForbidden() if is_ajax(request) else None
8186

8287
# If the view is regularly polled by the webpage to update information then expiry refresh should be disabled.

NEMO/templates/tool_control/tool_status.html

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,10 +1165,16 @@ <h4 class="media-heading">Tool properties</h4>
11651165
show_alerts();
11661166
update_stop_button();
11671167
update_start_button();
1168-
{% if tool.in_use %}
1169-
$('body').on('dynamic-form-group-changed dynamic-form-field-changed', update_stop_button);
1170-
{% else %}
1171-
$('body').on('dynamic-form-group-changed dynamic-form-field-changed', update_start_button);
1172-
{% endif %}
1173-
$('body').on('change keyup', '#downtime', update_stop_button);
1168+
$('body').on('change keyup', '#downtime', update_stop_button);
1169+
$('body').on('dynamic-form-group-changed dynamic-form-field-changed', function (event, event_data)
1170+
{
1171+
if (event_data.questions_type === "pre")
1172+
{
1173+
update_start_button();
1174+
}
1175+
else if (event_data.questions_type === "post")
1176+
{
1177+
update_stop_button();
1178+
}
1179+
});
11741180
</script>

NEMO/views/tool_control.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ def usage_data_history(request, tool_id):
229229
if not last and not start and not end:
230230
# Default to last 25 records
231231
last = 25
232-
usage_events = UsageEvent.objects.filter(tool_id__in=Tool.objects.get(pk=tool_id).get_family_tool_ids())
232+
tool_family_ids = Tool.objects.get(pk=tool_id).get_family_tool_ids()
233+
usage_events = UsageEvent.objects.filter(tool_id__in=tool_family_ids)
233234

234235
if start:
235236
usage_events = usage_events.filter(end__gte=start)
@@ -241,7 +242,7 @@ def usage_data_history(request, tool_id):
241242
except ValueError:
242243
pass
243244

244-
all_usage_events = usage_events.order_by("-end")
245+
all_usage_events = usage_events.order_by("-start")
245246
pre_usage_events = usage_events.order_by("-start")
246247
post_usage_events = usage_events.filter(end__isnull=False).order_by("-end")
247248
if last:
@@ -255,6 +256,8 @@ def usage_data_history(request, tool_id):
255256
post_usage_events = post_usage_events[:last]
256257

257258
table_data = BasicDisplayTable()
259+
if len(tool_family_ids) > 1:
260+
table_data.add_header(("tool", "Tool"))
258261
table_data.add_header(("user", "User"))
259262
table_data.add_header(("operator", "Operator"))
260263
if show_project_info:
@@ -263,13 +266,17 @@ def usage_data_history(request, tool_id):
263266
table_data.add_header(("end_date", "End date"))
264267

265268
table_pre_run_data = BasicDisplayTable()
269+
if len(tool_family_ids) > 1:
270+
table_data.add_header(("tool", "Tool"))
266271
table_pre_run_data.add_header(("user", "User"))
267272
table_pre_run_data.add_header(("operator", "Operator"))
268273
if show_project_info:
269274
table_pre_run_data.add_header(("project", "Project"))
270275
table_pre_run_data.add_header(("start_date", "Start date"))
271276

272277
table_post_run_data = BasicDisplayTable()
278+
if len(tool_family_ids) > 1:
279+
table_data.add_header(("tool", "Tool"))
273280
table_post_run_data.add_header(("user", "User"))
274281
table_post_run_data.add_header(("operator", "Operator"))
275282
if show_project_info:
@@ -856,6 +863,7 @@ def format_usage_data(
856863
user_data = f"{usage_event.user.first_name} {usage_event.user.last_name}"
857864
operator_data = f"{usage_event.operator.first_name} {usage_event.operator.last_name}"
858865
run_data: Dict = loads(usage_run_data) if usage_run_data else {}
866+
tool_name = usage_event.tool.name
859867
for question_key, question in run_data.items():
860868
if "user_input" in question and not question.get("readonly", False):
861869
if question["type"] == "group":
@@ -889,6 +897,7 @@ def format_usage_data(
889897
table_result.formatted_value(user_input) + suffix if user_input else ""
890898
)
891899
if group_usage_data:
900+
group_usage_data["tool"] = tool_name
892901
group_usage_data["user"] = user_data
893902
group_usage_data["operator"] = operator_data
894903
group_usage_data["start_date"] = format_datetime(
@@ -905,6 +914,7 @@ def format_usage_data(
905914
table_result.formatted_value(question["user_input"]) + suffix if question["user_input"] else ""
906915
)
907916
if usage_data or all_data:
917+
usage_data["tool"] = tool_name
908918
usage_data["user"] = user_data
909919
usage_data["operator"] = operator_data
910920
usage_data["start_date"] = format_datetime(usage_event.start, "SHORT_DATETIME_FORMAT")

NEMO/widgets/dynamic_form.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,7 @@ def get_js_event_data(item, dynamic_field_name: str, extra_data=None) -> str:
11121112
"item_type_id": ContentType.objects.get_for_model(item).id,
11131113
"item_id": item.id,
11141114
"field_name": dynamic_field_name,
1115+
"questions_type": getattr(item, "questions_type", None),
11151116
**extra_data,
11161117
}
11171118
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "NEMO"
3-
version = "7.3.6"
3+
version = "7.3.7"
44
description = "NEMO is a laboratory logistics web application. Use it to schedule reservations, control tool access, track maintenance issues, and more."
55
keywords = ["NEMO"]
66
readme = "README.md"

0 commit comments

Comments
 (0)