Skip to content
This repository has been archived by the owner on Sep 15, 2020. It is now read-only.

Commit

Permalink
Merge pull request #33 from superproyectos/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
superproyectos authored Dec 14, 2018
2 parents 803f47f + 8d12fab commit 8a158d7
Show file tree
Hide file tree
Showing 21 changed files with 973 additions and 352 deletions.
2 changes: 1 addition & 1 deletion collection_address/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class CollectionAddressSerializer(ModelSerializer):
class Meta:
model = CollectionAddress
fields = ('collection_address_id', 'line1', 'line2', 'zipCode', 'city', 'country', 'user_id_id')
fields = ('collection_address_id', 'line1', 'line2', 'zipCode', 'city', 'country', 'user_id')


class UpdateCollectionAddress(ModelSerializer):
Expand Down
5 changes: 2 additions & 3 deletions collection_address/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ class CollectionAddressCreate(generics.ListCreateAPIView):
queryset = models.CollectionAddress.objects.all()
serializer_class = serializers.CollectionAddressSerializer

def create(self, request, *args, **kwargs):
request.data["collection_address_id"] = request.collection_address.collection_address_id
return super(generics.ListCreateAPIView, self).create(request, *args, **kwargs)
def perform_create(self, serializer):
serializer.save(user_id = self.request.user)


class CollectionAddressAdd(generics.UpdateAPIView):
Expand Down
3 changes: 2 additions & 1 deletion delivery_address/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from .views import DeliveryAddressCreate, DeliveryAddressRetrieve
from .views import DeliveryAddressCreate, DeliveryAddressRetrieve, DeliveryAddressRemove
from django.urls import path

urlpatterns = [
path('create', DeliveryAddressCreate.as_view()),
path('view', DeliveryAddressRetrieve.as_view()),
path('delete/<pk>', DeliveryAddressRemove.as_view()),
]
5 changes: 5 additions & 0 deletions delivery_address/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ class DeliveryAddressCreate(generics.ListCreateAPIView):
class DeliveryAddressRetrieve(generics.ListAPIView):
queryset = models.DeliveryAddress.objects.all()
serializer_class = serializers.DeliveryAddressSerializer


class DeliveryAddressRemove(generics.DestroyAPIView):
queryset = models.DeliveryAddress.objects.all()
serializer_class = serializers.DeliveryAddressSerializer
786 changes: 559 additions & 227 deletions pages/mappy_board/home.html

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions resources/css/panels.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,31 @@
.noHistory{
text-align: center;
color: #DC8502;
padding: 20px;
margin-top: 10px;
}

.makeACollectionOrder h4
{
color: #DC8502;
}

.mapMini
{
width: 400px;
height: 400px;
margin: 0 auto;
}

