diff --git a/bodegaTerrazaDelChupi/__pycache__/settings.cpython-37.pyc b/bodegaTerrazaDelChupi/__pycache__/settings.cpython-37.pyc new file mode 100644 index 0000000..e117b2d Binary files /dev/null and b/bodegaTerrazaDelChupi/__pycache__/settings.cpython-37.pyc differ diff --git a/bodegaTerrazaDelChupi/__pycache__/urls.cpython-37.pyc b/bodegaTerrazaDelChupi/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000..f84442f Binary files /dev/null and b/bodegaTerrazaDelChupi/__pycache__/urls.cpython-37.pyc differ diff --git a/bodegaTerrazaDelChupi/__pycache__/wsgi.cpython-37.pyc b/bodegaTerrazaDelChupi/__pycache__/wsgi.cpython-37.pyc new file mode 100644 index 0000000..3e50a41 Binary files /dev/null and b/bodegaTerrazaDelChupi/__pycache__/wsgi.cpython-37.pyc differ diff --git a/bodegaTerrazaDelChupi/urls.py b/bodegaTerrazaDelChupi/urls.py index a93c515..6d951ab 100644 --- a/bodegaTerrazaDelChupi/urls.py +++ b/bodegaTerrazaDelChupi/urls.py @@ -32,7 +32,7 @@ #2 Add URL maps to redirect the base URL to our application from django.views.generic import RedirectView urlpatterns += [ - path('', RedirectView.as_view(url='/catalogo/', permanent=True)), + path('/', RedirectView.as_view(url='/catalogo/', permanent=True)), ] #3 Use static() to add url mapping to serve static files during development (only) diff --git a/catalogo/__pycache__/admin.cpython-37.pyc b/catalogo/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000..1f0c7ac Binary files /dev/null and b/catalogo/__pycache__/admin.cpython-37.pyc differ diff --git a/catalogo/__pycache__/apps.cpython-37.pyc b/catalogo/__pycache__/apps.cpython-37.pyc new file mode 100644 index 0000000..2bf2ab1 Binary files /dev/null and b/catalogo/__pycache__/apps.cpython-37.pyc differ diff --git a/catalogo/__pycache__/models.cpython-37.pyc b/catalogo/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000..393f822 Binary files /dev/null and b/catalogo/__pycache__/models.cpython-37.pyc differ diff --git a/catalogo/__pycache__/urls.cpython-37.pyc b/catalogo/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000..82d9524 Binary files /dev/null and b/catalogo/__pycache__/urls.cpython-37.pyc differ diff --git a/catalogo/__pycache__/views.cpython-37.pyc b/catalogo/__pycache__/views.cpython-37.pyc new file mode 100644 index 0000000..6074d76 Binary files /dev/null and b/catalogo/__pycache__/views.cpython-37.pyc differ diff --git a/catalogo/models.py b/catalogo/models.py index f0351e4..84d00a8 100644 --- a/catalogo/models.py +++ b/catalogo/models.py @@ -1,73 +1,73 @@ -from django.db import models +from django.db import models -#Create your models here +#Create your models here - -class Bebida(models.Model): + +class Bebida(models.Model): """ - + Modelo que representa una bebida. - - """ - + + """ + nombre = models.CharField(max_length=200) - - + + tamanho = models.IntegerField(help_text="Ingresar solo números en mililitros (ml)") - - sabor = models.CharField(max_length=30) - + + sabor = models.CharField(max_length=30) + proveedor = models.CharField (max_length=200) - - + + GASEOSA = 'GASE' - + CERVEZA = 'CERV' - + WHISKY = 'WHIS' - + VODKA = 'VOD' - + TIPO_BEBIDA = ( - - (GASEOSA, 'Gaseosa'), + + (GASEOSA, 'Gaseosa'), (CERVEZA, 'Cerveza'), - + (WHISKY, 'Whisky'), - - (VODKA, 'Vodka'), - ) - + (VODKA, 'Vodka'), + + ) + tipo = models.CharField (max_length = 4, choices = TIPO_BEBIDA, default = GASEOSA) - - + + contenido_alcohol = models.IntegerField(default=0) - + precio = models.IntegerField(default=0) - - + + stock = models.IntegerField(default=0) - - - def __str__(self): + + + def __str__(self): """ - + String que representa al objeto Bebida - - """ - return self.nombre - - - + """ + + return self.nombre + + + class Cliente (models.Model): @@ -76,28 +76,28 @@ class Cliente (models.Model): ruc = models.CharField(max_length=200) telefono = models.CharField(max_length=200) - def __str__(self): + def __str__(self): """ - + String que representa al objeto Cliente - - """ - return self.nombre - - - + """ + + return self.nombre + + + class Pedido(models.Model): """ - + Modelo que representa un pedido. - - """ - + + """ + no_pedido = models.CharField(max_length=10, unique=True, primary_key=True) f_pedido = models.DateTimeField(auto_now_add=True) @@ -106,12 +106,12 @@ class Pedido(models.Model): monto_total = models.IntegerField (default=0) CONTADO = 'CONT' CREDITO = 'CRED' - + TIPO_PAGO = ( - - (CONTADO, 'Contado'), - (CREDITO, 'Crédito'), + (CONTADO, 'Contado'), + + (CREDITO, 'Crédito'), ) condicion_pago = models.CharField (max_length = 4, choices = TIPO_PAGO, default = CONTADO) @@ -121,15 +121,15 @@ class Pedido(models.Model): (EFECTIVO, 'Efectivo'), (TARJETA, 'Tarjeta'), ) - + medio_pago = models.CharField (max_length = 4, choices = MEDIO_PAGO, default = EFECTIVO) def __str__(self): """ - + String que representa al objeto Pedido - - """ + + """ return self.no_pedido diff --git a/catalogo/templates/base_generic.html b/catalogo/templates/base_generic.html index d551da7..6c3042a 100644 --- a/catalogo/templates/base_generic.html +++ b/catalogo/templates/base_generic.html @@ -7,7 +7,7 @@ - + {% load static %} @@ -15,19 +15,22 @@ +
-
-
- {% block sidebar %} - - {% endblock %} -
{% block content %}{% endblock %}
diff --git a/catalogo/templates/index.html b/catalogo/templates/index.html index 98b3376..20b8573 100644 --- a/catalogo/templates/index.html +++ b/catalogo/templates/index.html @@ -1,9 +1,9 @@ {% extends "base_generic.html" %} {% block content %} -

