diff --git a/ExEcommerce/__pycache__/__init__.cpython-38.pyc b/ExEcommerce/__pycache__/__init__.cpython-38.pyc index 4fdba20..4bd19a8 100644 Binary files a/ExEcommerce/__pycache__/__init__.cpython-38.pyc and b/ExEcommerce/__pycache__/__init__.cpython-38.pyc differ diff --git a/ExEcommerce/__pycache__/settings.cpython-38.pyc b/ExEcommerce/__pycache__/settings.cpython-38.pyc index 88da244..e0d5012 100644 Binary files a/ExEcommerce/__pycache__/settings.cpython-38.pyc and b/ExEcommerce/__pycache__/settings.cpython-38.pyc differ diff --git a/ExEcommerce/__pycache__/urls.cpython-38.pyc b/ExEcommerce/__pycache__/urls.cpython-38.pyc index 0a1243a..8b0af73 100644 Binary files a/ExEcommerce/__pycache__/urls.cpython-38.pyc and b/ExEcommerce/__pycache__/urls.cpython-38.pyc differ diff --git a/ExEcommerce/__pycache__/wsgi.cpython-38.pyc b/ExEcommerce/__pycache__/wsgi.cpython-38.pyc index bdd487d..93c8d8c 100644 Binary files a/ExEcommerce/__pycache__/wsgi.cpython-38.pyc and b/ExEcommerce/__pycache__/wsgi.cpython-38.pyc differ diff --git a/ExEcommerce/settings.py b/ExEcommerce/settings.py index 274e968..1ae68c0 100644 --- a/ExEcommerce/settings.py +++ b/ExEcommerce/settings.py @@ -39,7 +39,8 @@ 'django.contrib.staticfiles', 'Productos', 'rest_framework', - 'rest_framework.authtoken' + 'rest_framework.authtoken', + 'cheackout1130619212' ] REST_FRAMEWORK = { diff --git a/ExEcommerce/urls.py b/ExEcommerce/urls.py index a28b9fb..012683a 100644 --- a/ExEcommerce/urls.py +++ b/ExEcommerce/urls.py @@ -3,5 +3,6 @@ urlpatterns = [ path('admin/', admin.site.urls), - path('productos/api/', include('Productos.urls')) + path('productos/api/', include('Productos.urls')), + path('checkout/api/', include('cheackout1130619212.urls')), ] diff --git a/Productos/__pycache__/__init__.cpython-38.pyc b/Productos/__pycache__/__init__.cpython-38.pyc index 12858eb..3e5eec6 100644 Binary files a/Productos/__pycache__/__init__.cpython-38.pyc and b/Productos/__pycache__/__init__.cpython-38.pyc differ diff --git a/Productos/__pycache__/admin.cpython-38.pyc b/Productos/__pycache__/admin.cpython-38.pyc index 5e45772..a1be199 100644 Binary files a/Productos/__pycache__/admin.cpython-38.pyc and b/Productos/__pycache__/admin.cpython-38.pyc differ diff --git a/Productos/__pycache__/apps.cpython-38.pyc b/Productos/__pycache__/apps.cpython-38.pyc new file mode 100644 index 0000000..77a9e76 Binary files /dev/null and b/Productos/__pycache__/apps.cpython-38.pyc differ diff --git a/Productos/__pycache__/models.cpython-38.pyc b/Productos/__pycache__/models.cpython-38.pyc index 39e54e5..78f3529 100644 Binary files a/Productos/__pycache__/models.cpython-38.pyc and b/Productos/__pycache__/models.cpython-38.pyc differ diff --git a/Productos/__pycache__/serializers.cpython-38.pyc b/Productos/__pycache__/serializers.cpython-38.pyc index dea7d34..81a55af 100644 Binary files a/Productos/__pycache__/serializers.cpython-38.pyc and b/Productos/__pycache__/serializers.cpython-38.pyc differ diff --git a/Productos/__pycache__/urls.cpython-38.pyc b/Productos/__pycache__/urls.cpython-38.pyc index e7d36ca..c5bfc67 100644 Binary files a/Productos/__pycache__/urls.cpython-38.pyc and b/Productos/__pycache__/urls.cpython-38.pyc differ diff --git a/Productos/__pycache__/views.cpython-38.pyc b/Productos/__pycache__/views.cpython-38.pyc index a696ef1..7ff4f08 100644 Binary files a/Productos/__pycache__/views.cpython-38.pyc and b/Productos/__pycache__/views.cpython-38.pyc differ diff --git a/Productos/migrations/__pycache__/0001_initial.cpython-38.pyc b/Productos/migrations/__pycache__/0001_initial.cpython-38.pyc index a8fb162..b844bfb 100644 Binary files a/Productos/migrations/__pycache__/0001_initial.cpython-38.pyc and b/Productos/migrations/__pycache__/0001_initial.cpython-38.pyc differ diff --git a/Productos/migrations/__pycache__/0002_auto_20210916_1521.cpython-38.pyc b/Productos/migrations/__pycache__/0002_auto_20210916_1521.cpython-38.pyc index 0dcf924..290db67 100644 Binary files a/Productos/migrations/__pycache__/0002_auto_20210916_1521.cpython-38.pyc and b/Productos/migrations/__pycache__/0002_auto_20210916_1521.cpython-38.pyc differ diff --git a/Productos/migrations/__pycache__/__init__.cpython-38.pyc b/Productos/migrations/__pycache__/__init__.cpython-38.pyc index fb60fc5..e92bcff 100644 Binary files a/Productos/migrations/__pycache__/__init__.cpython-38.pyc and b/Productos/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/cheackout1130619212/__init__.py b/cheackout1130619212/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cheackout1130619212/__pycache__/__init__.cpython-38.pyc b/cheackout1130619212/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..b38c785 Binary files /dev/null and b/cheackout1130619212/__pycache__/__init__.cpython-38.pyc differ diff --git a/cheackout1130619212/__pycache__/admin.cpython-38.pyc b/cheackout1130619212/__pycache__/admin.cpython-38.pyc new file mode 100644 index 0000000..c9d8d5c Binary files /dev/null and b/cheackout1130619212/__pycache__/admin.cpython-38.pyc differ diff --git a/cheackout1130619212/__pycache__/apps.cpython-38.pyc b/cheackout1130619212/__pycache__/apps.cpython-38.pyc new file mode 100644 index 0000000..a50829e Binary files /dev/null and b/cheackout1130619212/__pycache__/apps.cpython-38.pyc differ diff --git a/cheackout1130619212/__pycache__/models.cpython-38.pyc b/cheackout1130619212/__pycache__/models.cpython-38.pyc new file mode 100644 index 0000000..60fa965 Binary files /dev/null and b/cheackout1130619212/__pycache__/models.cpython-38.pyc differ diff --git a/cheackout1130619212/__pycache__/serializador.cpython-38.pyc b/cheackout1130619212/__pycache__/serializador.cpython-38.pyc new file mode 100644 index 0000000..a673400 Binary files /dev/null and b/cheackout1130619212/__pycache__/serializador.cpython-38.pyc differ diff --git a/cheackout1130619212/__pycache__/urls.cpython-38.pyc b/cheackout1130619212/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000..4d81a3b Binary files /dev/null and b/cheackout1130619212/__pycache__/urls.cpython-38.pyc differ diff --git a/cheackout1130619212/__pycache__/views.cpython-38.pyc b/cheackout1130619212/__pycache__/views.cpython-38.pyc new file mode 100644 index 0000000..115ec3d Binary files /dev/null and b/cheackout1130619212/__pycache__/views.cpython-38.pyc differ diff --git a/cheackout1130619212/admin.py b/cheackout1130619212/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/cheackout1130619212/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/cheackout1130619212/apps.py b/cheackout1130619212/apps.py new file mode 100644 index 0000000..1b7ac24 --- /dev/null +++ b/cheackout1130619212/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class Cheackout1130619212Config(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'cheackout1130619212' diff --git a/cheackout1130619212/migrations/0001_initial.py b/cheackout1130619212/migrations/0001_initial.py new file mode 100644 index 0000000..820374e --- /dev/null +++ b/cheackout1130619212/migrations/0001_initial.py @@ -0,0 +1,49 @@ +# Generated by Django 3.2.7 on 2021-09-21 02:24 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('Productos', '0002_auto_20210916_1521'), + ] + + operations = [ + migrations.CreateModel( + name='CarritoCompras', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('usuario', models.CharField(blank=True, max_length=200, null=True)), + ('fecha', models.DateField(auto_now_add=True)), + ('descuento', models.FloatField(blank=True, max_length=7, null=True)), + ('CantMinima', models.IntegerField(blank=True, max_length=7, null=True)), + ('pagado', models.BooleanField()), + ], + ), + migrations.CreateModel( + name='InfoEnvio', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('nombre', models.CharField(blank=True, max_length=200, null=True)), + ('apellido', models.CharField(blank=True, max_length=300, null=True)), + ('direccion', models.CharField(blank=True, max_length=300, null=True)), + ('pais', models.CharField(blank=True, max_length=300, null=True)), + ('departamento', models.CharField(blank=True, max_length=300, null=True)), + ('ciudad', models.CharField(blank=True, max_length=300, null=True)), + ('carrito', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cheackout1130619212.carritocompras')), + ], + ), + migrations.CreateModel( + name='Articulo', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('cantidad', models.IntegerField(blank=True, max_length=7, null=True)), + ('carrito', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cheackout1130619212.carritocompras')), + ('producto', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Productos.producto')), + ], + ), + ] diff --git a/cheackout1130619212/migrations/__init__.py b/cheackout1130619212/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/cheackout1130619212/migrations/__pycache__/0001_initial.cpython-38.pyc b/cheackout1130619212/migrations/__pycache__/0001_initial.cpython-38.pyc new file mode 100644 index 0000000..85ad350 Binary files /dev/null and b/cheackout1130619212/migrations/__pycache__/0001_initial.cpython-38.pyc differ diff --git a/cheackout1130619212/migrations/__pycache__/__init__.cpython-38.pyc b/cheackout1130619212/migrations/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..accf711 Binary files /dev/null and b/cheackout1130619212/migrations/__pycache__/__init__.cpython-38.pyc differ diff --git a/cheackout1130619212/models.py b/cheackout1130619212/models.py new file mode 100644 index 0000000..e14d2f9 --- /dev/null +++ b/cheackout1130619212/models.py @@ -0,0 +1,46 @@ +from django.db import models +from django.db.models.fields import BooleanField, CharField, DateField, FloatField, IntegerField +from django.db.models.fields.related import ForeignKey +from Productos.models import * + + + +class CarritoCompras (models.Model): + usuario = CharField(max_length=200,null=True,blank=True) + fecha = DateField(auto_now_add=True) + descuento = FloatField(max_length=7,null=True,blank=True) + CantMinima = IntegerField(max_length=7,null=True,blank=True) + pagado = BooleanField() + + def total(): + pass + def __str__(self): + return self.usuario + def numArt(): + pass + +class Articulo(models.Model): + carrito = ForeignKey(CarritoCompras, on_delete=models.CASCADE) + producto = ForeignKey(Producto, on_delete=models.CASCADE) + cantidad = IntegerField(max_length=7,null=True,blank=True) + + def __str__(self): + return self.carrito + + def subtotal(): + pass + +class InfoEnvio(models.Model): + carrito = ForeignKey(CarritoCompras, on_delete=models.CASCADE) + nombre = CharField(max_length=200,null=True,blank=True) + apellido = CharField(max_length=300,blank=True,null=True) + direccion = CharField(max_length=300,blank=True,null=True) + pais = CharField(max_length=300,blank=True,null=True) + departamento = CharField(max_length=300,blank=True,null=True) + ciudad = CharField(max_length=300,blank=True,null=True) + + def __str__(self): + return self.nombre + + +# Create your models here. diff --git a/cheackout1130619212/serializador.py b/cheackout1130619212/serializador.py new file mode 100644 index 0000000..d9c7d9c --- /dev/null +++ b/cheackout1130619212/serializador.py @@ -0,0 +1,18 @@ +from rest_framework import serializers + +from cheackout1130619212.models import * + +class CarritoSerial(serializers.ModelSerializer): + class Meta: + model = CarritoCompras + fields = '__all__' + +class ArticuloSerial(serializers.ModelSerializer): + class Meta: + model = Articulo + fields = '__all__' + +class InfoSerial(serializers.ModelSerializer): + class Meta: + model = InfoEnvio + fields = '__all__' diff --git a/cheackout1130619212/tests.py b/cheackout1130619212/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/cheackout1130619212/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/cheackout1130619212/urls.py b/cheackout1130619212/urls.py new file mode 100644 index 0000000..0fd87e3 --- /dev/null +++ b/cheackout1130619212/urls.py @@ -0,0 +1,17 @@ + +from django.urls import path, include + +from rest_framework.routers import DefaultRouter + +from cheackout1130619212.views import * + +router = DefaultRouter() +router.register('Carrito', CarritoAPI) +router.register('Articulo',ArticuloAPI,basename='Arti') +router.register('Info',InfoAPI) + +urlpatterns = [ + path('crud/', include(router.urls)) +] + +#localhost:8000/cheackout/api/crud/ \ No newline at end of file diff --git a/cheackout1130619212/views.py b/cheackout1130619212/views.py new file mode 100644 index 0000000..c6e2185 --- /dev/null +++ b/cheackout1130619212/views.py @@ -0,0 +1,34 @@ +from django.http.response import Http404 +from django.shortcuts import render +from rest_framework.status import HTTP_400_BAD_REQUEST + +from rest_framework import viewsets +from rest_framework.response import Response + +from cheackout1130619212.models import * + +from cheackout1130619212.serializador import * + +class CarritoAPI (viewsets.ModelViewSet): + serializer_class = CarritoSerial + queryset = CarritoCompras.objects.all() + +class ArticuloAPI (viewsets.ViewSet): + def list (self, request): + articulos=Articulo.objects.all() + serializar = ArticuloSerial(articulos, many=True) + return Response(serializar.data) + + def create(self,request): + serial=ArticuloSerial(data=request.data) + if serial.is_valid(): + serial.save() + return Response ({'Creados':True}) + return Response(serial.errors, HTTP_400_BAD_REQUEST) + + +class InfoAPI (viewsets.ModelViewSet): + serializer_class = InfoSerial + queryset = InfoEnvio.objects.all() + + diff --git a/db.sqlite3 b/db.sqlite3 deleted file mode 100644 index 65d1360..0000000 Binary files a/db.sqlite3 and /dev/null differ