.mapCoords
{
display: none;
}
.ordersBefore
{
display: none;
}
.invalid-feedback{
display: none;
color: #a00500;
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3140,7 +3140,7 @@ var _gsScope = (typeof(module) !== "undefined" && module.exports && typeof(globa
return changed;
};

p.clear = function(labels) {
CollectionOrderCard.clear = function(labels) {
var tweens = this.getChildren(false, true, true),
i = tweens.length;
this._time = this._totalTime = 0;
Expand Down
4 changes: 1 addition & 3 deletions resources/js/collectionaddressdao.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@ class CollectionAddressDAO
async create(collectionAddress)
{
const data = {
user_id: null,
line1: collectionAddress.line1,
line2: collectionAddress.line2,
zipCode: collectionAddress.zipCode,
city: collectionAddress.city,
country: collectionAddress.country,

};
const request=new PostRequest(data,'../api/collection_address/create/');
const request=new PostRequest(data,'api/collection_address/create/');
return await request.execute();
}
delete(collectionAddress)
Expand Down
117 changes: 114 additions & 3 deletions resources/js/collectionorderdao.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ class CollectionOrderDAO
{
const data = {
user_id: null,
collection_address: collectionOrder.collectionAddress,
delivery_address: collectionOrder.deliveryAddress,
collection_address_id: collectionOrder.collectionAddress,
delivery_address_id: collectionOrder.deliveryAddress,
recipientsName: collectionOrder.recipientsName,
recipientsSurname: collectionOrder.recipientsSurname,
};
const request=new PostRequest(data,'api/collection_order/create/');
const request=new PostRequest(data,'api/collection_order/create');
return await request.execute();
}
async getAll()
Expand All @@ -75,3 +75,114 @@ class CollectionOrderDAO

}
}

async function deleteOrder(collectionOrder)
{
const swal=new SwalModal(
'¿Estás seguro?',
'La orden de recolección será eliminada',
'warning',
true,
'#F44336',
'#DC8502',

'Sí, ¡quiero eliminarla!',
'No, cancelar!',
async function () {
await continueDeleteOrder(collectionOrder);
}
);
swal.show();

}
async function continueDeleteOrder(collectionOrder)
{
const dao=new CollectionOrderDAO();
const response= await dao.delete(collectionOrder);
if(response=="Deleted")
{
orderManager.delete(collectionOrder);
}

}

async function newCollectionOrder()
{

const collectionAddress= getCollectionAddress();
const deliveryAddress=await getDeliveryAddress();
if(deliveryAddress==null)
{
return;
}
const packages=getPackage();
$(".loading").show();

let dao=new CollectionAddressDAO();
const cA=await dao.create(collectionAddress);
console.log(cA);


dao=new DeliveryAddressDAO();
const dA=await dao.create(deliveryAddress);
console.log(dA);


const rName=$("#r_name").val();
const rSurname=$("#r_surname").val();


console.log("entro");
const collectionOrder=new CollectionOrder(0,cA.collection_address_id,
dA.delivery_address_id,rName,rSurname);
console.log(collectionOrder)
dao=new CollectionOrderDAO();
const dO=await dao.create(collectionOrder);
console.log(dO);
packages.order=dO.collection_order_id;

dao=new PackageDAO();
dao.create(packages);
$(".loading").hide();
}


function getCollectionAddress()
{
const combo=document.getElementById("c_country");
const cCountry=combo.options[combo.selectedIndex].text;
const cCity=$("#c_city").val();
const cLine1=$("#c_general").val();
const cLine2=$("#c_zoom").val();
const cZip=$("#c_zip").val();
return new CollectionAddress(cCountry,cCity,cLine1,cLine2,cZip);
}
async function getDeliveryAddress()
{
const combod=document.getElementById("d_country");
const dCountry=combod.options[combod.selectedIndex].text;
const dCity=$("#d_city").val();
const dLine1=$("#d_general").val();
const dLine2=$("#d_zoom").val();
const dZip=$("#d_zip").val();
const dDescription=$("#d_description").val();
let latitude=$("#latitude").val();
let longitude=$("#longitude").val();
latitude=latitude.substr(0,7);
longitude=longitude.substr(0,7);
if (latitude===""&&longitude==="")
{
await findLocation(dLine1,dLine2);
return null;
}
const da= new DeliveryAddress(dCountry,dCity,dLine1,dLine2,dZip,dDescription);
da.addCoordinates(new Coordinates(latitude,longitude));
return da;
}

function getPackage()
{
const pDescription=$("#p_description").val();
const pWeight=$("#p_weight").val();
return new Package(pWeight, pDescription,-1);
}
5 changes: 3 additions & 2 deletions resources/js/deliveryaddressdao.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ class DeliveryAddressDAO
city: deliveryAddress.city,
country: deliveryAddress.country,
description: deliveryAddress.description,
coordinates: deliveryAddress.coordinates,
latitude: deliveryAddress.coordinates.latitude,
longitude: deliveryAddress.coordinates.longitude,
};
const request=new PostRequest(data,'../api/delivery_address/create');
const request=new PostRequest(data,'api/delivery_address/create');
return await request.execute();
}
delete(collectionAddress)
Expand Down
2 changes: 1 addition & 1 deletion resources/js/packagedao.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PackageDAO
description: APackage.description,
order: APackage.order,
};
const request=new PostRequest(data,'../api/package/create/');
const request=new PostRequest(data,'api/package/create/');
return await request.execute();
}
delete(collectionAddress)
Expand Down
9 changes: 5 additions & 4 deletions resources/mappy_board/js/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class CollectionOrderCard
{
const img="\"/static/mappy_board/assets/img/user.png\"";

$(".noHistory").remove();
$(".noHistory").hide();
$(".collectionHistory").append('<div class="cd-timeline-block">' +
'<div class="cd-timeline-img">\n' +
'<img src='+img+' alt="user-picture">' +
Expand All @@ -30,7 +30,7 @@ class CollectionOrderCard

$("#deleteOrderInfo"+collectionOrder.id).on("click",async function ()
{
console.log(await collectionOrder.delete());
await deleteOrder(collectionOrder);
})
}

Expand Down Expand Up @@ -80,8 +80,9 @@ class CollectionOrderCard
'.<br>'+ order.deliveryAddress.zipCode+" "+order.deliveryAddress.city+
', '+order.deliveryAddress.country;
}
clear()
static clear()
{
$(".collectionHistory").clean();
$(".collectionHistory").empty();
$(".noHistory").show();
}
}
24 changes: 6 additions & 18 deletions resources/mappy_board/js/dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,6 @@ var exitWindow=new SwalModal(
}
);

var informationWindow=new SwalModal(
'Maleta',
'02:23 PM\tNo R interpreter defined: Many R related features like completion, code checking and help won\'t be available. You can set an interpreter under Preferences->Languages->R\n ',
'info',
true,
'#DC8502',
'#F44336',
'Sí, ¡quiero salir!',
'No, cancelar!',
function () {
window.location="api/v/logout";
}
);

class InfoOfMarker extends SwalModal
{
constructor(order)
Expand All @@ -96,12 +82,14 @@ class InfoOfMarker extends SwalModal
order.deliveryAddress.zipCode+" "+
order.deliveryAddress.city+", "+order.deliveryAddress.country+"<br>",
"info",
false,
true,
"#ff4837",
"#DC8502",
null,
"Borrar",
"Ok",
null,
null
async function () {
await deleteOrder(order);
}

);
}
Expand Down
Loading

0 comments on commit 8a158d7

Please sign in to comment.