Created
September 30, 2014 16:00
-
-
Save jsplink/6e39f9e2fc07af4221e9 to your computer and use it in GitHub Desktop.
the kitchen sink
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
@login_required | |
@csrf_exemp | |
def stamp_detail(self, request): | |
# (N) login adapted from stamps.views.observe | |
# grab the stamp from the DB | |
GRID_SHAPES = [(4, 5), (7, 9), (13, 17)] | |
try: | |
request.META['HTTP_USER_AGENT'] = request.GET.get('uagent') | |
apicall = get_stamp( | |
request=request, | |
return_apicall=True | |
) | |
except Stamp.DoesNotExist: | |
pass | |
if apicall: | |
response = { | |
'sessionId': request.GET.get('session_id'), | |
'testId': request.GET.get('test_id'), | |
'receipt': apicall.receipt, | |
'stamp': { | |
'points': request.GET.get('points'), | |
'origin': { | |
'id': apicall.stamp.id, | |
'gridShape': GRID_SHAPES[apicall.stamp.grid_shape], | |
'version': apicall.stamp.version, | |
'serial': apicall.stamp.serial, | |
'coords': [ | |
[apicall.stamp.x1, apicall.stamp.y1], | |
[apicall.stamp.x2, apicall.stamp.y2], | |
[apicall.stamp.x3, apicall.stamp.y3] | |
], | |
'constants': { | |
'MINIMUM_POINT_DISTANCE': apicall.stamp.MINIMUM_POINT_DISTANCE, | |
'ANCHOR_POINT_MIN': apicall.stamp.ANCHOR_POINT_MIN, | |
'ANCHOR_POINT_MAX': apicall.stamp.ANCHOR_POINT_MAX, | |
'ANCHOR_POINT_DISTANCE': apicall.stamp.ANCHOR_POINT_DISTANCE, | |
'CENTER': apicall.stamp.CENTER, | |
'GRID_SHAPES': apicall.stamp.GRID_SHAPES | |
} | |
}, | |
'metrics': { | |
'scale': apicall.scale, | |
'translation': [apicall.translation_x, apicall.translation_y], | |
'rotation': apicall.rotation, | |
'replayedRequest': apicall.data | |
}, | |
'observation': { | |
'id': apicall.stampobservation.id, | |
'gridShape': GRID_SHAPES[apicall.stampobservation.grid_shape], | |
'version': apicall.stampobservation.version, | |
'serial': apicall.stampobservation.serial, | |
'points': [ | |
[apicall.stampobservation.x1, apicall.stampobservation.y1], | |
[apicall.stampobservation.x2, apicall.stampobservation.y2], | |
[apicall.stampobservation.x3, apicall.stampobservation.y3] | |
], | |
'constants': { | |
'MINIMUM_POINT_DISTANCE': apicall.stampobservation.MINIMUM_POINT_DISTANCE, | |
'ANCHOR_POINT_MIN': apicall.stampobservation.ANCHOR_POINT_MIN, | |
'ANCHOR_POINT_MAX': apicall.stampobservation.ANCHOR_POINT_MAX, | |
'ANCHOR_POINT_DISTANCE': apicall.stampobservation.ANCHOR_POINT_DISTANCE, | |
'CENTER': apicall.stampobservation.CENTER, | |
'GRID_SHAPES': apicall.stampobservation.GRID_SHAPES | |
} | |
} | |
} | |
} | |
else: | |
response = {'stamp_id': False} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment