Skip to content

Commit

Permalink
- added sounds and background color when logging out of an area
Browse files Browse the repository at this point in the history
  • Loading branch information
rptmat57 committed Sep 23, 2019
1 parent 92178d0 commit 60a3e07
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 4 deletions.
1 change: 1 addition & 0 deletions Dockerfile.splash_pad
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ WORKDIR /nemo

COPY resources/icons/* /nemo/media/
COPY resources/people/* /nemo/media/
COPY resources/media/* /nemo/media/
COPY resources/splash_pad_settings.py /nemo/
COPY NEMO/fixtures/splash_pad.json /nemo/

Expand Down
12 changes: 12 additions & 0 deletions NEMO/static/nemo.css
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,16 @@ Twitter Typeahead autocomplete dropdown menu isn't chopped off. */
.navbar-preferences > a > img {
width: 19px;
height: 19px;
}

body.logout-error {
background-color: red;
}

body.logout-warning {
background-color: orange;
}

body.logout-success {
background-color: green;
}
2 changes: 2 additions & 0 deletions NEMO/templates/area_access/badge_not_found.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script>$('body').removeClass().addClass('logout-error')</script>
<h1>Your badge wasn't recognized.</h1>
<h2>If you got a new one recently then we'll need to update your account.</h2>
<h2>Please visit the NanoFab user office to resolve the problem.</h2>
<audio src="{% url 'media' 'error.mp3' %}" autoplay></audio>
<script>revert(15);</script>
5 changes: 4 additions & 1 deletion NEMO/templates/area_access/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
{% endblock %}
<div id="occupancy"></div>
</div>
<div id="error" style="display: none"><h1>There was a problem communicating with the web server. Please visit the user office for assistance.</h1></div>
<div id="error" style="display: none"><h1>There was a problem communicating with the web server. Please visit the user office for assistance.</h1><audio id="error-sound" src="{% url 'media' 'error.mp3' %}"></audio></div>
<div id="status" style="display: none"></div>
<div><h1 style="color:lightgrey" id="badge_number"></h1></div>
<script type="text/javascript">
Expand Down Expand Up @@ -76,9 +76,11 @@
{
if(status === "error")
{
document.getElementById('error-sound').play();
$("#default_content").hide();
$("#status").hide();
$("#error").show();
$('body').removeClass().addClass('logout-error');
revert(15);
}
}
Expand All @@ -90,6 +92,7 @@
}
function revert_to_default_content()
{
$('body').removeClass();
fetch_occupancy();
clear_timeout();
$("#status").hide();
Expand Down
2 changes: 2 additions & 0 deletions NEMO/templates/area_access/logout_success.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
<script>$('body').removeClass().addClass('logout-success')</script>
<h1>You're now logged out of the {{ area|lower }}, {{ name }}.</h1>
<audio src="{% url 'media' 'success.mp3' %}" autoplay></audio>
<script>revert(7);</script>
12 changes: 12 additions & 0 deletions NEMO/templates/area_access/logout_warning.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>$('body').removeClass().addClass('logout-warning')</script>
<h1>You're now logged out of the {{ area|lower }}, {{ name }}.</h1>
<audio src="{% url 'media' 'warning.mp3' %}" autoplay></audio>
<h2 style="color:red">
<p>You are currently still logged in to the following tools:</p>
<ul>
{% for usage_event in tools_in_use %}
<li>{{ usage_event.tool.name }}</li>
{% endfor %}
</ul>
</h2>
<script>revert(15);</script>
2 changes: 2 additions & 0 deletions NEMO/templates/area_access/not_logged_in.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<script>$('body').removeClass().addClass('logout-warning')</script>
<h1>According to our records, you're not logged in to any access controlled areas.</h1>
<h2>Please visit the NanoFab user office if you believe this is an error.</h2>
<audio src="{% url 'media' 'warning.mp3' %}" autoplay></audio>
<script>revert(15);</script>
8 changes: 6 additions & 2 deletions NEMO/views/area_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from django.utils.http import urlencode
from django.views.decorators.http import require_GET, require_POST, require_http_methods

from NEMO.models import Area, AreaAccessRecord, Door, PhysicalAccessLog, PhysicalAccessType, Project, User
from NEMO.models import Area, AreaAccessRecord, Door, PhysicalAccessLog, PhysicalAccessType, Project, User, UsageEvent
from NEMO.tasks import postpone
from NEMO.utilities import parse_start_and_end_date
from NEMO.views.customization import get_customization
Expand Down Expand Up @@ -193,7 +193,11 @@ def logout_of_area(request, door_id):
if record:
record.end = timezone.now()
record.save()
return render(request, 'area_access/logout_success.html', {'area': record.area, 'name': user.first_name})
busy_tools = UsageEvent.objects.filter(end=None, user=user)
if busy_tools:
return render(request, 'area_access/logout_warning.html', {'area': record.area, 'name': user.first_name, 'tools_in_use': busy_tools})
else:
return render(request, 'area_access/logout_success.html', {'area': record.area, 'name': user.first_name})
else:
return render(request, 'area_access/not_logged_in.html')

Expand Down
Binary file added resources/sounds/error.mp3
Binary file not shown.
Binary file added resources/sounds/success.mp3
Binary file not shown.
Binary file added resources/sounds/warning.mp3
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='NEMO',
version='1.16.2',
version='1.17.0',
python_requires='>=3.6',
packages=find_packages(exclude=['NEMO.tests']),
include_package_data=True,
Expand Down

0 comments on commit 60a3e07

Please sign in to comment.