예제 #1
0
파일: views.py 프로젝트: dcaulton/spectro
 def retrieve(self, request, pk=None):  # TODO add tests for this
     '''
     Extending the default rest_framework endpoint for fetch one group to support the custom path/pseudo id of /groups/current
     That's the one pointed to by the settings record
     Note that the 'current' id does NOT work for updates/deletes, etc.
     '''
     if pk == 'current':
         group = get_current_group()
     else:  # TODO just defer to super() from here on
         group = get_object_or_404(self.queryset, pk=pk)
     serializer = GroupSerializer(group)
     return Response(serializer.data)
예제 #2
0
파일: views.py 프로젝트: adaniy/spectro
 def retrieve(self, request, pk=None):  # TODO add tests for this
     '''
     Extending the default rest_framework endpoint for fetch one group to support the custom path/pseudo id of /groups/current
     That's the one pointed to by the settings record
     Note that the 'current' id does NOT work for updates/deletes, etc.
     '''
     if pk == 'current':
         group = get_current_group()
     else:  # TODO just defer to super() from here on
         group = get_object_or_404(self.queryset, pk=pk)
     serializer = GroupSerializer(group)
     return Response(serializer.data)
예제 #3
0
파일: views.py 프로젝트: dcaulton/spectro
def capture_sample(request):
    '''
    Calls the chain of tasks associated with getting a physical sample from the spectrometer according to the parameters
        specified in the current active group from (the settings record)
    Tasks are run asynchronously, relevant ids for created objects are returned
    '''
    group = get_current_group()

    try:
        response_dict = capture_sample_task(group)
        return Response(response_dict)
    except Exception as e:
        return Response(get_error_string_for_api(e), status=e.status_code)
예제 #4
0
파일: views.py 프로젝트: adaniy/spectro
def capture_sample(request):
    '''
    Calls the chain of tasks associated with getting a physical sample from the spectrometer according to the parameters
        specified in the current active group from (the settings record)
    Tasks are run asynchronously, relevant ids for created objects are returned
    '''
    group = get_current_group()

    try:
        response_dict = capture_sample_task(group)
        return Response(response_dict)
    except Exception as e:
        return Response(get_error_string_for_api(e), status=e.status_code)
예제 #5
0
파일: views.py 프로젝트: dcaulton/spectro
def calibrate(request):
    '''
    Take a sample according to the current group config.
    Compare its data to the reference_sample_id passed in as a get parm
    On success return a SampleDelta object with the differences between the two samples
    '''
    # TODO add logic and tests for null reference_sample_id
    group = get_current_group()

    if 'reference_sample_id' in request.query_params and request.query_params['reference_sample_id']:
        try:
            return_data = calibrate_task(group, request.query_params['reference_sample_id'])
            return Response(return_data)
        except Exception as e:
            return Response(get_error_string_for_api(e), status=e.status_code)
    else:  # TODO add a test for this condition
        err_message = 'An id must be specified for a reference sample'
        return Response(data=err_message, status=409)
예제 #6
0
파일: views.py 프로젝트: adaniy/spectro
def calibrate(request):
    '''
    Take a sample according to the current group config.
    Compare its data to the reference_sample_id passed in as a get parm
    On success return a SampleDelta object with the differences between the two samples
    '''
    # TODO add logic and tests for null reference_sample_id
    group = get_current_group()

    if 'reference_sample_id' in request.query_params and request.query_params[
            'reference_sample_id']:
        try:
            return_data = calibrate_task(
                group, request.query_params['reference_sample_id'])
            return Response(return_data)
        except Exception as e:
            return Response(get_error_string_for_api(e), status=e.status_code)
    else:  # TODO add a test for this condition
        err_message = 'An id must be specified for a reference sample'
        return Response(data=err_message, status=409)