Created generic view for vm pricing widget, Added VM configuration info on VM detail view, Fixed template bugs. Fixed Blog urls bugs

This commit is contained in:
Levi 2016-06-30 01:23:14 -05:00
parent 9aa732626f
commit e90c5fece0
7 changed files with 99 additions and 14 deletions

View file

@ -7,9 +7,10 @@ from django.conf.urls.static import static
from django.conf import settings from django.conf import settings
from hosting.views import RailsHostingView, DjangoHostingView, NodeJSHostingView from hosting.views import RailsHostingView, DjangoHostingView, NodeJSHostingView
from membership import urls as membership_urls from membership import urls as membership_urls
from ungleich_page.views import LandingView
import debug_toolbar import debug_toolbar
urlpatterns = [ urlpatterns = [ url(r'^index.html$', LandingView.as_view()),
url(r'^hosting/', include('hosting.urls', namespace="hosting")), url(r'^hosting/', include('hosting.urls', namespace="hosting")),
url(r'^railshosting/', RailsHostingView.as_view(), name="rails.hosting"), url(r'^railshosting/', RailsHostingView.as_view(), name="rails.hosting"),
url(r'^nodehosting/', NodeJSHostingView.as_view(), name="node.hosting"), url(r'^nodehosting/', NodeJSHostingView.as_view(), name="node.hosting"),
@ -21,12 +22,13 @@ urlpatterns = [
# note the django CMS URLs included via i18n_patterns # note the django CMS URLs included via i18n_patterns
urlpatterns += i18n_patterns('', urlpatterns += i18n_patterns('',
url(r'^/?$', LandingView.as_view()),
url(r'^admin/', include(admin.site.urls)), url(r'^admin/', include(admin.site.urls)),
url(r'^digitalglarus/login/', include(membership_urls)), url(r'^digitalglarus/login/', include(membership_urls)),
url(r'^digitalglarus/', include('digitalglarus.urls', url(r'^digitalglarus/', include('digitalglarus.urls',
namespace="digitalglarus")), namespace="digitalglarus")),
# url(r'^blog/', include('ungleich.urls', namespace='ungleich')), #url(r'^blog/', include('ungleich.urls', namespace='ungleich')),
url(r'^ungleich_page/', url(r'^',
include('ungleich_page.urls', namespace='ungleich_page'), include('ungleich_page.urls', namespace='ungleich_page'),
name='ungleich_page'), name='ungleich_page'),
url(r'^blog/', include('ungleich.urls', namespace='ungleich')), url(r'^blog/', include('ungleich.urls', namespace='ungleich')),

View file

@ -1,18 +1,21 @@
from django.shortcuts import redirect from django.shortcuts import redirect
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from .models import VirtualMachinePlan
class ProcessVMSelectionMixin(object): class ProcessVMSelectionMixin(object):
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
hosting = request.POST.get('configuration')
configuration_detail = dict(VirtualMachinePlan.VM_CONFIGURATION).get(hosting)
vm_specs = { vm_specs = {
'cores': request.POST.get('cores'), 'cores': request.POST.get('cores'),
'memory': request.POST.get('memory'), 'memory': request.POST.get('memory'),
'disk_size': request.POST.get('disk_space'), 'disk_size': request.POST.get('disk_space'),
'hosting_company': request.POST.get('hosting_company'), 'hosting_company': request.POST.get('hosting_company'),
'location_code': request.POST.get('location_code'), 'location_code': request.POST.get('location_code'),
'configuration': request.POST.get('configuration'), 'configuration': hosting,
'configuration_detail': request.POST.get('configuration_detail'), 'configuration_detail': configuration_detail,
'final_price': request.POST.get('final_price') 'final_price': request.POST.get('final_price')
} }
request.session['vm_specs'] = vm_specs request.session['vm_specs'] = vm_specs

View file

@ -0,0 +1,44 @@
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<link href="{% static 'hosting/css/pricing.css' %}" rel="stylesheet" />
<title>Hosting</title>
<!-- Bootstrap Core CSS -->
<link href="{% static 'hosting/css/bootstrap.min.css' %}" rel="stylesheet">
<link href="{% static 'hosting/css/pricing.css' %}" rel="stylesheet">
<!-- Custom CSS -->
<link href="{% static 'hosting/css/landing-page.css' %}" rel="stylesheet">
<!-- Custom Fonts -->
<link href='//fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
<link href="{% static 'hosting/font-awesome/css/font-awesome.min.css' %}" rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic,700italic" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="{% static 'hosting/img/favicon.ico' %}" type="image/x-icon" />
</head>
<body>
{% include "hosting/includes/_pricing.html" with select_configuration=True%}
<!-- Pricing data -->
{% if vm_types %}
<script type="text/javascript">
(function () {window.VMTypesData = "{{vm_types|safe}}";})();
</script>
{%endif%}
<!-- Lodash -->
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.11.1/lodash.min.js"></script>
<!-- jQuery -->
<script src="{% static 'hosting/js/jquery.js' %}"></script>
<!-- Pricing -->
<script src="{% static 'hosting/js/pricing.js' %}"></script>
</body>
</html>

View file

@ -24,8 +24,7 @@
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="hosting_company" value="{{vm.hosting_company}}"> <input type="hidden" name="hosting_company" value="{{vm.hosting_company}}">
<input type="hidden" name="location_code" value="{{vm.location_code}}"> <input type="hidden" name="location_code" value="{{vm.location_code}}">
<input type="hidden" name="configuration_detail" value="{{configuration_detail}}">
<input type="hidden" name="configuration" value="{{hosting}}">
<ul class="pricing {% cycle 'p-red' 'p-black' 'p-red' 'p-yel' %}"> <ul class="pricing {% cycle 'p-red' 'p-black' 'p-red' 'p-yel' %}">
@ -46,13 +45,24 @@
</div> </div>
</li> </li>
<li> <li>
<!-- Single button --> <label for="configuration">Configuration: </label>
<div class="btn-group"> {% if select_configuration %}
<div class="form-group"> <select class="form-control" name="configuration" id="{{vm.hosting_company}}-configuration" data-vm-type="{{vm.hosting_company}}">
<label for="cores">Configuration: </label> {% for key,value in configuration_options.items %}
{{configuration_detail}} <option value="{{key}}">{{ value }}</option>
{% endfor %}
</select>
{% else %}
<input type="hidden" name="configuration_detail" value="{{configuration_detail}}">
<input type="hidden" name="configuration" value="{{hosting}}">
<!-- Single button -->
<div class="btn-group">
<div class="form-group">
<label>Configuration: </label>
{{configuration_detail}}
</div>
</div> </div>
</div> {% endif %}
</li> </li>
<li> <li>
<!-- Single button --> <!-- Single button -->

View file

@ -89,6 +89,11 @@
</div><!--/row--> </div><!--/row-->
</div><!--/col-12--> </div><!--/col-12-->
</div><!--/row--> </div><!--/row-->
<div class="row">
<div class="col-md-12">
Configuration: {{virtual_machine.get_configuration_display}}
</div>
</div>
</div> </div>

View file

@ -4,13 +4,14 @@ from .views import DjangoHostingView, RailsHostingView, PaymentVMView,\
NodeJSHostingView, LoginView, SignupView, IndexView, \ NodeJSHostingView, LoginView, SignupView, IndexView, \
OrdersHostingListView, OrdersHostingDetailView, VirtualMachinesPlanListView,\ OrdersHostingListView, OrdersHostingDetailView, VirtualMachinesPlanListView,\
VirtualMachineView, GenerateVMSSHKeysView, OrdersHostingDeleteView, NotificationsView, \ VirtualMachineView, GenerateVMSSHKeysView, OrdersHostingDeleteView, NotificationsView, \
MarkAsReadNotificationView, PasswordResetView, PasswordResetConfirmView MarkAsReadNotificationView, PasswordResetView, PasswordResetConfirmView, HostingPricingView
urlpatterns = [ urlpatterns = [
url(r'index/?$', IndexView.as_view(), name='index'), url(r'index/?$', IndexView.as_view(), name='index'),
url(r'django/?$', DjangoHostingView.as_view(), name='djangohosting'), url(r'django/?$', DjangoHostingView.as_view(), name='djangohosting'),
url(r'nodejs/?$', NodeJSHostingView.as_view(), name='nodejshosting'), url(r'nodejs/?$', NodeJSHostingView.as_view(), name='nodejshosting'),
url(r'rails/?$', RailsHostingView.as_view(), name='railshosting'), url(r'rails/?$', RailsHostingView.as_view(), name='railshosting'),
url(r'pricing/?$', HostingPricingView.as_view(), name='pricing'),
url(r'payment/?$', PaymentVMView.as_view(), name='payment'), url(r'payment/?$', PaymentVMView.as_view(), name='payment'),
url(r'orders/?$', OrdersHostingListView.as_view(), name='orders'), url(r'orders/?$', OrdersHostingListView.as_view(), name='orders'),
url(r'orders/(?P<pk>\d+)/?$', OrdersHostingDetailView.as_view(), name='orders'), url(r'orders/(?P<pk>\d+)/?$', OrdersHostingDetailView.as_view(), name='orders'),

View file

@ -99,6 +99,26 @@ class NodeJSHostingView(ProcessVMSelectionMixin, View):
return render(request, self.template_name, context) return render(request, self.template_name, context)
class HostingPricingView(ProcessVMSelectionMixin, View):
template_name = "hosting/hosting_pricing.html"
def get_context_data(self, **kwargs):
configuration_options = dict(VirtualMachinePlan.VM_CONFIGURATION)
context = {
'configuration_options': configuration_options,
'email': "info@django-hosting.ch",
'vm_types': VirtualMachineType.get_serialized_vm_types(),
}
return context
def get(self, request, *args, **kwargs):
request.session['hosting_url'] = reverse('hosting:djangohosting')
context = self.get_context_data()
return render(request, self.template_name, context)
class IndexView(View): class IndexView(View):
template_name = "hosting/index.html" template_name = "hosting/index.html"