Example #1
0
def get_kindergartens(request):
    data = []
    for sadik in Sadik.objects.all():
        data.append({
            'id': sadik.id,
            'address': sadik.address.text,
            'phone': sadik.phone,
            'name': sadik.short_name,
            'head_name': sadik.head_name,
            'email': sadik.email,
            'site': sadik.site,
        })
    response = [{'sign': gpgtools.sign_data(data).data, 'data': data}]
    return HttpResponse(json.dumps(response), content_type='text/json')
Example #2
0
def api_sign_test(request):
    status = 'error'
    msgs = []
    if request.method == 'GET':
        msgs.append("Wrong method, use POST instead of GET")
    signed_data = request.POST.get('signed_data')
    if not (signed_data and gpgtools.check_data_sign(
            {'data': request.POST.get('test_string'), 'sign': signed_data})):
        msgs.append("Sing check error")
    test_string = request.POST.get('test_string')
    if not test_string == u"Проверочная строка":
        msgs.append("wrong test_string")
    if not msgs:
        status = 'ok'
        msgs = ["All passed"]
    response = {'sign': gpgtools.sign_data(test_string.encode('utf8')).data,
                'data': msgs, 'status': status}
    return JSONResponse(response)
Example #3
0
def api_test(request):
    status = 'error'
    msg = None
    if request.method == 'GET':
        msg = "Wrong method, use POST instead of GET"
    signed_data = request.POST.get('signed_data')
    if not (signed_data and gpgtools.check_data_sign(
            {'data': request.POST.get('test_string'), 'sign': signed_data})):
        msg = "Sing check error"
    test_string = request.POST.get('test_string')
    if not test_string == u"Проверочная строка":
        msg = "wrong test_string"
    if not msg:
        status = 'ok'
        msg = "All passed"
    response = [{'sign': gpgtools.sign_data(msg).data,
                 'data': msg, 'status': status}]
    return HttpResponse(simplejson.dumps(response), mimetype='text/json')
Example #4
0
def get_child(request):
    if request.method == 'GET':
        raise Http404
    data = json.loads(request.body)
    if not data['data']:
        return HttpResponse()
    if gpgtools.check_data_sign(data):
        requestion_ct = ContentType.objects.get_for_model(Requestion)
        requestion_ids = EvidienceDocument.objects.filter(
            content_type=requestion_ct, document_number=data['data'],
            template__destination=REQUESTION_IDENTITY
        ).values_list('object_id', flat=True)
        if not requestion_ids:
            return HttpResponse()
        requestions = Requestion.objects.filter(id__in=requestion_ids)
        data = add_requestions_data(requestions, request)
        response = [{'sign': gpgtools.sign_data(data).data, 'data': data}]
        return HttpResponse(json.dumps(response), content_type='text/json')
    raise Http404