diff --git a/Checkout/__pycache__/__init__.cpython-39.pyc b/Checkout/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..9ac3a56 Binary files /dev/null and b/Checkout/__pycache__/__init__.cpython-39.pyc differ diff --git a/Checkout/__pycache__/admin.cpython-39.pyc b/Checkout/__pycache__/admin.cpython-39.pyc new file mode 100644 index 0000000..5c88084 Binary files /dev/null and b/Checkout/__pycache__/admin.cpython-39.pyc differ diff --git a/Checkout/__pycache__/apps.cpython-39.pyc b/Checkout/__pycache__/apps.cpython-39.pyc new file mode 100644 index 0000000..527e704 Binary files /dev/null and b/Checkout/__pycache__/apps.cpython-39.pyc differ diff --git a/Checkout/__pycache__/models.cpython-39.pyc b/Checkout/__pycache__/models.cpython-39.pyc new file mode 100644 index 0000000..9ec8f85 Binary files /dev/null and b/Checkout/__pycache__/models.cpython-39.pyc differ diff --git a/Checkout/__pycache__/serializers.cpython-39.pyc b/Checkout/__pycache__/serializers.cpython-39.pyc new file mode 100644 index 0000000..8ebd912 Binary files /dev/null and b/Checkout/__pycache__/serializers.cpython-39.pyc differ diff --git a/Checkout/__pycache__/urls.cpython-39.pyc b/Checkout/__pycache__/urls.cpython-39.pyc new file mode 100644 index 0000000..6510208 Binary files /dev/null and b/Checkout/__pycache__/urls.cpython-39.pyc differ diff --git a/Checkout/__pycache__/views.cpython-39.pyc b/Checkout/__pycache__/views.cpython-39.pyc new file mode 100644 index 0000000..a6bbcf0 Binary files /dev/null and b/Checkout/__pycache__/views.cpython-39.pyc differ diff --git a/ExEcommerce/__pycache__/__init__.cpython-39.pyc b/ExEcommerce/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..414d558 Binary files /dev/null and b/ExEcommerce/__pycache__/__init__.cpython-39.pyc differ diff --git a/ExEcommerce/__pycache__/settings.cpython-39.pyc b/ExEcommerce/__pycache__/settings.cpython-39.pyc new file mode 100644 index 0000000..47c6476 Binary files /dev/null and b/ExEcommerce/__pycache__/settings.cpython-39.pyc differ diff --git a/ExEcommerce/__pycache__/urls.cpython-39.pyc b/ExEcommerce/__pycache__/urls.cpython-39.pyc new file mode 100644 index 0000000..9fddda4 Binary files /dev/null and b/ExEcommerce/__pycache__/urls.cpython-39.pyc differ diff --git a/ExEcommerce/settings.py b/ExEcommerce/settings.py index 16bb888..177c35d 100644 --- a/ExEcommerce/settings.py +++ b/ExEcommerce/settings.py @@ -41,7 +41,9 @@ 'rest_framework', 'rest_framework.authtoken', 'Checkout', - 'Servicios' + 'Servicios', + 'checkout1026301065', + ] REST_FRAMEWORK = { diff --git a/Productos/__pycache__/__init__.cpython-39.pyc b/Productos/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..eaa5799 Binary files /dev/null and b/Productos/__pycache__/__init__.cpython-39.pyc differ diff --git a/Productos/__pycache__/admin.cpython-39.pyc b/Productos/__pycache__/admin.cpython-39.pyc new file mode 100644 index 0000000..d8ea788 Binary files /dev/null and b/Productos/__pycache__/admin.cpython-39.pyc differ diff --git a/Productos/__pycache__/apps.cpython-39.pyc b/Productos/__pycache__/apps.cpython-39.pyc new file mode 100644 index 0000000..16e6bc7 Binary files /dev/null and b/Productos/__pycache__/apps.cpython-39.pyc differ diff --git a/Productos/__pycache__/models.cpython-39.pyc b/Productos/__pycache__/models.cpython-39.pyc new file mode 100644 index 0000000..fe402b8 Binary files /dev/null and b/Productos/__pycache__/models.cpython-39.pyc differ diff --git a/Productos/__pycache__/serializers.cpython-39.pyc b/Productos/__pycache__/serializers.cpython-39.pyc new file mode 100644 index 0000000..940b5b1 Binary files /dev/null and b/Productos/__pycache__/serializers.cpython-39.pyc differ diff --git a/Productos/__pycache__/urls.cpython-39.pyc b/Productos/__pycache__/urls.cpython-39.pyc new file mode 100644 index 0000000..698b9f0 Binary files /dev/null and b/Productos/__pycache__/urls.cpython-39.pyc differ diff --git a/Productos/__pycache__/views.cpython-39.pyc b/Productos/__pycache__/views.cpython-39.pyc new file mode 100644 index 0000000..438d3a6 Binary files /dev/null and b/Productos/__pycache__/views.cpython-39.pyc differ diff --git a/Servicios/__pycache__/__init__.cpython-38.pyc b/Servicios/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index e12b130..0000000 Binary files a/Servicios/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/Servicios/__pycache__/admin.cpython-38.pyc b/Servicios/__pycache__/admin.cpython-38.pyc deleted file mode 100644 index 5a77434..0000000 Binary files a/Servicios/__pycache__/admin.cpython-38.pyc and /dev/null differ diff --git a/Servicios/__pycache__/models.cpython-38.pyc b/Servicios/__pycache__/models.cpython-38.pyc deleted file mode 100644 index 763863c..0000000 Binary files a/Servicios/__pycache__/models.cpython-38.pyc and /dev/null differ diff --git a/Servicios/admin.py b/Servicios/admin.py deleted file mode 100644 index ac0e048..0000000 --- a/Servicios/admin.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.contrib import admin - -from .models import * - -admin.site.register(Servicio) \ No newline at end of file diff --git a/Servicios/apps.py b/Servicios/apps.py deleted file mode 100644 index bc13776..0000000 --- a/Servicios/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class ServiciosConfig(AppConfig): - name = 'Servicios' diff --git a/Servicios/migrations/0001_initial.py b/Servicios/migrations/0001_initial.py deleted file mode 100644 index 30172bb..0000000 --- a/Servicios/migrations/0001_initial.py +++ /dev/null @@ -1,21 +0,0 @@ -# Generated by Django 3.0.8 on 2021-09-23 01:19 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='Servicio', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('nombre', models.CharField(max_length=100)), - ], - ), - ] diff --git a/Servicios/migrations/__pycache__/0001_initial.cpython-38.pyc b/Servicios/migrations/__pycache__/0001_initial.cpython-38.pyc deleted file mode 100644 index b5fe453..0000000 Binary files a/Servicios/migrations/__pycache__/0001_initial.cpython-38.pyc and /dev/null differ diff --git a/Servicios/migrations/__pycache__/__init__.cpython-38.pyc b/Servicios/migrations/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index d877a83..0000000 Binary files a/Servicios/migrations/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/Servicios/models.py b/Servicios/models.py deleted file mode 100644 index 4174ac5..0000000 --- a/Servicios/models.py +++ /dev/null @@ -1,4 +0,0 @@ -from django.db import models - -class Servicio(models.Model): - nombre = models.CharField(max_length=100) \ No newline at end of file diff --git a/Servicios/views.py b/Servicios/views.py deleted file mode 100644 index 91ea44a..0000000 --- a/Servicios/views.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.shortcuts import render - -# Create your views here. diff --git a/Servicios/__init__.py b/checkout1026301065/__init__.py similarity index 100% rename from Servicios/__init__.py rename to checkout1026301065/__init__.py diff --git a/checkout1026301065/__pycache__/__init__.cpython-39.pyc b/checkout1026301065/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..1f059fb Binary files /dev/null and b/checkout1026301065/__pycache__/__init__.cpython-39.pyc differ diff --git a/checkout1026301065/__pycache__/admin.cpython-39.pyc b/checkout1026301065/__pycache__/admin.cpython-39.pyc new file mode 100644 index 0000000..65854e3 Binary files /dev/null and b/checkout1026301065/__pycache__/admin.cpython-39.pyc differ diff --git a/checkout1026301065/__pycache__/apps.cpython-39.pyc b/checkout1026301065/__pycache__/apps.cpython-39.pyc new file mode 100644 index 0000000..91810a6 Binary files /dev/null and b/checkout1026301065/__pycache__/apps.cpython-39.pyc differ diff --git a/checkout1026301065/__pycache__/models.cpython-39.pyc b/checkout1026301065/__pycache__/models.cpython-39.pyc new file mode 100644 index 0000000..c97e4a2 Binary files /dev/null and b/checkout1026301065/__pycache__/models.cpython-39.pyc differ diff --git a/checkout1026301065/admin.py b/checkout1026301065/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/checkout1026301065/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/checkout1026301065/apps.py b/checkout1026301065/apps.py new file mode 100644 index 0000000..d859d39 --- /dev/null +++ b/checkout1026301065/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class Checkout1026301065Config(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'checkout1026301065' diff --git a/Servicios/migrations/__init__.py b/checkout1026301065/migrations/__init__.py similarity index 100% rename from Servicios/migrations/__init__.py rename to checkout1026301065/migrations/__init__.py diff --git a/checkout1026301065/models.py b/checkout1026301065/models.py new file mode 100644 index 0000000..4649d67 --- /dev/null +++ b/checkout1026301065/models.py @@ -0,0 +1,64 @@ +import Productos +from django.contrib.auth import get_user_model +from django.db import models +from django.db.models.base import Model +from django.db.models.deletion import CASCADE +from django.db.models.fields import CharField + +from Productos.models import * + +'''class CarritoCompras(models.Model): + #dvariables + usurio=models.ForeignKey(get_user_model(),on_delete=models.SET_NULL,null=True) + fecha=models.DateField(auto_now_add=True) + descuento=models.FloatField(null=True) + cantMinima = models.IntegerField() + pagado=models.BooleanField(default=False) + #metodos + def __str__(self): + return str(self.usuario) + " - " + str(self.fecha) + def total(self): + total=0 + for articulo in self.articulo_set.all(): + total += articulo.subtotal() + return total''' +class CarritoCompras(models.Model): + usuario = models.ForeignKey(get_user_model(), on_delete=models.SET_NULL, null=True) + fecha = models.DateTimeField(auto_now_add=True) + pagado = models.BooleanField(default=False) + + def __str__(self): + return str(self.usuario) + " - " + str(self.fecha) + + @property + def total(self): + total = 0 + for articulo in self.articulo_set.all(): + total += articulo.subtotal() + return total + +class Articulo(models.Model): + carrito = models.ForeignKey(CarritoCompras, on_delete=models.CASCADE) + producto = models.ForeignKey(Producto, on_delete=models.SET_NULL, null=True) + cantidad = models.IntegerField() + + def __str__(self): + return self.carrito.__str__() + " / " + self.producto.nombre + + def subtotal(self): + return self.producto.precio*self.cantidad +class InfoEnvio(models.Model): + carrito=models.ForeignKey(CarritoCompras,on_delete=models.CASCADE) + nombre=models.CharField(max_length=200) + apellido=models.CharField(max_length=200) + direccion=models.CharField(max_length=100) + pais=models.CharField(max_length=100) + departamento=models.CharField(max_length=100) + ciudad=models.CharField(max_length=100) + + def __str__(self): + return self.carrito.__str__() + + + + diff --git a/checkout1026301065/serializers.py b/checkout1026301065/serializers.py new file mode 100644 index 0000000..238ad26 --- /dev/null +++ b/checkout1026301065/serializers.py @@ -0,0 +1,17 @@ +from rest_framework import serializers +from checkout1026301065.models import * + + +class CaritoSerial(serializers.ModelSerializer): + class Meta: + model = CarritoCompras + fields = ['usuario', 'fecha', 'total'] +class ArticuloSerial(serializers.ModelSerializer): + class Meta: + model = Articulo + fields = '__all__' +class InfoEnvioSerial(serializers.ModelSerializer): + class Meta: + model = InfoEnvio + fields = '__all__' + \ No newline at end of file diff --git a/Servicios/tests.py b/checkout1026301065/tests.py similarity index 100% rename from Servicios/tests.py rename to checkout1026301065/tests.py diff --git a/checkout1026301065/urls.py b/checkout1026301065/urls.py new file mode 100644 index 0000000..6f9f8cb --- /dev/null +++ b/checkout1026301065/urls.py @@ -0,0 +1,13 @@ +from django.urls.resolvers import URLPattern +from checkout1026301065.views import * +from django.urls import path,include +from rest_framework.routers import DefaultRouter + + +router=DefaultRouter() +router.register("carrito",CarritoCompraAPI,basename="carrito") +router.register("articulo",ArticuloAPI,basename="articulo") +router.register("infoenvio",InfoEnvioAPI,basename="envio") +urlpatterns=[path("crud/",include(router.urls)) +] + diff --git a/checkout1026301065/views.py b/checkout1026301065/views.py new file mode 100644 index 0000000..ed50b6b --- /dev/null +++ b/checkout1026301065/views.py @@ -0,0 +1,14 @@ +from django.shortcuts import render +from rest_framework import viewsets +from checkout1026301065.models import * +from checkout1026301065.serializers import * + +class CarritoCompraAPI(viewsets.ModelViewSet): + serializers_class=CaritoSerial + queryset= CarritoCompras.objects.all() +class ArticuloAPI(viewsets.ModelViewSet): + serializers_class=ArticuloSerial + queryset= Articulo.objects.all() +class InfoEnvioAPI(viewsets.ModelViewSet): + serializers_class=InfoEnvioSerial + queryset= InfoEnvio.objects.all() \ No newline at end of file