예제 #1
0
 def required_fields_dec(required_list):
    for key in request.POST:
         if key not in required_fields:
             response = { 
                 'error': {
                     'code': 500,
                     'message': "Missing field required"
                 }
             }
             return HttpResponse(serializers.serializers('json'), [response]))
예제 #2
0
@required_fields(['password', 'new_password'])
def change_password(request, bcuser_id):
    u = BCUser.objects.get(pk=bcuser_id) 
    if check_password(request.POST['password'], u.password):
        u.password = make_password(request.POST['new_password'])
        response = {
            'status': 'success'
        }
    else:
        response = { 
            'error': {
                'code': 500,
                'message': "Invalid password"
            }
        }
    return HttpResponse(serializers.serializers('json'), [response]))

@required_POST
@required_fields(['password'])
def delete(request, bcuser_id):
    if check_password(request.POST['password'], u.password): 
        u = BCUser.objects.get(pk=bcuser_id)
        u.delete()
        u.save()
        response = {
            'status': 'success'
        }
    else:
        response = {
            'error': {
                'code': 500,
예제 #3
0
def get_supply_chains(request):
  chains = SupplyChain.objects.all()
  response = serializers.serializers('json', chains)
  return HttpResponse(response, mimetype='application/json')