-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from Domotina/test
Entrega 3 Sprint 3 - Corrección bug de popups en firefox - Por ajax cargar los dueños de los inmubles y filtrar sus inmuebles para que se carguen en un combobox y puedan ser seleccionados por el usuario - Inclusión de funcionalidad para ver reportes de eventos ocurridos en un rango de fechas en HTML. - Inclusión de validaciones del lado del servidor para que pasen las pruebas de los escenarios en la HU011 - Inclusión de funcionalidad para ver reportes en PDF - Inclusión imagenes (encabezado) en el reporte PDF
- Loading branch information
Showing
15 changed files
with
570 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import datetime | ||
from map.models import Place | ||
from event_manager.models import Event | ||
|
||
|
||
# Validating if date is valid | ||
def is_valid_format(date): | ||
passed = False | ||
try: | ||
start_year = datetime.datetime.strptime(date, "%Y/%m/%d").year | ||
passed = True | ||
except ValueError: | ||
passed = False | ||
|
||
return passed | ||
|
||
|
||
# Getting the place based on its pk | ||
def get_place(pk): | ||
return Place.objects.get(pk=pk) | ||
|
||
|
||
# Getting events in the place based on a date range | ||
def get_events_in_place(place, start_date, end_date): | ||
try: | ||
start_year = datetime.datetime.strptime(start_date, "%Y/%m/%d").year | ||
end_year = datetime.datetime.strptime(end_date, "%Y/%m/%d").year | ||
|
||
start_month = datetime.datetime.strptime(start_date, "%Y/%m/%d").month | ||
end_month = datetime.datetime.strptime(end_date, "%Y/%m/%d").month | ||
|
||
start_day = datetime.datetime.strptime(start_date, "%Y/%m/%d").day | ||
end_day = datetime.datetime.strptime(start_date, "%Y/%m/%d").day | ||
|
||
events = Event.objects.filter(sensor__floor__place=place)\ | ||
.filter(timestamp__gt=datetime.date(start_year, start_month, start_day), | ||
timestamp__lt=datetime.date(end_year, end_month, end_day)) | ||
return events | ||
|
||
except ValueError: | ||
return None | ||
|
||
|
||
# Verifying if the end date is greater than the start date | ||
def is_end_date_greater(start_date, end_date): | ||
|
||
if datetime.datetime.strptime(start_date, "%Y/%m/%d") > \ | ||
datetime.datetime.strptime(end_date, "%Y/%m/%d"): | ||
return False | ||
else: | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{% extends "base.html"%} | ||
{% load static %} | ||
|
||
{% block title %} | ||
- Events in a date range | ||
{% endblock %} | ||
|
||
{% block navbar %} | ||
<li><a href='{% url "map_home" %}'>My places</a></li> | ||
<li><a href="#">About Smart Home</a></li> | ||
<li><a href="#">About Domotina</a></li> | ||
{% endblock navbar %} | ||
|
||
{% block content %} | ||
<div class="well"> | ||
<h3>Report of handled events in your place {{place.name}}</h3> | ||
{% if events %} | ||
<h5>These are handled events in your place between {{start_date}} and {{end_date}}.</h5> | ||
{% endif %} | ||
|
||
<div class="panel panel-primary"> | ||
{% if events %} | ||
<table class="table table-striped table-hover "> | ||
<thead> | ||
<tr> | ||
<th>Date</th> | ||
<th>Time</th> | ||
<th>Asset</th> | ||
<th>Description</th> | ||
</tr> | ||
</thead> | ||
<tbody class="table-striped"> | ||
{% for event in events %} | ||
<tr> | ||
<td>{{ event.timestamp.date }}</td> | ||
<td>{{ event.timestamp.time }}</td> | ||
<td>{{ event.sensor }}</td> | ||
<td>Status changed to {{ event }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% else %} | ||
<ul class="list-group"> | ||
<li class="list-group-item">There are no handled events between {{start_date}} and {{end_date}}.</li> | ||
</ul> | ||
{% endif %} | ||
</div> | ||
<a href='{% url "report_home" place.pk %}'>View events in another date.</a> | ||
</div> | ||
{% endblock %} |
Oops, something went wrong.