diff --git a/hosting/migrations/0022_virtualmachineplan_ip.py b/hosting/migrations/0022_virtualmachineplan_ip.py new file mode 100644 index 00000000..e426ddc8 --- /dev/null +++ b/hosting/migrations/0022_virtualmachineplan_ip.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-06-07 00:52 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0021_auto_20160526_0445'), + ] + + operations = [ + migrations.AddField( + model_name='virtualmachineplan', + name='ip', + field=models.CharField(default='127.0.0.1', max_length=50), + preserve_default=False, + ), + ] diff --git a/hosting/migrations/0023_virtualmachineplan_configutarion.py b/hosting/migrations/0023_virtualmachineplan_configutarion.py new file mode 100644 index 00000000..97b82bd0 --- /dev/null +++ b/hosting/migrations/0023_virtualmachineplan_configutarion.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-06-07 02:13 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0022_virtualmachineplan_ip'), + ] + + operations = [ + migrations.AddField( + model_name='virtualmachineplan', + name='configutarion', + field=models.CharField(choices=[('django', 'Ubuntu 14.04, Django'), ('rails', 'Ubuntu 14.04, Rails'), ('nodejs', 'Debian, NodeJS')], default='django', max_length=20), + preserve_default=False, + ), + ] diff --git a/hosting/migrations/0024_auto_20160607_0231.py b/hosting/migrations/0024_auto_20160607_0231.py new file mode 100644 index 00000000..aedc3430 --- /dev/null +++ b/hosting/migrations/0024_auto_20160607_0231.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-06-07 02:31 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0023_virtualmachineplan_configutarion'), + ] + + operations = [ + migrations.RenameField( + model_name='virtualmachineplan', + old_name='configutarion', + new_name='configuration', + ), + ] diff --git a/hosting/mixins.py b/hosting/mixins.py index 1f6366ab..e8a2b7b4 100644 --- a/hosting/mixins.py +++ b/hosting/mixins.py @@ -10,7 +10,9 @@ class ProcessVMSelectionMixin(object): 'memory': request.POST.get('memory'), 'disk_size': request.POST.get('disk_space'), 'hosting_company': request.POST.get('hosting_company'), - 'hosting_company_name': request.POST.get('hosting_company_name'), + 'location_code': request.POST.get('location_code'), + 'configuration': request.POST.get('configuration'), + 'configuration_detail': request.POST.get('configuration_detail'), 'final_price': request.POST.get('final_price') } request.session['vm_specs'] = vm_specs diff --git a/hosting/models.py b/hosting/models.py index a8237f3a..e9f59478 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -35,6 +35,7 @@ class VirtualMachineType(models.Model): (DE_LOCATION, 'Germany'), (CH_LOCATION, 'Switzerland'), ) + description = models.TextField() base_price = models.FloatField() memory_price = models.FloatField() @@ -93,13 +94,25 @@ class VirtualMachinePlan(models.Model): (CANCELED_STATUS, 'Canceled') ) + DJANGO = 'django' + RAILS = 'rails' + NODEJS = 'nodejs' + + VM_CONFIGURATION = ( + (DJANGO, 'Ubuntu 14.04, Django'), + (RAILS, 'Ubuntu 14.04, Rails'), + (NODEJS, 'Debian, NodeJS'), + ) + cores = models.IntegerField() memory = models.IntegerField() disk_size = models.IntegerField() vm_type = models.ForeignKey(VirtualMachineType) price = models.FloatField() - public_key = models.TextField() + public_key = models.TextField(blank=True) status = models.CharField(max_length=20, choices=VM_STATUS_CHOICES, default=PENDING_STATUS) + ip = models.CharField(max_length=50, blank=True) + configuration = models.CharField(max_length=20, choices=VM_CONFIGURATION) objects = VMPlansManager() diff --git a/hosting/static/hosting/css/virtual-machine.css b/hosting/static/hosting/css/virtual-machine.css index 570d5118..b5cd27f4 100644 --- a/hosting/static/hosting/css/virtual-machine.css +++ b/hosting/static/hosting/css/virtual-machine.css @@ -39,4 +39,8 @@ .virtual-machine-container .tabs-right>li>a { border-radius: 0 4px 4px 0; margin-right: 0; +} + +.virtual-machine-container .right-place{ + margin-top: 15px; } \ No newline at end of file diff --git a/hosting/static/hosting/js/gen-ssh-key.js b/hosting/static/hosting/js/gen-ssh-key.js index 46e701d7..23897c01 100644 --- a/hosting/static/hosting/js/gen-ssh-key.js +++ b/hosting/static/hosting/js/gen-ssh-key.js @@ -29,7 +29,7 @@ $( document ).ready(function() { $('[data-toggle="tooltip"]').tooltip(); - var clipboard = new Clipboard('#copy_to_clipboard'); + var clipboard = new Clipboard('.to_copy'); clipboard.on('success', function(e) { var selector = "#"; diff --git a/hosting/static/hosting/js/initial.js b/hosting/static/hosting/js/initial.js new file mode 100644 index 00000000..da2887c6 --- /dev/null +++ b/hosting/static/hosting/js/initial.js @@ -0,0 +1,16 @@ +$( document ).ready(function() { + + + $('[data-toggle="tooltip"]').tooltip(); + + var clipboard = new Clipboard('.to_copy'); + + clipboard.on('success', function(e) { + var selector = "#"; + var copy_button_id = selector.concat(e.trigger.id); + setTimeout(function(){ + $(copy_button_id).tooltip('hide'); + }, 1000); + }); + +}); \ No newline at end of file diff --git a/hosting/templates/hosting/base_short.html b/hosting/templates/hosting/base_short.html index df6f5c37..64c93781 100644 --- a/hosting/templates/hosting/base_short.html +++ b/hosting/templates/hosting/base_short.html @@ -53,7 +53,7 @@ <span class="icon-bar"></span> <span class="icon-bar"></span> </button> - <a class="navbar-brand topnav" href="#"><img src="{% static 'hosting/img/logo_black.svg' %}"></a> + <a class="navbar-brand topnav" href="{% url 'ungleich_page:landing' %}"><img src="{% static 'hosting/img/logo_black.svg' %}"></a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> @@ -161,6 +161,9 @@ <!-- Bootstrap Core JavaScript --> <script src="{% static 'hosting/js/bootstrap.min.js' %}"></script> + <!-- Init JavaScript --> + <script src="{% static 'hosting/js/initial.js' %}"></script> + <!-- Stripe Lib --> <script type="text/javascript" src="//js.stripe.com/v2/"></script> diff --git a/hosting/templates/hosting/includes/_navbar.html b/hosting/templates/hosting/includes/_navbar.html index 150af49f..aa1fe8a6 100644 --- a/hosting/templates/hosting/includes/_navbar.html +++ b/hosting/templates/hosting/includes/_navbar.html @@ -11,7 +11,7 @@ <span class="icon-bar"></span> <span class="icon-bar"></span> </button> - <a class="navbar-brand topnav" href="#"><img src="{% static 'hosting/img/logo_black.svg' %}"></a> + <a class="navbar-brand topnav" href="{% url 'ungleich_page:landing' %}"><img src="{% static 'hosting/img/logo_black.svg' %}"></a> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> diff --git a/hosting/templates/hosting/includes/_pricing.html b/hosting/templates/hosting/includes/_pricing.html index c61c27dc..3a9138b4 100644 --- a/hosting/templates/hosting/includes/_pricing.html +++ b/hosting/templates/hosting/includes/_pricing.html @@ -23,7 +23,9 @@ <form class="form-inline" method="POST" action="{{request.path}}"> {% csrf_token %} <input type="hidden" name="hosting_company" value="{{vm.hosting_company}}"> - <input type="hidden" name="hosting_company_name" value="{{vm.hosting_company_name}}"> + <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' %}"> @@ -43,6 +45,15 @@ </div> </div> </li> + <li> + <!-- Single button --> + <div class="btn-group"> + <div class="form-group"> + <label for="cores">Configuration: </label> + {{configuration_detail}} + </div> + </div> + </li> <li> <!-- Single button --> <div class="btn-group"> diff --git a/hosting/templates/hosting/notifications.html b/hosting/templates/hosting/notifications.html index 959dfe4f..8bd140c7 100644 --- a/hosting/templates/hosting/notifications.html +++ b/hosting/templates/hosting/notifications.html @@ -13,7 +13,12 @@ <ul class="nav nav-tabs tabs-left sideways"> <li class="active"> <a href="#unread-v" data-toggle="tab"> - Unread <span class="badge">{{unread_notifications|length}}</span> + Unread + {% if unread_notifications|length > 0%} + <span class="badge"> + {{unread_notifications|length}} + </span> + {% endif %} </a> </li> <li> diff --git a/hosting/templates/hosting/order_detail.html b/hosting/templates/hosting/order_detail.html index 87b4a5e0..3278f050 100644 --- a/hosting/templates/hosting/order_detail.html +++ b/hosting/templates/hosting/order_detail.html @@ -50,6 +50,8 @@ <div class="content"> <p><b>Type</b> <span class="pull-right">{{order.vm_plan.hosting_company_name}}</span></p> <hr> + <p><b>Configuration</b> <span class="pull-right">{{order.vm_plan.get_configuration_display}}</span></p> + <hr> <p><b>Cores</b> <span class="pull-right">{{order.vm_plan.cores}}</span></p> <hr> <p><b>Memory</b> <span class="pull-right">{{order.vm_plan.memory}} GiB</span></p> diff --git a/hosting/templates/hosting/payment.html b/hosting/templates/hosting/payment.html index 15bd6a14..985d91c7 100644 --- a/hosting/templates/hosting/payment.html +++ b/hosting/templates/hosting/payment.html @@ -86,10 +86,12 @@ <h3><b>Billing Amount</b></h3> <hr> <div class="content"> - <p><b>Type</b> <span class="pull-right">{{request.session.vm_specs.hosting_company_name}}</span></p> + <p><b>Type</b> <span class="pull-right">{{request.session.vm_specs.location_code}}</span></p> <hr> <p><b>Cores</b> <span class="pull-right">{{request.session.vm_specs.cores}}</span></p> <hr> + <p><b>Configuration</b> <span class="pull-right">{{request.session.vm_specs.configuration_detail}}</span></p> + <hr> <p><b>Memory</b> <span class="pull-right">{{request.session.vm_specs.memory}} GiB</span></p> <hr> <p><b>Disk space</b> <span class="pull-right">{{request.session.vm_specs.disk_size}} GiB</span></p> diff --git a/hosting/templates/hosting/virtual_machine_detail.html b/hosting/templates/hosting/virtual_machine_detail.html index 210739d6..6b97d6be 100644 --- a/hosting/templates/hosting/virtual_machine_detail.html +++ b/hosting/templates/hosting/virtual_machine_detail.html @@ -42,9 +42,27 @@ <div class="tab-content"> <div class="tab-pane active" id="settings-v"> <div class="row"> - <div class="col-md-12"> + <div class="col-md-12 inline-headers"> <h3>{{virtual_machine.hosting_company_name}}</h3> + + {% if virtual_machine.ip %} + <div class="pull-right right-place"> + <button type="link" data-clipboard-text="{{virtual_machine.ip}}" id="copy_vm_id" class="to_copy btn btn-link" + data-toggle="tooltip" data-placement="bottom" title="Copied" data-trigger="click"> + Ip: {{virtual_machine.ip}} <i class="fa fa-files-o" aria-hidden="true"></i> + </button> + </div> + {% else %} + + <div class="pull-right right-place"> + <span class="label label-warning"><strong>Ip not assigned yet</strong></span> + <i data-toggle="tooltip" title="Your ip will be assigned soon" class="fa fa-info-circle" aria-hidden="true"></i> + </div> + + {% endif %} + <hr> + </div> </div> <div class="row"> diff --git a/hosting/urls.py b/hosting/urls.py index bc72a636..1368ab73 100644 --- a/hosting/urls.py +++ b/hosting/urls.py @@ -7,7 +7,6 @@ from .views import DjangoHostingView, RailsHostingView, PaymentVMView,\ MarkAsReadNotificationView urlpatterns = [ - # url(r'pricing/?$', VMPricingView.as_view(), name='pricing'), url(r'index/?$', IndexView.as_view(), name='index'), url(r'django/?$', DjangoHostingView.as_view(), name='djangohosting'), url(r'nodejs/?$', NodeJSHostingView.as_view(), name='nodejshosting'), diff --git a/hosting/views.py b/hosting/views.py index 17739155..d9026d4c 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -27,9 +27,12 @@ class DjangoHostingView(ProcessVMSelectionMixin, View): template_name = "hosting/django.html" def get_context_data(self, **kwargs): + HOSTING = 'django' + configuration_detail = dict(VirtualMachinePlan.VM_CONFIGURATION).get(HOSTING) context = { - 'hosting': "django", + 'hosting': HOSTING, 'hosting_long': "Django", + 'configuration_detail': configuration_detail, 'domain': "django-hosting.ch", 'google_analytics': "UA-62285904-6", 'email': "info@django-hosting.ch", @@ -49,8 +52,11 @@ class RailsHostingView(ProcessVMSelectionMixin, View): template_name = "hosting/rails.html" def get_context_data(self, **kwargs): + HOSTING = 'rails' + configuration_detail = dict(VirtualMachinePlan.VM_CONFIGURATION).get(HOSTING) context = { - 'hosting': "rails", + 'hosting': HOSTING, + 'configuration_detail': configuration_detail, 'hosting_long': "Ruby On Rails", 'domain': "rails-hosting.ch", 'google_analytics': "UA-62285904-5", @@ -69,9 +75,12 @@ class NodeJSHostingView(ProcessVMSelectionMixin, View): template_name = "hosting/nodejs.html" def get_context_data(self, **kwargs): + HOSTING = 'nodejs' + configuration_detail = dict(VirtualMachinePlan.VM_CONFIGURATION).get(HOSTING) context = { 'hosting': "nodejs", 'hosting_long': "NodeJS", + 'configuration_detail': configuration_detail, 'domain': "node-hosting.ch", 'google_analytics': "UA-62285904-7", 'email': "info@node-hosting.ch", @@ -230,6 +239,7 @@ class PaymentVMView(LoginRequiredMixin, FormView): 'cores': specifications.get('cores'), 'memory': specifications.get('memory'), 'disk_size': specifications.get('disk_size'), + 'configuration': specifications.get('configuration'), 'price': final_price } token = form.cleaned_data.get('token') @@ -289,11 +299,11 @@ class PaymentVMView(LoginRequiredMixin, FormView): email = BaseEmail(**email_data) email.send() - request.session.update({ - 'charge': charge, - 'order': order.id, - 'billing_address': billing_address.id - }) + # request.session.update({ + # 'charge': charge, + # 'order': order.id, + # 'billing_address': billing_address.id + # }) return HttpResponseRedirect(reverse('hosting:orders', kwargs={'pk': order.id})) else: return self.form_invalid(form) diff --git a/ungleich_page/urls.py b/ungleich_page/urls.py index 91bc136a..607b7042 100644 --- a/ungleich_page/urls.py +++ b/ungleich_page/urls.py @@ -4,6 +4,6 @@ from django.utils.translation import ugettext_lazy as _ urlpatterns = [ url(r'^$', LandingView.as_view(), name='landing'), - url(r'^ungleich_page/?$', LandingView.as_view(), name='landing'), + # url(r'^ungleich_page/?$', LandingView.as_view(), name='landing'), url(_(r'contact/$'), ContactView.as_view(), name='contact'), ]