Exemple #1
0
def photos_verify(request):
    """ Just verify if picture is valid """
    if request.method == 'GET':
        return json_response({'status': 'FAIL'}, 403)
    elif request.method == 'POST':
        photo = SinglePhotoForm(request.POST, request.FILES)
        if photo.is_valid():
            return json_response({'status': 'OK'})
        else:
            return json_response({'status': 'FAIL'}, 403)
Exemple #2
0
def photos_upload(request):
    """ Upload photos """
    if request.method == 'POST':
        photo = SinglePhotoForm(request.POST, request.FILES)
        if photo.is_valid():
            genitalia = Genitalia(name='',image=request.FILES['photo'])
            already_uploaded = Genitalia.objects.filter(hash=genitalia.get_hash())
            if not already_uploaded:
                genitalia.save()
                return json_response({'status': 'OK'})
            else:
                return json_response({'status': 'FAIL','error': 'Picture already uploaded'}, 403)
        else:
            return json_response({'status': 'FAIL','error': 'Not a valid picture'}, 403)

    return json_response({'status': 'FAIL'}, 403)