From 1486843af010d5a03b0fd6fa048887572b2bbadc Mon Sep 17 00:00:00 2001 From: Levi Date: Wed, 4 May 2016 00:16:41 -0500 Subject: [PATCH] Added VM detail page, Added VM setting page, Added VM pricing page,Added VM orders page, Added VM status page --- hosting/models.py | 9 + hosting/static/hosting/css/commons.css | 5 + .../static/hosting/css/virtual-machine.css | 42 +++++ hosting/templates/hosting/base_short.html | 3 +- hosting/templates/hosting/orders.html | 16 -- .../hosting/virtual_machine_detail.html | 155 ++++++++++++++++++ .../templates/hosting/virtual_machines.html | 4 +- hosting/urls.py | 5 +- hosting/views.py | 7 + 9 files changed, 226 insertions(+), 20 deletions(-) create mode 100644 hosting/static/hosting/css/virtual-machine.css create mode 100644 hosting/templates/hosting/virtual_machine_detail.html diff --git a/hosting/models.py b/hosting/models.py index edee580d..ea650ebb 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -90,6 +90,15 @@ class VirtualMachinePlan(models.Model): def hosting_company_name(self): return self.vm_type.get_hosting_company_display() + @cached_property + def name(self): + name = 'vm-%s' % self.id + return name + + @cached_property + def orders(self): + return [self.hostingorder] + @classmethod def create(cls, data, user): instance = cls.objects.create(**data) diff --git a/hosting/static/hosting/css/commons.css b/hosting/static/hosting/css/commons.css index e77ddfa2..f386cfd6 100644 --- a/hosting/static/hosting/css/commons.css +++ b/hosting/static/hosting/css/commons.css @@ -13,3 +13,8 @@ display: block; color: transparent; } + +.inline-headers h3, .inline-headers h4 { + display: inline-block; + vertical-align: baseline; +} diff --git a/hosting/static/hosting/css/virtual-machine.css b/hosting/static/hosting/css/virtual-machine.css new file mode 100644 index 00000000..570d5118 --- /dev/null +++ b/hosting/static/hosting/css/virtual-machine.css @@ -0,0 +1,42 @@ +.virtual-machine-container .tabs-left, .virtual-machine-container .tabs-right { + border-bottom: none; + padding-top: 2px; +} +.virtual-machine-container .tabs-left { + border-right: 1px solid #ddd; +} +.virtual-machine-container .tabs-right { + border-left: 1px solid #ddd; +} +.virtual-machine-container .tabs-left>li, .virtual-machine-container .tabs-right>li { + float: none; + margin-bottom: 2px; +} +.virtual-machine-container .tabs-left>li { + margin-right: -1px; +} +.virtual-machine-container .tabs-right>li { + margin-left: -1px; +} +.virtual-machine-container .tabs-left>li.active>a, +.virtual-machine-container .tabs-left>li.active>a:hover, +.virtual-machine-container .tabs-left>li.active>a:focus { + border-bottom-color: #ddd; + border-right-color: transparent; +} + +.virtual-machine-container .tabs-right>li.active>a, +.virtual-machine-container .tabs-right>li.active>a:hover, +.virtual-machine-container .tabs-right>li.active>a:focus { + border-bottom: 1px solid #ddd; + border-left-color: transparent; +} +.virtual-machine-container .tabs-left>li>a { + border-radius: 4px 0 0 4px; + margin-right: 0; + display:block; +} +.virtual-machine-container .tabs-right>li>a { + border-radius: 0 4px 4px 0; + margin-right: 0; +} \ No newline at end of file diff --git a/hosting/templates/hosting/base_short.html b/hosting/templates/hosting/base_short.html index 266ee484..339020de 100644 --- a/hosting/templates/hosting/base_short.html +++ b/hosting/templates/hosting/base_short.html @@ -18,9 +18,10 @@ - + + diff --git a/hosting/templates/hosting/orders.html b/hosting/templates/hosting/orders.html index 819dec4d..99c6464f 100644 --- a/hosting/templates/hosting/orders.html +++ b/hosting/templates/hosting/orders.html @@ -2,22 +2,6 @@ {% load staticfiles bootstrap3 %} {% block content %} - -
diff --git a/hosting/templates/hosting/virtual_machine_detail.html b/hosting/templates/hosting/virtual_machine_detail.html new file mode 100644 index 00000000..87edd71f --- /dev/null +++ b/hosting/templates/hosting/virtual_machine_detail.html @@ -0,0 +1,155 @@ +{% extends "hosting/base_short.html" %} +{% load staticfiles bootstrap3 %} +{% block content %} +
+
+
+
+
+

{{virtual_machine.name}}

+
+ + +
+ +
+
+
+
+

{{virtual_machine.hosting_company_name}}

+
+
+
+
+
+
+
+
+ Cores
+ {{virtual_machine.cores}} +
+
+
+
+ Memory
+ {{virtual_machine.memory}} GiB +
+
+
+
+ Disk
+ {{virtual_machine.disk_size}} GiB +
+
+
+
+
+ + +
+
+ +
+
+

Current pricing

+ {{virtual_machine.price|floatformat}} CHF/mo +
+
+
+
+
+
+
+ +

Orders

+
+ + + + + + + + + + + {% for order in virtual_machine.orders %} + + + + + + + + {% endfor %} + +
#DateAmountStatus
{{order.id}}{{order.created_at}}{{order.VMPlan.price}} CHF{% if order.approved %} + Approved + {% else%} + Declined + {% endif%} + + +
+
+
+
+
+ +
+
+

Current status

+ Online +
+
+
+
+
+
+ +
+
+
+ +
+
+ +
+ +{%endblock%} + + + + + + + + + diff --git a/hosting/templates/hosting/virtual_machines.html b/hosting/templates/hosting/virtual_machines.html index 47eb23b1..fa673c99 100644 --- a/hosting/templates/hosting/virtual_machines.html +++ b/hosting/templates/hosting/virtual_machines.html @@ -19,11 +19,11 @@ {% for vm in vms %} - {{vm.id}} + {{vm.name}} {{vm.hosting_company_name}} {{vm.price}} CHF - + {% endfor %} diff --git a/hosting/urls.py b/hosting/urls.py index 31a3eaea..15aa4008 100644 --- a/hosting/urls.py +++ b/hosting/urls.py @@ -2,7 +2,8 @@ from django.conf.urls import url from .views import DjangoHostingView, RailsHostingView, PaymentVMView, \ NodeJSHostingView, LoginView, SignupView, IndexView, \ - OrdersHostingListView, OrdersHostingDetailView, VirtualMachinesPlanListView + OrdersHostingListView, OrdersHostingDetailView, VirtualMachinesPlanListView,\ + VirtualMachineDetailListView urlpatterns = [ url(r'index/?$', IndexView.as_view(), name='index'), @@ -13,6 +14,8 @@ urlpatterns = [ url(r'orders/?$', OrdersHostingListView.as_view(), name='orders'), url(r'orders/(?P\d+)/?$', OrdersHostingDetailView.as_view(), name='orders'), url(r'my-virtual-machines/?$', VirtualMachinesPlanListView.as_view(), name='virtual_machines'), + url(r'my-virtual-machines/(?P\d+)/?$', VirtualMachineDetailListView.as_view(), + name='virtual_machines'), url(r'login/?$', LoginView.as_view(), name='login'), url(r'signup/?$', SignupView.as_view(), name='signup'), url(r'^logout/?$', 'django.contrib.auth.views.logout', diff --git a/hosting/views.py b/hosting/views.py index 3494c983..b0e76028 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -247,3 +247,10 @@ class VirtualMachinesPlanListView(LoginRequiredMixin, ListView): user = self.request.user self.queryset = VirtualMachinePlan.objects.active(user) return super(VirtualMachinesPlanListView, self).get_queryset() + + +class VirtualMachineDetailListView(LoginRequiredMixin, DetailView): + template_name = "hosting/virtual_machine_detail.html" + login_url = reverse_lazy('hosting:login') + model = VirtualMachinePlan + context_object_name = "virtual_machine"