add delete hosting order
This commit is contained in:
parent
700406a16c
commit
d3b579a41c
3 changed files with 100 additions and 54 deletions
|
@ -2,7 +2,7 @@
|
|||
{% load staticfiles bootstrap3 %}
|
||||
{% block content %}
|
||||
|
||||
<div>
|
||||
<div>
|
||||
<div class="container orders-container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
|
@ -21,20 +21,57 @@
|
|||
<tbody>
|
||||
{% for order in orders %}
|
||||
<tr>
|
||||
<td scope="row">{{order.id}}</td>
|
||||
<td>{{order.created_at}}</td>
|
||||
<td>{{order.VMPlan.price}} CHF</td>
|
||||
<td scope="row">{{ order.id }}</td>
|
||||
<td>{{ order.created_at }}</td>
|
||||
<td>{{ order.VMPlan.price }} CHF</td>
|
||||
<td>{% if order.approved %}
|
||||
<span class="text-success strong">Approved</span>
|
||||
{% else%}
|
||||
{% else %}
|
||||
<span class="text-danger strong">Declined</span>
|
||||
{% endif%}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-default"><a href="{% url 'hosting:orders' order.id %}">View Detail</a></button>
|
||||
<button type="button" class="btn btn-default"><a
|
||||
href="{% url 'hosting:orders' order.id %}">View Detail</a>
|
||||
</button>
|
||||
<button type="button" class="btn btn-default" data-toggle="modal"
|
||||
data-target="#Modal{{ order.id }}"><a
|
||||
href="#">Cancel order</a>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<div class="modal fade" id="Modal{{ order.id }}" tabindex="-1" role="dialog"
|
||||
aria-labelledby="exampleModalLabel">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"
|
||||
aria-label="Confirm"><span
|
||||
aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<h4 class="modal-title" id="ModalLabel">Do You want do delete
|
||||
Your
|
||||
order?</h4>
|
||||
|
||||
<form method="post" action="{% url 'hosting:delete_order' order.id %}">
|
||||
{% csrf_token %}
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default"
|
||||
data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary">Delete
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
@ -42,13 +79,13 @@
|
|||
<div class="pagination">
|
||||
<span class="page-links">
|
||||
{% if page_obj.has_previous %}
|
||||
<a href="{{request.path}}?page={{ page_obj.previous_page_number }}">previous</a>
|
||||
<a href="{{ request.path }}?page={{ page_obj.previous_page_number }}">previous</a>
|
||||
{% endif %}
|
||||
<span class="page-current">
|
||||
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
|
||||
</span>
|
||||
{% if page_obj.has_next %}
|
||||
<a href="{{request.path}}?page={{ page_obj.next_page_number }}">next</a>
|
||||
<a href="{{ request.path }}?page={{ page_obj.next_page_number }}">next</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
|
@ -59,6 +96,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{%endblock%}
|
||||
{% endblock %}
|
|
@ -3,7 +3,7 @@ from django.conf.urls import url
|
|||
from .views import DjangoHostingView, RailsHostingView, PaymentVMView, \
|
||||
NodeJSHostingView, LoginView, SignupView, IndexView, \
|
||||
OrdersHostingListView, OrdersHostingDetailView, VirtualMachinesPlanListView,\
|
||||
VirtualMachineDetailListView
|
||||
VirtualMachineDetailListView,OrdersHostingDeleteView
|
||||
|
||||
urlpatterns = [
|
||||
# url(r'pricing/?$', VMPricingView.as_view(), name='pricing'),
|
||||
|
@ -14,6 +14,7 @@ urlpatterns = [
|
|||
url(r'payment/?$', PaymentVMView.as_view(), name='payment'),
|
||||
url(r'orders/?$', OrdersHostingListView.as_view(), name='orders'),
|
||||
url(r'orders/(?P<pk>\d+)/?$', OrdersHostingDetailView.as_view(), name='orders'),
|
||||
url(r'cancel_order/(?P<pk>\d+)/?$',OrdersHostingDeleteView.as_view(),name='delete_order'),
|
||||
url(r'my-virtual-machines/?$', VirtualMachinesPlanListView.as_view(), name='virtual_machines'),
|
||||
url(r'my-virtual-machines/(?P<pk>\d+)/?$', VirtualMachineDetailListView.as_view(),
|
||||
name='virtual_machines'),
|
||||
|
|
|
@ -3,7 +3,7 @@ from django.shortcuts import get_object_or_404, render
|
|||
from django.core.urlresolvers import reverse_lazy, reverse
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
|
||||
from django.views.generic import View, CreateView, FormView, ListView, DetailView
|
||||
from django.views.generic import View, CreateView, FormView, ListView, DetailView,DeleteView
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.contrib.auth import authenticate, login
|
||||
from django.conf import settings
|
||||
|
@ -124,7 +124,7 @@ class LoginView(FormView):
|
|||
class SignupView(CreateView):
|
||||
template_name = 'hosting/signup.html'
|
||||
form_class = HostingUserSignupForm
|
||||
moodel = CustomUser
|
||||
model = CustomUser
|
||||
|
||||
def get_success_url(self):
|
||||
next_url = self.request.session.get('next', reverse_lazy('hosting:signup'))
|
||||
|
@ -235,6 +235,14 @@ class OrdersHostingListView(LoginRequiredMixin, ListView):
|
|||
self.queryset = HostingOrder.objects.filter(customer__user=user)
|
||||
return super(OrdersHostingListView, self).get_queryset()
|
||||
|
||||
class OrdersHostingDeleteView(LoginRequiredMixin,DeleteView):
|
||||
login_url=reverse_lazy('hosting:login')
|
||||
success_url = reverse_lazy('hosting:orders')
|
||||
model = HostingOrder
|
||||
def get_queryset(self):
|
||||
user = self.request.user
|
||||
self.queryset = VirtualMachinePlan.objects.active(user)
|
||||
return super(VirtualMachinesPlanListView, self).get_queryset()
|
||||
|
||||
class VirtualMachinesPlanListView(LoginRequiredMixin, ListView):
|
||||
template_name = "hosting/virtual_machines.html"
|
||||
|
|
Loading…
Reference in a new issue