Skip to content

Commit

Permalink
Merge pull request #8 from Domotina/test
Browse files Browse the repository at this point in the history
Entrega Sprint 1
  • Loading branch information
Andrés Felipe Esguerra Restrepo committed Mar 10, 2015
2 parents b68a6da + 5e16a2d commit b428e89
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 74 deletions.
4 changes: 2 additions & 2 deletions domotina/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'middleware.http.Http403Middleware',
)

REST_FRAMEWORK = {
Expand All @@ -57,7 +58,6 @@
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {}
# DATABASES = {}

# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
Expand All @@ -68,7 +68,7 @@
USE_TZ = True

# Parse database configuration from $DATABASE_URL
import dj_database_url
#import dj_database_url
DATABASES['default'] = dj_database_url.config()
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
Expand Down
15 changes: 9 additions & 6 deletions event_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class Event(models.Model):
sensor = models.ForeignKey(Sensor)
type = models.ForeignKey(EventType)
timestamp = models.DateTimeField('date', auto_now_add=True)
pos_x = models.IntegerField('x position', default=0)
pos_y = models.IntegerField('y position', default=0)
status = models.IntegerField('status', default=0)
pos_x = models.IntegerField('x position', blank=True, null=True)
pos_y = models.IntegerField('y position', blank=True, null=True)
status = models.IntegerField('status', blank=True, null=True)

class Meta:
verbose_name = 'event'
Expand Down Expand Up @@ -55,9 +55,12 @@ def myHandler(sender, instance, **kwargs):
if instance.type.is_critical:
alarm = Alarm(event=instance)
alarm.save()
instance.sensor.current_status_id = instance.status
instance.sensor.current_pos_x = instance.pos_x
instance.sensor.current_pos_y = instance.pos_y
if instance.status is not None:
instance.sensor.current_status_id = instance.status
if instance.pos_x is not None:
instance.sensor.current_pos_x = instance.pos_x
if instance.pos_y is not None:
instance.sensor.current_pos_y = instance.pos_y
instance.sensor.current_date = instance.timestamp
instance.sensor.save()

Expand Down
Loading

0 comments on commit b428e89

Please sign in to comment.