generated from determinedguy/django-railway-template
-
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.
Browse files
Browse the repository at this point in the history
* Finish feature add available time * Remove unused import statement * Change url and icon of sidebar * Add forbidden page * Implement dashboard driver and status order feature
- Loading branch information
Showing
7 changed files
with
298 additions
and
51 deletions.
There are no files selected for viewing
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,96 @@ | ||
function accept_order(id_order){ | ||
console.log(id_order) | ||
$.ajax({ | ||
url: "/respons-order/accept-order", | ||
type: "POST", | ||
data:{ | ||
id_order: id_order, | ||
}, | ||
success: function(response) { | ||
document.getElementById(id_order).remove() | ||
Toastify({ | ||
text: "Success accept the order", | ||
duration: 3000, | ||
close: true, | ||
gravity: "top", | ||
position: "center", | ||
backgroundColor: "#4fbe87", | ||
}).showToast() | ||
}, | ||
failed: function(response) { | ||
document.getElementById(id_order).remove() | ||
Toastify({ | ||
text: "Failed accept the order", | ||
duration: 3000, | ||
close: true, | ||
gravity: "top", | ||
position: "center", | ||
backgroundColor: "#ff0000", | ||
}).showToast() | ||
}, | ||
}) | ||
} | ||
|
||
function reject_order(id_order){ | ||
$.ajax({ | ||
url: "/respons-order/reject-order", | ||
type: "POST", | ||
data:{ | ||
id_order: id_order, | ||
}, | ||
success: function(response) { | ||
document.getElementById(id_order).remove() | ||
Toastify({ | ||
text: "Success reject the order", | ||
duration: 3000, | ||
close: true, | ||
gravity: "top", | ||
position: "center", | ||
backgroundColor: "#4fbe87", | ||
}).showToast() | ||
}, | ||
failed: function(response) { | ||
document.getElementById(id_order).remove() | ||
Toastify({ | ||
text: "Failed reject the order", | ||
duration: 3000, | ||
close: true, | ||
gravity: "top", | ||
position: "center", | ||
backgroundColor: "#ff0000", | ||
}).showToast() | ||
}, | ||
}) | ||
} | ||
|
||
function finish_order(id_order){ | ||
$.ajax({ | ||
url: "/respons-order/finish-order", | ||
type: "POST", | ||
data:{ | ||
id_order: id_order, | ||
}, | ||
success: function(response) { | ||
document.getElementById(id_order).remove() | ||
Toastify({ | ||
text: "Success finish the order", | ||
duration: 3000, | ||
close: true, | ||
gravity: "top", | ||
position: "center", | ||
backgroundColor: "#4fbe87", | ||
}).showToast() | ||
}, | ||
failed: function(response) { | ||
document.getElementById(id_order).remove() | ||
Toastify({ | ||
text: "Failed finish the order", | ||
duration: 3000, | ||
close: true, | ||
gravity: "top", | ||
position: "center", | ||
backgroundColor: "#ff0000", | ||
}).showToast() | ||
}, | ||
}) | ||
} |
126 changes: 112 additions & 14 deletions
126
dashboard_driver/templates/dashboard_driver/index.html
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,18 +1,116 @@ | ||
{% extends 'base.html' %} | ||
{% load static %} | ||
{% block meta %} | ||
<link | ||
href="{% static 'assets/extensions/datatables.net-bs5/css/dataTables.bootstrap5.min.css'%}" | ||
rel="stylesheet" | ||
type="text/css" | ||
/> | ||
<link href="{% static 'assets/css/pages/datatables.css' %}" rel="stylesheet" type="text/css"/> | ||
<link href="{% static 'assets/css/pages/fontawesome.css' %}" rel="stylesheet" type="text/css"/> | ||
<link | ||
href="{% static 'assets/extensions/toastify-js/src/toastify.css' %}" | ||
rel="stylesheet" | ||
/> | ||
{% endblock meta %} | ||
{% block content %} | ||
|
||
<h1>Dashboard Driver!</h1> | ||
<div class="page-heading"> | ||
<div class="page-title"> | ||
<div class="row"> | ||
<div class="col-12 col-md-6 order-md-1 order-last"> | ||
<h3>{{ title }}</h3> | ||
<p class="text-subtitle text-muted"> | ||
Your current {{ title|lower }}(s) | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<table> | ||
<thead> | ||
<th>pending_order</th> | ||
</thead> | ||
<tbody> | ||
{% for entry in pending_order %} | ||
<tr> | ||
<td>{{entry.order_date}}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
<!-- Basic Tables start --> | ||
<section class="section"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<table class="table" id="table1"> | ||
<thead> | ||
<tr> | ||
<th>Pickup Location</th> | ||
<th>Destination Location</th> | ||
<th>Order Date</th> | ||
<th>Pickup Date</th> | ||
<th>Distance</th> | ||
<th>Fee</th> | ||
<th>Customer</th> | ||
{% if title == 'Accepted Order' or title == 'Rejected Order' or title == 'Finished Order'%} | ||
<th>Status</th> | ||
{% endif %} | ||
{% if title == 'Pending Order' or title == 'Accepted Order' %} | ||
<th>Action</th> | ||
{% endif %} | ||
|
||
{% endblock content %} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for entry in order %} | ||
<tr id="{{entry.id}}"> | ||
<td>{{entry.pickup_location}}</td> | ||
<td>{{entry.destination_location}}</td> | ||
<td>{{entry.order_date}}</td> | ||
<td>{{entry.pickup_date}}</td> | ||
<td>{{entry.distance}}</td> | ||
<td>{{entry.fee}}</td> | ||
<td>{{entry.customer.user}}</td> | ||
{% if title == 'Accepted Order'%} | ||
<td class="justify-content-center"> | ||
<span class="badge bg-success">Accepted</span> | ||
</td> | ||
{% endif %} | ||
{% if title == 'Rejected Order'%} | ||
<td class="justify-content-center"> | ||
<span class="badge bg-danger">Rejected</span> | ||
</td> | ||
{% endif %} | ||
{% if title == 'Finished Order' %} | ||
<td class="justify-content-center"> | ||
<span class="badge bg-primary">Finished</span> | ||
</td> | ||
{% endif %} | ||
{% if title == 'Pending Order' %} | ||
<td class="justify-content-center"> | ||
<button type="button" class="btn btn-success rounded-pill m-1" onclick="accept_order({{entry.id}})" | ||
>Accept</button | ||
> | ||
<a onclick="reject_order({{entry.id}})" class="btn btn-danger rounded-pill m-1" href="#" | ||
>Reject</a | ||
> | ||
</td> | ||
{% endif %} | ||
{% if title == 'Accepted Order' %} | ||
<td class="justify-content-center"> | ||
<button type="button" class="btn btn-primary rounded-pill m-1" onclick="finish_order({{entry.id}})" | ||
>Finish</button | ||
> | ||
</td> | ||
{% endif %} | ||
|
||
</tr> | ||
|
||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</section> | ||
<!-- Basic Tables end --> | ||
</div> | ||
|
||
{% endblock content %} | ||
{% block script %} | ||
<script src="{% static 'assets/extensions/jquery/jquery.min.js' %}"></script> | ||
<script rel="javascript" type="text/javascript" src="{% static 'js/change_status_order.js' %}"></script> | ||
|
||
<script src="https://cdn.datatables.net/v/bs5/dt-1.12.1/datatables.min.js" type="text/javascript"></script> | ||
<script src="{% static 'assets/js/pages/datatables.js' %}"></script> | ||
<script src="{% static 'assets/extensions/toastify-js/src/toastify.js' %}"></script> | ||
<script src="{% static 'js/add_available_time.js' %}"></script> | ||
{% endblock script %} |
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,25 @@ | ||
{% extends 'base.html' %} | ||
{% load static %} | ||
|
||
{% block content %} | ||
<div id="error"> | ||
<div class="error-page container"> | ||
<div class="col-md-8 col-12 offset-md-2"> | ||
<div class="text-center"> | ||
<img | ||
class="img-error" | ||
src="{% static 'assets/images/samples/error-403.svg'%}" | ||
alt="Not Found" | ||
/> | ||
<h1 class="error-title">Forbidden</h1> | ||
<p class="fs-5 text-gray-600"> | ||
You are unauthorized to see this page. | ||
</p> | ||
<a href="{% url 'main:home'%}" class="btn btn-lg btn-outline-primary mt-3" | ||
>Go Home</a | ||
> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock content %} |
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,9 @@ | ||
app_name = 'respons_order' | ||
from django.urls import path | ||
from .views import accept_order, reject_order | ||
from .views import accept_order, reject_order, finish_order | ||
|
||
urlpatterns = [ | ||
path('accept-order', accept_order, name="accept_order"), | ||
path('reject-order', reject_order, name="reject_order") | ||
path('reject-order', reject_order, name="reject_order"), | ||
path('finish-order', finish_order, name="finish_order") | ||
] |
Oops, something went wrong.