Пример #1
0
def getParts(request):
    try:
        data = json.loads(request.body)
        try:
            token = Token.objects.filter(token=data['token']).first()
            user = token.user
        except:
            raise myError('Please Log In.')
        part_name = data['part_name']
        searchResult = getPart(part_name)
        if searchResult['successful']:
            result = {
                'successful': True,
                'data': searchResult,
                'error': {
                    'id': '',
                    'msg': '',
                }
            }
        else:
            raise myError('Check Failed.')
    except myError, e:
        result = {
            'successful': False,
            'error': {
                'id': '',
                'msg': e.value,
            }
        }
Пример #2
0
def getParts(request):
    try:
        data = json.loads(request.body)
        try:
            token = Token.objects.filter(token=data['token']).first()
            user = token.user
        except:
            raise myError('Please Log In.')
        part_name = data['part_name']
        searchResult = getPart(part_name)
        if searchResult['successful']:
            result = {
                'successful': True,
                'data': searchResult,
                'error': {
                    'id': '',
                    'msg': '',
                }
            }
        else:
            raise myError('Check Failed.')
    except myError, e:
        result = {
            'successful': False,
            'error': {
                'id': '',
                'msg': e.value,
            }
        }
Пример #3
0
def getParts(request):
    partName = request.GET.get('partname')
    results = getPart(partName)
    return HttpResponse(json.dumps(results), content_type="text/json")