cleanup
This commit is contained in:
parent
666d51ba59
commit
ee7a502851
@ -1,3 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
@ -1,6 +1,6 @@
|
|||||||
from hashlib import sha1
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
|
from django.utils.hashcompat import sha_constructor as sha1
|
||||||
from django.utils import simplejson as json
|
from django.utils import simplejson as json
|
||||||
|
|
||||||
class LayarException(Exception):
|
class LayarException(Exception):
|
||||||
@ -20,7 +20,7 @@ class POI(object):
|
|||||||
self.line2 = line2 # recommended max len 35
|
self.line2 = line2 # recommended max len 35
|
||||||
self.line3 = line3
|
self.line3 = line3
|
||||||
self.line4 = line4
|
self.line4 = line4
|
||||||
self.type = type
|
self.type = type # must be 0..3
|
||||||
self.attribution = attribution # recommended max len 45
|
self.attribution = attribution # recommended max len 45
|
||||||
self.actions = actions
|
self.actions = actions
|
||||||
|
|
||||||
@ -45,6 +45,7 @@ class LayarView(object):
|
|||||||
|
|
||||||
results_per_page = 15
|
results_per_page = 15
|
||||||
max_results = 50
|
max_results = 50
|
||||||
|
verify_hash = True
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.developer_key = settings.LAYAR_DEVELOPER_KEY
|
self.developer_key = settings.LAYAR_DEVELOPER_KEY
|
||||||
@ -64,15 +65,13 @@ class LayarView(object):
|
|||||||
slider = request.GET.get('CUSTOM_SLIDER')
|
slider = request.GET.get('CUSTOM_SLIDER')
|
||||||
page = int(request.GET.get('pageKey', 0))
|
page = int(request.GET.get('pageKey', 0))
|
||||||
|
|
||||||
# oauth: oauth_consumer_key, oauth_signature_method, oauth_timestamp,
|
|
||||||
# oauth_nonce, oauth_version, oauth_signature
|
|
||||||
|
|
||||||
layar_response = dict(hotspots=[], layer=layer_name, errorCode=0,
|
layar_response = dict(hotspots=[], layer=layer_name, errorCode=0,
|
||||||
errorString='ok', nextPageKey=None, morePages=False)
|
errorString='ok', nextPageKey=None, morePages=False)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
# verify hash
|
# verify hash
|
||||||
|
if self.verify_hash:
|
||||||
key = self.developer_key + timestamp
|
key = self.developer_key + timestamp
|
||||||
if sha1(key).hexdigest() != developer_hash:
|
if sha1(key).hexdigest() != developer_hash:
|
||||||
raise LayarException(20, 'Bad developerHash')
|
raise LayarException(20, 'Bad developerHash')
|
||||||
@ -113,4 +112,5 @@ class LayarView(object):
|
|||||||
layar_response['errorString'] = e.message
|
layar_response['errorString'] = e.message
|
||||||
|
|
||||||
content = json.dumps(layar_response)
|
content = json.dumps(layar_response)
|
||||||
return HttpResponse(content, content_type='application/javascript; charset=utf-8')
|
return HttpResponse(content,
|
||||||
|
content_type='application/javascript; charset=utf-8')
|
||||||
|
Loading…
Reference in New Issue
Block a user