Revision 66cc3ee3
added tool authentication system. It works!
crm/crm/urls.py | ||
---|---|---|
9 | 9 |
# Examples: |
10 | 10 |
# url(r'^$', 'crm.views.home', name='home'), |
11 | 11 |
# url(r'^crm/', include('crm.foo.urls')), |
12 |
url(r'^roboauth/(?P<rfid_tag>[0-9A-Fa-f]+)/(?P<mach_num>\d+)/', 'crm.robocrm.roboauth'),
|
|
12 |
url(r'^roboauth/(?P<rfid_tag>[0-9A-Fa-f]+)/(?P<mach_num>\d+)/', 'robocrm.views.roboauth'),
|
|
13 | 13 |
|
14 | 14 |
# Uncomment the admin/doc line below to enable admin documentation: |
15 | 15 |
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')), |
crm/robocrm/views.py | ||
---|---|---|
1 | 1 |
# Create your views here. |
2 | 2 |
from django.http import HttpResponse |
3 |
from robocrm.models import * |
|
3 | 4 |
|
4 | 5 |
def index(request): |
5 | 6 |
return HttpResponse("Hello again, world!") |
6 | 7 |
|
7 |
def roboauth(request, rfid_tag, mach_number): |
|
8 |
return HttpResponse("Hello, world!") |
|
9 |
#r = robocrm.objects.filter(rfid=rfid_tag) |
|
10 |
#auth_machines = r.machines.filter(id=mach_number) |
|
11 |
#if auth_machines.count() > 0 : |
|
12 |
# return HttpResponse("1") |
|
13 |
#else |
|
14 |
# return HttpResponse("0") |
|
8 |
def roboauth(request, rfid_tag, mach_num): |
|
9 |
# return HttpResponse("Hello, world!") |
|
10 |
r = RoboUser.objects.filter(rfid=rfid_tag) |
|
11 |
if r.count() > 0: |
|
12 |
us = r[0] |
|
13 |
else: |
|
14 |
return HttpResponse("0") |
|
15 |
auth_machines = us.machines.filter(id=mach_num) |
|
16 |
if auth_machines.count() > 0 : |
|
17 |
return HttpResponse("1") |
|
18 |
else : |
|
19 |
return HttpResponse("0") |
|
15 | 20 |
|
Also available in: Unified diff