Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
Update to Django 1.9.2 and Device modification to read one tag and sa…
Browse files Browse the repository at this point in the history
…ve it for later assign it to a user.
  • Loading branch information
torehc committed Feb 3, 2016
1 parent f533b72 commit 922ca20
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
20 changes: 20 additions & 0 deletions web/carontepass/access/migrations/0013_auto_20160203_1405.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-02-03 14:05
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('access', '0012_auto_20151221_1239'),
]

operations = [
migrations.AlterField(
model_name='device',
name='kind',
field=models.CharField(choices=[(b'nfc', b'NFC'), (b'mac', b'MAC'), (b'tag', b'TAG')], default=b'nfc', max_length=3),
),
]
10 changes: 10 additions & 0 deletions web/carontepass/access/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ class Device(models.Model):

NFC = 'nfc'
MAC = 'mac'
TAG = 'tag'
DEVICE_CHOICES = (
(NFC, 'NFC'),
(MAC, 'MAC'),
(TAG, 'TAG'),
)

user = models.ForeignKey('User')
Expand All @@ -104,6 +106,14 @@ class Device(models.Model):

def __str__(self):
return 'Device {}:{} - {}'.format(self.user, self.kind, self.code)

@staticmethod
def check_exists_device(code_id):
#If there is no device code creates a new one.
#With this you have saved the new devices and then assign them to your user.
if not Device.objects.filter(code=code_id):
caronte = User.objects.filter(name="Caronte").first()
device_create = Device.objects.create(user=caronte, kind='tag', code=code_id)


class Log(models.Model):
Expand Down
6 changes: 3 additions & 3 deletions web/carontepass/access/telegram_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import urllib3
urllib3.disable_warnings()

from carontepass.settings import TOKEN_BOT
from carontepass.settings import TOKEN_BOT, ID_CHAT_RECEIVER

#Receptor chat id
IDchatReceiver = 'XXXXXX'
#id of the person receiving the telegram messages
IDchatReceiver = ID_CHAT_RECEIVER

tb = telebot.TeleBot(TOKEN_BOT)

Expand Down
2 changes: 2 additions & 0 deletions web/carontepass/access/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ def get_queryset(self, **kwargs):

code_id = self.kwargs['code']

Device.check_exists_device(code_id)

return Device.objects.filter(code=code_id)

2 changes: 1 addition & 1 deletion web/carontepass/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django==1.8.6
Django==1.9.2
django-debug-toolbar
djangorestframework
urllib3
Expand Down

0 comments on commit 922ca20

Please sign in to comment.