Skip to content
Snippets Groups Projects
Commit d65a4953 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch 'fix/on_leave_buttons' into 'master'

fixed issue #265 removing buttons and adding divs with tooltips

Closes #265

See merge request NCER-PD/scheduling-system!187
parents 06284e0d 17f9bf86
No related branches found
No related tags found
1 merge request!187fixed issue #265 removing buttons and adding divs with tooltips
Pipeline #7570 passed
...@@ -153,6 +153,15 @@ class Worker(models.Model): ...@@ -153,6 +153,15 @@ class Worker(models.Model):
return True return True
return False return False
def current_leave_details(self):
holidays = self.holiday_set.filter(datetime_end__gt=datetime.datetime.now(),
datetime_start__lt=datetime.datetime.now(),
kind=AVAILABILITY_HOLIDAY).order_by('-datetime_end')
if len(holidays) > 0:
return holidays[0]
else:
return None
def disable(self): def disable(self):
if self.user is not None: if self.user is not None:
self.user.is_active = False self.user.is_active = False
......
...@@ -5,6 +5,20 @@ ...@@ -5,6 +5,20 @@
{{ block.super }} {{ block.super }}
<!-- DataTables --> <!-- DataTables -->
<link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}"> <link rel="stylesheet" href="{% static 'AdminLTE/plugins/datatables/dataTables.bootstrap.css' %}">
<style type="text/css">
.no_leave{
height: 100%;
line-height: 2.5;
text-align: center;
background-color: #00a65b;
}
.on_leave{
height: 100%;
line-height: 2.5;
text-align: center;
background-color: #dd4b39;
}
</style>
{% endblock styles %} {% endblock styles %}
{% block ui_active_tab %}'workers'{% endblock ui_active_tab %} {% block ui_active_tab %}'workers'{% endblock ui_active_tab %}
...@@ -53,7 +67,7 @@ ...@@ -53,7 +67,7 @@
<th>Languages</th> <th>Languages</th>
<th>Details</th> <th>Details</th>
{% if worker_type == 'STAFF' %} {% if worker_type == 'STAFF' %}
<th>On leave</th> <th>At work</th>
<th>Disabled</th> <th>Disabled</th>
{% endif %} {% endif %}
</tr> </tr>
...@@ -82,9 +96,9 @@ ...@@ -82,9 +96,9 @@
{% if worker_type == 'STAFF' %} {% if worker_type == 'STAFF' %}
<td> <td>
{% if worker.is_on_leave %} {% if worker.is_on_leave %}
<button type="button" class="btn btn-block btn-danger">YES</button> <div title="Worker is on leave until: {{ worker.current_leave_details.datetime_end }}" class="on_leave"></div>
{% else %} {% else %}
<button type="button" class="btn btn-block btn-success">NO</button> <div title="Worker is not on leave" class="no_leave"></div>
{% endif %} {% endif %}
</td> </td>
<td> <td>
...@@ -120,5 +134,7 @@ ...@@ -120,5 +134,7 @@
"autoWidth": false "autoWidth": false
}); });
}); });
$('.no_leave, .on_leave').tooltip();
</script> </script>
{% endblock scripts %} {% endblock scripts %}
...@@ -61,6 +61,16 @@ class WorkerModelTests(TestCase): ...@@ -61,6 +61,16 @@ class WorkerModelTests(TestCase):
self.assertTrue(worker.is_on_leave()) self.assertTrue(worker.is_on_leave())
def test_current_leave_details(self):
worker = create_worker()
self.assertEqual(worker.current_leave_details(), None)
h = Holiday(person=worker,
datetime_start=get_today_midnight_date() + datetime.timedelta(days=-2),
datetime_end=get_today_midnight_date() + datetime.timedelta(days=2))
h.save()
self.assertEqual(worker.current_leave_details(), h)
def test_get_by_user_for_anonymous(self): def test_get_by_user_for_anonymous(self):
self.assertIsNone(Worker.get_by_user(AnonymousUser())) self.assertIsNone(Worker.get_by_user(AnonymousUser()))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment