def add_ticket_element(request):
    outlet_id = request.POST.get('id_outlet', None)
    type = request.POST.get('type', None).upper()
    comment = request.POST.get('comment', None)
    urgency = request.POST.get('urgency', None).upper()
    image = request.FILES.get('picture', None)
    outlet = Element.objects.filter(id=outlet_id).first()
    if (outlet is None):
        return HttpResponse("Impossible de trouver la sortie d'eau correspondante au ticket", status=400)
    if (not has_access(outlet, request)):
        return HttpResponse("Vous n'avez pas les droits sur cet élément de réseau", status=403)
    if image:
        import uuid
        extension = image.name.split('.')
        filename = str(uuid.uuid4())
        image.name = ((filename + '.') + extension[1])
    ticket = Ticket(water_outlet=outlet, type=type, comment=comment, urgency=urgency, image=image)
    log_element(ticket, request)
    json_object = {'data': ticket.descript(), 'type': 'add', 'table': 'ticket'}
    return HttpResponse(json.dumps(json_object), status=200)
def add_ticket_element(request):
    outlet_id = request.POST.get('id_outlet', None)
    type = request.POST.get('type', None).upper()
    comment = request.POST.get('comment', None)
    urgency = request.POST.get('urgency', None).upper()
    image = request.FILES.get('picture', None)
    outlet = Element.objects.filter(id=outlet_id).first()
    if (outlet is None):
        return HttpResponse("Impossible de trouver la sortie d'eau correspondante au ticket", status=400)
    if (not has_access(outlet, request)):
        return HttpResponse("Vous n'avez pas les droits sur cet élément de réseau", status=403)
    if image:
        import uuid
        extension = image.name.split('.')
        filename = str(uuid.uuid4())
        image.name = ((filename + '.') + extension[1])
    ticket = Ticket(water_outlet=outlet, type=type, comment=comment, urgency=urgency, image=image)
    log_element(ticket, request)
    json_object = {'data': ticket.descript(), 'type': 'add', 'table': 'ticket'}
    return HttpResponse(json.dumps(json_object), status=200)