Inicio Bodega Terraza Del Chupi

+

Bodega Terraza

-

Bienvenido a Terraza Del Chupi, un sitio web básico de Django desarrollado como tutorial de ejemplo para MITIC.

+

Bienvenido a Terraza, un sitio web básico de Django desarrollado como tutorial de ejemplo para MITIC.

Contenido Dinámico

@@ -13,5 +13,19 @@

Contenido Dinámico

  • Pedidos: {{ num_pedidos }}
  • Bebidas Disponibles: {{ num_bebidas_disponibles }}
  • - + + + + {% for bebida in bebidas %} + + + + + {% endfor %} +
    NombreCantidad
    + {{ bebida.nombre }} + + {{ bebida.stock }} +
    + {% endblock %} \ No newline at end of file diff --git a/catalogo/views.py b/catalogo/views.py index fd0aab0..ec87dff 100644 --- a/catalogo/views.py +++ b/catalogo/views.py @@ -5,7 +5,7 @@ #Create your views here. def index(request): - + # Genera contadores de algunos de los objetos principales num_bebidas = Bebida.objects.all().count() num_pedidos = Pedido.objects.all().count() @@ -13,10 +13,15 @@ def index(request): num_bebidas_disponibles = Bebida.objects.all().aggregate(Sum('stock')) #num_bebidas_disponibles = Bebida.objects.filter(stock__gt=0).count() - + bebidas = Bebida.objects.all() + # Renderiza la plantilla HTML index.html con los datos en la variable contexto return render( request, 'index.html', - context={'num_bebidas':num_bebidas, 'num_pedidos':num_pedidos, 'num_bebidas_disponibles':num_bebidas_disponibles}, - ) \ No newline at end of file + context={'num_bebidas':num_bebidas, 'num_pedidos':num_pedidos, 'num_bebidas_disponibles':num_bebidas_disponibles, 'bebidas': bebidas}, + ) + +def comprar(request): + device_value = request.POST.get('nombre') + print (device_value) diff --git a/db.sqlite3 b/db.sqlite3 index e27fab7..29dc653 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