def update_location_reviewer(request, project_id=None, node_id=None): """ Updates the reviewer id and review time of a node """ try: # Try to get the review object. If this fails we create a new one. Doing # it in a try/except instead of get_or_create allows us to retrieve the # skeleton ID only if needed. r = Review.objects.get(treenode_id=node_id, reviewer=request.user) except Review.DoesNotExist: r = Review(project_id=project_id, treenode_id=node_id, reviewer=request.user) # Find the skeleton r.skeleton = Treenode.objects.get(pk=node_id).skeleton r.review_time = datetime.now() r.save() return HttpResponse(json.dumps({'reviewer_id': request.user.id}), content_type='text/json')
def update_location_reviewer(request, project_id=None, node_id=None): """ Updates the reviewer id and review time of a node """ try: # Try to get the review object. If this fails we create a new one. Doing # it in a try/except instead of get_or_create allows us to retrieve the # skeleton ID only if needed. r = Review.objects.get(treenode_id=node_id, reviewer=request.user) except Review.DoesNotExist: node = get_object_or_404(Treenode, pk=node_id) r = Review(project_id=project_id, treenode_id=node_id, skeleton_id=node.skeleton_id, reviewer=request.user) r.review_time = timezone.now() r.save() return HttpResponse(json.dumps({ 'reviewer_id': request.user.id, 'review_time': r.review_time.isoformat(), }), content_type='application/json')
def update_location_reviewer(request, project_id=None, node_id=None): """ Updates the reviewer id and review time of a node """ try: # Try to get the review object. If this fails we create a new one. Doing # it in a try/except instead of get_or_create allows us to retrieve the # skeleton ID only if needed. r = Review.objects.get(treenode_id=node_id, reviewer=request.user) except Review.DoesNotExist: node = get_object_or_404(Treenode, pk=node_id) r = Review(project_id=project_id, treenode_id=node_id, skeleton_id=node.skeleton_id, reviewer=request.user) r.review_time = timezone.now() r.save() return JsonResponse({ 'reviewer_id': request.user.id, 'review_time': r.review_time.isoformat(), })
def update_location_reviewer(request, project_id=None, node_id=None): """ Updates the reviewer id and review time of a node """ try: # Try to get the review object. If this fails we create a new one. Doing # it in a try/except instead of get_or_create allows us to retrieve the # skeleton ID only if needed. r = Review.objects.get(treenode_id=node_id, reviewer=request.user) except Review.DoesNotExist: r = Review(project_id=project_id, treenode_id=node_id, reviewer=request.user) # Find the skeleton r.skeleton = Treenode.objects.get(pk=node_id).skeleton r.review_time = datetime.now() r.save() return HttpResponse(json.dumps({ 'reviewer_id': request.user.id, 'review_time': r.review_time.isoformat(), }), content_type='text/json')