This repository has been archived by the owner on Sep 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from superproyectos/develop
Develop
- Loading branch information
Showing
185 changed files
with
8,420 additions
and
131 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Generated by Django 2.1.3 on 2018-12-06 23:03 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('collection_address', '0002_collectionaddress_user_id'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='collectionaddress', | ||
name='user_id', | ||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='collection_address', to=settings.AUTH_USER_MODEL), | ||
), | ||
] |
Binary file added
BIN
+838 Bytes
collection_address/migrations/__pycache__/0001_initial.cpython-35.pyc
Binary file not shown.
Binary file added
BIN
+868 Bytes
collection_address/migrations/__pycache__/0002_collectionaddress_user_id.cpython-35.pyc
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from .views import CollectionAddressCreate, CollectionAddressRetrieve, CollectionAddressAdd | ||
from user.views import RetrieveCollectionAddresses | ||
from django.urls import path | ||
|
||
urlpatterns = [ | ||
path('create', CollectionAddressCreate.as_view()), | ||
path('create/', CollectionAddressCreate.as_view()), | ||
path('add/<pk>', CollectionAddressAdd.as_view()), | ||
path('view', CollectionAddressRetrieve.as_view()), | ||
path('getAll', RetrieveCollectionAddresses.as_view()), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 2.1.3 on 2018-12-06 23:24 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('collection_address', '0003_auto_20181206_1903'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('delivery_address', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='CollectionOrder', | ||
fields=[ | ||
('collection_order_id', models.AutoField(primary_key=True, serialize=False)), | ||
('recipientsName', models.CharField(max_length=35)), | ||
('recipientsSurname', models.CharField(max_length=35)), | ||
('collection_address_id', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='collection_address', to='collection_address.CollectionAddress')), | ||
('delivery_address_id', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='delivery_address', to='delivery_address.DeliveryAddress')), | ||
('user_id', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='user', to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
from django.db import models | ||
from user.models import User | ||
from collection_address.models import CollectionAddress | ||
from package.models import Package | ||
from delivery_address.models import DeliveryAddress | ||
|
||
|
||
# Create your models here. | ||
|
||
class CollectionOrder(models.Model): | ||
collection_order_id = models.AutoField(primary_key = True) | ||
user_id = models.OneToOneField(User, on_delete = models.SET_NULL, null = True) | ||
package_id = models.ForeignKey(Package, on_delete = models.CASCADE, null = False, blank = False) | ||
collection_address_id = models.OneToOneField(CollectionAddress, on_delete = models.CASCADE, null = True) | ||
delivery_address_id = models.OneToOneField(DeliveryAddress, on_delete = models.CASCADE, null = True) | ||
user_id = models.ForeignKey(User, on_delete = models.SET_NULL, null = True, related_name = "user") | ||
collection_address_id = models.ForeignKey(CollectionAddress, on_delete = models.CASCADE, | ||
null = True, related_name = "collection_address") | ||
delivery_address_id = models.ForeignKey(DeliveryAddress, on_delete = models.CASCADE, | ||
null = True, related_name = "delivery_address") | ||
recipientsName = models.CharField(max_length = 35) | ||
recipientsSurname = models.CharField(max_length = 35) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from rest_framework.serializers import ModelSerializer | ||
from package.serializers import PackageSerializer | ||
from delivery_address.serializers import DeliveryAddressSerializer | ||
from collection_address.serializers import CollectionAddressSerializer | ||
from .models import CollectionOrder | ||
|
||
|
||
class CollectionOrderSerializer(ModelSerializer): | ||
order = PackageSerializer(many = True, read_only = True) | ||
|
||
class Meta: | ||
model = CollectionOrder | ||
fields = ('collection_order_id', 'user_id', 'collection_address_id', 'delivery_address_id', | ||
'recipientsName', 'recipientsSurname', 'order',) | ||
|
||
|
||
class CollectionOrderSerializerExtended(ModelSerializer): | ||
order = PackageSerializer(many = True, read_only = True) | ||
delivery_address_id = DeliveryAddressSerializer(many = False, read_only = True) | ||
collection_address_id = CollectionAddressSerializer(many = False, read_only = True) | ||
|
||
class Meta: | ||
model = CollectionOrder | ||
fields = ('collection_order_id', 'user_id', 'collection_address_id', 'delivery_address_id', | ||
'recipientsName', 'recipientsSurname', 'order',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from .views import CreateCollectionOrder,ViewAllCollectionOrders,RetrieveCollectionOrdersOfUser, RemoveCollectionOrder | ||
from django.urls import path | ||
|
||
urlpatterns = [ | ||
path('create', CreateCollectionOrder.as_view()), | ||
path('view', ViewAllCollectionOrders.as_view()), | ||
path('getAll', RetrieveCollectionOrdersOfUser.as_view()), | ||
path('remove/<pk>', RemoveCollectionOrder.as_view()), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,39 @@ | ||
from django.shortcuts import render | ||
from rest_framework import generics | ||
from rest_framework.response import Response | ||
|
||
# Create your views here. | ||
from . import models | ||
from . import serializers | ||
|
||
|
||
class CreateCollectionOrder(generics.CreateAPIView): | ||
serializer_class = serializers.CollectionOrderSerializer | ||
queryset = models.CollectionOrder.objects.all() | ||
|
||
def perform_create(self, serializer): | ||
serializer.save(user_id = self.request.user) | ||
|
||
|
||
class ViewAllCollectionOrders(generics.ListAPIView): | ||
serializer_class = serializers.CollectionOrderSerializer | ||
queryset = models.CollectionOrder.objects.all() | ||
|
||
|
||
class RetrieveCollectionOrdersOfUser(generics.ListAPIView): | ||
serializer_class = serializers.CollectionOrderSerializerExtended | ||
|
||
def get_queryset(self): | ||
user = self.request.user | ||
return models.CollectionOrder.objects.filter(user_id = user.user_id) | ||
|
||
|
||
class RemoveCollectionOrder(generics.DestroyAPIView): | ||
serializer_class = serializers.CollectionOrderSerializer | ||
queryset = models.CollectionOrder.objects.all() | ||
|
||
def delete(self, request, *args, **kwargs): | ||
instance = self.get_object() | ||
# just the user can delete his own collection order | ||
if instance.user_id == request.user.user_id: | ||
return self.destroy(request, *args, **kwargs) | ||
else: | ||
return Response(data = "Error") |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1022 Bytes
delivery_address/migrations/__pycache__/0001_initial.cpython-35.pyc
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from rest_framework.serializers import ModelSerializer | ||
from .models import DeliveryAddress | ||
|
||
|
||
class DeliveryAddressSerializer(ModelSerializer): | ||
class Meta: | ||
model = DeliveryAddress | ||
fields = ('delivery_address_id', 'line1', 'line2', 'zipCode', 'city', | ||
'country', 'description', 'latitude', 'longitude',) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from .views import DeliveryAddressCreate, DeliveryAddressRetrieve | ||
from django.urls import path | ||
|
||
urlpatterns = [ | ||
path('create', DeliveryAddressCreate.as_view()), | ||
path('view', DeliveryAddressRetrieve.as_view()), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
from django.shortcuts import render | ||
from rest_framework import generics | ||
from . import models | ||
from . import serializers | ||
|
||
|
||
# Create your views here. | ||
|
||
class DeliveryAddressCreate(generics.ListCreateAPIView): | ||
queryset = models.DeliveryAddress.objects.all() | ||
serializer_class = serializers.DeliveryAddressSerializer | ||
|
||
def create(self, request, *args, **kwargs): | ||
request.data["delivery_address_id"] = request.deliveryAddress.delivery_address_id | ||
return super(generics.ListCreateAPIView, self).create(request, *args, **kwargs) | ||
|
||
|
||
class DeliveryAddressRetrieve(generics.ListAPIView): | ||
queryset = models.DeliveryAddress.objects.all() | ||
serializer_class = serializers.DeliveryAddressSerializer |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 2.1.3 on 2018-12-06 23:37 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('package', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='package', | ||
name='order', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='package', to='collection_order.CollectionOrder'), | ||
), | ||
] |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
from django.db import models | ||
from collection_order.models import CollectionOrder | ||
|
||
|
||
# Create your models here. | ||
|
||
class Package(models.Model): | ||
package_id = models.AutoField(primary_key = True) | ||
weight = models.DecimalField(max_digits = 20, decimal_places = 12, null = True) | ||
description = models.CharField(max_length = 35, null = True) | ||
order = models.ForeignKey(CollectionOrder, on_delete = models.CASCADE, | ||
null = True, blank = True, related_name = "order") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from rest_framework.serializers import ModelSerializer | ||
from .models import Package | ||
|
||
|
||
class PackageSerializer(ModelSerializer): | ||
class Meta: | ||
model = Package | ||
fields = ('package_id', 'weight', 'description', 'order') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from .views import PackageCreate, PackageViewAll | ||
from django.urls import path | ||
|
||
urlpatterns = [ | ||
path('create/', PackageCreate.as_view()), | ||
path('view/', PackageViewAll.as_view()), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
from django.shortcuts import render | ||
from rest_framework import generics | ||
from . import models | ||
from . import serializers | ||
|
||
# Create your views here. | ||
|
||
class PackageCreate(generics.CreateAPIView): | ||
queryset = models.Package.objects.all() | ||
serializer_class = serializers.PackageSerializer | ||
|
||
|
||
class PackageViewAll(generics.ListAPIView): | ||
queryset = models.Package.objects.all() | ||
serializer_class = serializers.PackageSerializer |
Oops, something went wrong.