Exemplo n.º 1
0
def get_tenderos(request):
    role = getRole(request)
    if role == "Administrador":
        tenderos_list = get_all_tenderos()
        context = {'tenderos_list': tenderos_list}
        return render(request, 'chiper_Totoro/get_all_tenderos.html', context)
    else:
        return HttpResponse("Unauthorized User")
Exemplo n.º 2
0
def get_bodegas(request):
    was_limited = getattr(request, 'limited', False)
    if was_limited:
        return HttpResponseRedirect('/')
    role = getRole(request)
    if role == "Administrador":
        bodegas_list = get_all_bodegas()
        context = {'bodegas_list': bodegas_list}
        return render(request, 'chiper_Totoro/get_all_bodegas.html', context)
    else:
        return HttpResponse("Unauthorized User")
Exemplo n.º 3
0
def get_bodega_id(request, id):
    role = getRole(request)
    if role == "Administrador":
        bodega = get_bodega(id)
        productos_chiper_bodega = get_all_productos_chiper_bodega(id)
        context = {
            'bodega': bodega,
            'productos_chiper_bodega': productos_chiper_bodega
        }
        return render(request, 'chiper_Totoro/get_bodega_id.html', context)
    else:
        return HttpResponse("Unauthorized User")
Exemplo n.º 4
0
def get_tiendas(request):
    """
    renderizacion del html de todas las tiendas
    :param request:
    :return:
    """
    role = getRole(request)
    if role['role'] =='Administrador':
        tiendas_list = get_all_tiendas()
        context = {'tiendas_list': tiendas_list}
        print(context)
        return render(request, 'chiper_Totoro/get_all_tiendas.html', context)
    return HttpResponse('Unauthorized user')
Exemplo n.º 5
0
def create_bodegas(request):
    role = getRole(request)
    if role == "Administrador":
        if request.method == 'POST':
            form = BodegaForm(request.POST)
            if form.is_valid():
                create_a_bodega(form)
                messages.add_message(request, messages.SUCCESS,
                                     'Bodega creada de manera satisfactoria')
                return HttpResponseRedirect(reverse('bodegaList'))
            else:
                print(form.errors)
        else:
            form = BodegaForm()

        context = {
            'form': form,
        }
        return render(request, 'chiper_Totoro/create_bodega.html', context)
    else:
        return HttpResponse("Unauthorized User")
Exemplo n.º 6
0
def get_tienda_id(request, id):
    """
    renderizacion de html de tienda especifica
    :param request:
    :param id: id de la tienda
    :return:
    """
    role = getRole(request)
    mail = ''
    try:
        tendero = get_tendero_tienda(id)
        mail = tendero[0]['mail']
        if role['role'] == 'Administrador' or (role['role'] == 'Propietario' and role['name'] == mail):
            tienda = get_tienda(id)
            productos = get_all_productos_tienda(id)
            productos_tienda = []
            for p in productos:
                product = get_producto(p.producto)[0]
                product['cantidad'] = p.cantidad
                productos_tienda.append(product)
            context = {'tienda': tienda, 'productos_tienda': productos_tienda}
            return render(request, 'chiper_Totoro/get_tienda_id.html', context)
    except:
        return HttpResponse('Unauthorized access')