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 #31 from superproyectos/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
superproyectos authored Dec 13, 2018
2 parents 1474647 + 6d444db commit 803f47f
Show file tree
Hide file tree
Showing 13 changed files with 433 additions and 111 deletions.
5 changes: 3 additions & 2 deletions collection_order/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class RemoveCollectionOrder(generics.DestroyAPIView):
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)
if instance.user_id == request.user:
self.destroy(request, *args, **kwargs)
return Response(data = "Deleted")
else:
return Response(data = "Error")
4 changes: 0 additions & 4 deletions delivery_address/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ 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()
Expand Down
110 changes: 67 additions & 43 deletions pages/mappy_board/home.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{%load staticfiles%}
<!DOCTYPE html>
<html lang="es">
<html lang="es" xmlns="http://www.w3.org/1999/html">
<head>
<title>Mappy</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link href="{% static 'img/favicon.png' %}" rel="shortcut icon">
<link rel="stylesheet" href="{% static 'mappy_board/css/main.css' %}">
<link rel="stylesheet" href="{% static 'css/loading.css' %}">
<link rel="stylesheet" href="{% static 'css/panels.css' %}">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" >
</head>
<body>
Expand Down Expand Up @@ -52,7 +53,7 @@
</li>
<li>
<a href="#!" class="historySideBar">
<i class="zmdi zmdi-book zmdi-hc-fw"></i> Historial
<i class="zmdi zmdi-book zmdi-hc-fw"></i> Órdenes en curso
</a>
</li>
<li>
Expand Down Expand Up @@ -98,11 +99,12 @@
</a>
</li>
</ul>

</nav>

<!--Here-->
<div class="makeACollectionOrder">
<!----------------------------Make a collection order form------------------------------->

<div class="makeACollectionOrder">
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
Expand Down Expand Up @@ -351,14 +353,66 @@
</div>
</div>
</div>

<!----------------------------History------------------------------->

<div class="historyOfCollectionOrders">
<section id="cd-timeline" class="collectionHistory cd-container">
<div class="noHistory">
No hay órdenes de recolección en curso<br>
<button type="button" class="doOne btn btn-primary btn-raised">¡Realiza una!</button>
</div>
</section>
</div>

</section>
<!-- Content page -->

<div id="mapMain" class="mapMain d-flex justify-content-center">

</div>
<!-- Notifications area -->
<section class="full-box Notifications-area">
<!----------------------------Main map------------------------------->

<div id="mapMain" class="mapMain d-flex justify-content-center">

</div>





<!-- Without collection orders dialog-->

<div class="modal fade" tabindex="-1" role="dialog" id="Dialog-Help">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">No tienes órdenes de recolección</h4>
</div>
<div class="modal-body">
<p>
Hasta el momento no tienes órdenes de recolección pendientes.<br>

</p>
</div>
<div class="modal-footer">
<button type="button" class="doOne btn btn-primary btn-raised" data-dismiss="modal">¡Realiza una!</button>
</div>
</div>
</div>
</div>


<!----------------------------Loading------------------------------->

<div class="loading">
<div id="loading27">
<div class="colorBalls"></div>
</div>
<div class="loadingText">
Espere un momento por favor...
</div>
</div>

<section class="full-box Notifications-area">
<div class="full-box Notifications-bg btn-Notifications-area"></div>
<div class="full-box Notifications-body">
<div class="Notifications-body-title text-titles text-center">
Expand Down Expand Up @@ -413,39 +467,7 @@ <h4 class="list-group-item-heading">Tile with a label</h4>
</div>
</section>

<!-- Dialog help -->
<div class="modal fade" tabindex="-1" role="dialog" id="Dialog-Help">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">No tienes órdenes de recolección</h4>
</div>
<div class="modal-body">
<p>
En este momento no tienes órdenes de recolección.<br>

</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary btn-raised" data-dismiss="modal">¡Realiza una!</button>
</div>
</div>
</div>
</div>


<div class="loading">
<div id="loading27">
<div class="colorBalls"></div>
</div>
<div class="loadingText">
Espere un momento por favor...
</div>
</div>

<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>

<script src="{% static 'mappy_board/js/jquery-3.1.1.min.js' %}"></script>
<script src="{% static 'mappy_board/js/sweetalert2.min.js' %}"></script>
<script src="{% static 'mappy_board/js/bootstrap.min.js' %}"></script>
Expand All @@ -456,11 +478,13 @@ <h4 class="modal-title">No tienes órdenes de recolección</h4>
<script src="{% static 'mappy_board/js/map.js' %}"></script>
<script src="{% static 'js/requests.js' %}"></script>
<script src="{% static 'js/userdao.js' %}"></script>
<script src="{% static 'js/packagedao.js' %}"></script>
<script src="{% static 'js/collectionaddressdao.js' %}"></script>
<script src="{% static 'js/deliveryaddressdao.js' %}"></script>
<script src="{% static 'js/collectionorderdao.js' %}"></script>

