Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified ExEcommerce/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified ExEcommerce/__pycache__/settings.cpython-38.pyc
Binary file not shown.
Binary file modified ExEcommerce/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified ExEcommerce/__pycache__/wsgi.cpython-38.pyc
Binary file not shown.
3 changes: 2 additions & 1 deletion ExEcommerce/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
'django.contrib.staticfiles',
'Productos',
'rest_framework',
'rest_framework.authtoken'
'rest_framework.authtoken',
'cheackout1130619212'
]

REST_FRAMEWORK = {
Expand Down
3 changes: 2 additions & 1 deletion ExEcommerce/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
]
Binary file modified Productos/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Binary file modified Productos/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file added Productos/__pycache__/apps.cpython-38.pyc
Binary file not shown.
Binary file modified Productos/__pycache__/models.cpython-38.pyc
Binary file not shown.
Binary file modified Productos/__pycache__/serializers.cpython-38.pyc
Binary file not shown.
Binary file modified Productos/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file modified Productos/__pycache__/views.cpython-38.pyc
Binary file not shown.
Binary file modified Productos/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file modified Productos/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
Empty file added cheackout1130619212/__init__.py
Empty file.
Binary file not shown.
Binary file added cheackout1130619212/__pycache__/admin.cpython-38.pyc
Binary file not shown.
Binary file added cheackout1130619212/__pycache__/apps.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added cheackout1130619212/__pycache__/urls.cpython-38.pyc
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions cheackout1130619212/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions cheackout1130619212/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class Cheackout1130619212Config(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'cheackout1130619212'
49 changes: 49 additions & 0 deletions cheackout1130619212/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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')),
],
),
]
Empty file.
Binary file not shown.
Binary file not shown.
46 changes: 46 additions & 0 deletions cheackout1130619212/models.py
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 18 additions & 0 deletions cheackout1130619212/serializador.py
Original file line number Diff line number Diff line change
@@ -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__'
3 changes: 3 additions & 0 deletions cheackout1130619212/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
17 changes: 17 additions & 0 deletions cheackout1130619212/urls.py
Original file line number Diff line number Diff line change
@@ -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/
34 changes: 34 additions & 0 deletions cheackout1130619212/views.py
Original file line number Diff line number Diff line change
@@ -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()


Binary file removed db.sqlite3
Binary file not shown.