<script src="{% static 'mappy_board/js/dialogs.js' %}"></script>
<script src="{% static 'mappy_board/js/queries.js' %}"></script>
<script src="{% static 'mappy_board/js/card.js' %}"></script>
<script>
$.material.init();
</script>
Expand Down
19 changes: 19 additions & 0 deletions resources/css/panels.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.historyOfCollectionOrders{
display: none;
}
.deleteOrderInfo{
background: #ff9d3a;
border-radius: 5px;
width: 100%;
padding: 5px;
margin: 5px;
border: none;
transition: all .3s ease-in-out;
}
.deleteOrderInfo:hover{
background: #ff5847;
}
.noHistory{
text-align: center;
color: #DC8502;
}
37 changes: 33 additions & 4 deletions resources/js/collectionorderdao.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
class CollectionOrder
{
constructor(collectionAddress, deliveryAddress, recipientsName, recipientsSurname)
constructor(id, collectionAddress, deliveryAddress, recipientsName, recipientsSurname)
{
this.id=id;
this.packages=[];
this.collectionAddress=collectionAddress;
this.deliveryAddress=deliveryAddress;
Expand All @@ -13,6 +14,32 @@ class CollectionOrder
{
this.packages.push(packages);
}

getPackagesResume()
{
let ret="";
for(let i=0;i<this.packages.length;i++)
{
ret+=this.packages[i].description+", ";
}
return ret.substr(0,ret.length-2);
}

getWeight()
{
let ret=0;
for(let i=0;i<this.packages.length;i++)
{
ret+=parseFloat(this.packages[i].weight);
}
return ret;
}

async delete()
{
let dao=new CollectionOrderDAO();
return await dao.delete(this);
}
}

class CollectionOrderDAO
Expand All @@ -32,11 +59,13 @@ class CollectionOrderDAO
async getAll()
{
const request=new GetRequest('api/collection_order/getAll');
return request.execute();
return await request.execute();
}

delete(collectionAddress)
async delete(collectionOrder)
{
const request=new DeleteRequest('api/collection_order/remove',collectionOrder.id)
return await request.execute();
}
findById(id)
{
Expand All @@ -45,4 +74,4 @@ class CollectionOrderDAO
{

}
}
}
4 changes: 4 additions & 0 deletions resources/js/createcollectionorder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
async function createAnOrder()
{

}
26 changes: 26 additions & 0 deletions resources/js/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,30 @@ class PostRequest
return e
});
}
}

class DeleteRequest
{
constructor(url, item)
{
this.url=url;
this.item=item;
}

async execute()
{
const cookie = new Cookie("csrftoken");
const token = cookie.getCookie();
const settings={
method: 'DELETE',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
"X-CSRFToken": token,
}
}
return await fetch(this.url+"/"+this.item,settings).then(response =>
response.json()).then(json => {
return json;}).catch(e => {return e});
}
}
10 changes: 5 additions & 5 deletions resources/mappy_board/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ body, html{
margin-left: 60px;
border-radius: 0.25em;
padding: 1em;
background-color: #01579B;
background-color: #DC8502;
color: #fff;
}
.cd-timeline-content::after {
Expand All @@ -541,7 +541,7 @@ body, html{
height: 0;
width: 0;
border: 7px solid transparent;
border-right: 7px solid #01579B;
border-right: 7px solid #DC8502;
}
@media (min-width: 1200px) {
#cd-timeline {
Expand Down Expand Up @@ -574,7 +574,7 @@ body, html{
height: 60px;
}
.cd-timeline-content .cd-date {
color: #01579B;
color: #DC8502;
}
.cd-timeline-content {
margin-left: 0;
Expand All @@ -584,7 +584,7 @@ body, html{
top: 24px;
left: 100%;
border-color: transparent;
border-left-color: #01579B;
border-left-color: #DC8502;
}
.cd-timeline-content .cd-date {
position: absolute;
Expand All @@ -602,7 +602,7 @@ body, html{
left: auto;
right: 100%;
border-color: transparent;
border-right-color: #01579B;
border-right-color: #DC8502;
}
.cd-timeline-block:nth-child(even) .cd-timeline-content .cd-date {
left: auto;
Expand Down
Loading

0 comments on commit 803f47f

Please sign in to comment.