From 05e73b1d5e57dd6cd62d26c40701e69c1cf0a683 Mon Sep 17 00:00:00 2001 From: Levi Date: Sun, 17 Apr 2016 19:52:19 -0500 Subject: [PATCH 1/4] Fixed ungleich urls, created model for storing VM types, created command to load VM prices and data to database --- digitalglarus/urls.py | 1 + hosting/admin.py | 4 +- hosting/management/__init__.py | 0 hosting/management/commands/__init__.py | 0 .../management/commands/create_vm_types.py | 54 +++++++++++++++++++ .../migrations/0003_virtualmachinetypes.py | 27 ++++++++++ hosting/migrations/0004_auto_20160418_0034.py | 19 +++++++ hosting/migrations/0005_auto_20160418_0038.py | 20 +++++++ hosting/models.py | 32 +++++++++++ 9 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 hosting/management/__init__.py create mode 100644 hosting/management/commands/__init__.py create mode 100644 hosting/management/commands/create_vm_types.py create mode 100644 hosting/migrations/0003_virtualmachinetypes.py create mode 100644 hosting/migrations/0004_auto_20160418_0034.py create mode 100644 hosting/migrations/0005_auto_20160418_0038.py diff --git a/digitalglarus/urls.py b/digitalglarus/urls.py index defb8f66..ef929726 100644 --- a/digitalglarus/urls.py +++ b/digitalglarus/urls.py @@ -5,6 +5,7 @@ from . import views from .views import ContactView, IndexView, AboutView urlpatterns = [ + url(r'', IndexView.as_view(), name='home'), url(_(r'home/?$'), IndexView.as_view(), name='home'), url(_(r'about/?$'), AboutView.as_view(), name='about'), url(_(r'contact/?$'), ContactView.as_view(), name='contact'), diff --git a/hosting/admin.py b/hosting/admin.py index ee686d03..8d5366e5 100644 --- a/hosting/admin.py +++ b/hosting/admin.py @@ -1,4 +1,4 @@ from django.contrib import admin -from .models import RailsBetaUser +from .models import RailsBetaUser, VirtualMachineType -admin.site.register(RailsBetaUser) +admin.site.register(RailsBetaUser, VirtualMachineType) diff --git a/hosting/management/__init__.py b/hosting/management/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/hosting/management/commands/__init__.py b/hosting/management/commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/hosting/management/commands/create_vm_types.py b/hosting/management/commands/create_vm_types.py new file mode 100644 index 00000000..78d9fbe3 --- /dev/null +++ b/hosting/management/commands/create_vm_types.py @@ -0,0 +1,54 @@ +from django.core.management.base import BaseCommand, CommandError +from hosting.models import VirtualMachineType + + +class Command(BaseCommand): + help = 'Create VM types' + + def get_data(self): + + hetzner = { + 'base_price': 10, + 'core_price': 10, + 'memory_price': 10, + 'disk_size_price': 10, + 'description': 'VM auf einzelner HW, Raid1, kein HA' + } + + return { + 'hetzner_nug': { + 'base_price': 5, + 'memory_price': 2, + 'core_price': 2, + 'disk_size_price': 0.5, + 'description': 'VM ohne Uptime Garantie' + }, + 'hetzner': hetzner, + 'hetzner_raid6': { + 'base_price': hetzner['base_price']*1.2, + 'core_price': hetzner['core_price']*1.2, + 'memory_price': hetzner['memory_price']*1.2, + 'disk_size_price': hetzner['disk_size_price']*1.2, + 'description': 'VM auf einzelner HW, Raid1, kein HA' + + }, + 'hetzner_glusterfs': { + 'base_price': hetzner['base_price']*1.4, + 'core_price': hetzner['core_price']*1.4, + 'memory_price': hetzner['memory_price']*1.4, + 'disk_size_price': hetzner['disk_size_price']*1.4, + 'description': 'VM auf einzelner HW, Raid1, kein HA' + }, + 'bern': { + 'base_price': 12, + 'core_price': 25, + 'memory_price': 7, + 'disk_size_price': 0.70, + 'description': "VM in Bern, HA Setup ohne HA Garantie", + } + } + + def handle(self, *args, **options): + + data = self.get_data() + [VirtualMachineType.objects.create(**data[key]) for key in data.keys()] diff --git a/hosting/migrations/0003_virtualmachinetypes.py b/hosting/migrations/0003_virtualmachinetypes.py new file mode 100644 index 00000000..0b240a75 --- /dev/null +++ b/hosting/migrations/0003_virtualmachinetypes.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-04-18 00:32 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0002_railsbetauser'), + ] + + operations = [ + migrations.CreateModel( + name='VirtualMachineTypes', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('description', models.TextField()), + ('base_price', models.FloatField()), + ('memory_price', models.FloatField()), + ('cores_price', models.FloatField()), + ('disk_size_price', models.FloatField()), + ('hosting_company', models.CharField(choices=[('hetzner_nug', 'Hetzner No Uptime Guarantee'), ('hetzner', 'Hetzner'), ('hetzner_raid6', 'Hetzner Raid6'), ('hetzner_glusterfs', 'Hetzner Glusterfs'), ('bern', 'Bern')], max_length=10)), + ], + ), + ] diff --git a/hosting/migrations/0004_auto_20160418_0034.py b/hosting/migrations/0004_auto_20160418_0034.py new file mode 100644 index 00000000..a376a23a --- /dev/null +++ b/hosting/migrations/0004_auto_20160418_0034.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-04-18 00:34 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0003_virtualmachinetypes'), + ] + + operations = [ + migrations.RenameModel( + old_name='VirtualMachineTypes', + new_name='VirtualMachineType', + ), + ] diff --git a/hosting/migrations/0005_auto_20160418_0038.py b/hosting/migrations/0005_auto_20160418_0038.py new file mode 100644 index 00000000..867d39b9 --- /dev/null +++ b/hosting/migrations/0005_auto_20160418_0038.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-04-18 00:38 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0004_auto_20160418_0034'), + ] + + operations = [ + migrations.RenameField( + model_name='virtualmachinetype', + old_name='cores_price', + new_name='core_price', + ), + ] diff --git a/hosting/models.py b/hosting/models.py index 28530a09..ea9d4d35 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -1,4 +1,9 @@ from django.db import models +from django.utils.translation import ugettext_lazy as _ +from django.core import serializers + + + class RailsBetaUser(models.Model): email = models.EmailField(unique=True) @@ -6,3 +11,30 @@ class RailsBetaUser(models.Model): def __str__(self): return "%s - %s" % (self.email, self.received_date) + + +class VirtualMachineType(models.Model): + + HETZNER_NUG = 'hetzner_nug' + HETZNER = 'hetzner' + HETZNER_R6 = 'hetzner_raid6' + HETZNER_G = 'hetzner_glusterfs' + BERN = 'bern' + + HOSTING_TYPES = ( + (HETZNER_NUG, 'Hetzner No Uptime Guarantee'), + (HETZNER, 'Hetzner'), + (HETZNER_R6, 'Hetzner Raid6'), + (HETZNER_G, 'Hetzner Glusterfs'), + (BERN, 'Bern'), + ) + + description = models.TextField() + base_price = models.FloatField() + memory_price = models.FloatField() + core_price = models.FloatField() + disk_size_price = models.FloatField() + hosting_company = models.CharField(max_length=10, choices=HOSTING_TYPES) + + def get_serialized_data(self): + return serializers("json", self) From 3015399692f871a6b33793525b5c2394bf629d7a Mon Sep 17 00:00:00 2001 From: Levi Date: Sun, 17 Apr 2016 20:05:39 -0500 Subject: [PATCH 2/4] registered VM types model in the admin --- hosting/admin.py | 4 +++- .../management/commands/create_vm_types.py | 3 ++- hosting/migrations/0006_auto_20160418_0103.py | 20 +++++++++++++++++++ hosting/migrations/0007_auto_20160418_0103.py | 20 +++++++++++++++++++ hosting/models.py | 7 ++++--- 5 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 hosting/migrations/0006_auto_20160418_0103.py create mode 100644 hosting/migrations/0007_auto_20160418_0103.py diff --git a/hosting/admin.py b/hosting/admin.py index 8d5366e5..84067ff9 100644 --- a/hosting/admin.py +++ b/hosting/admin.py @@ -1,4 +1,6 @@ from django.contrib import admin from .models import RailsBetaUser, VirtualMachineType -admin.site.register(RailsBetaUser, VirtualMachineType) + +admin.site.register(RailsBetaUser) +admin.site.register(VirtualMachineType) diff --git a/hosting/management/commands/create_vm_types.py b/hosting/management/commands/create_vm_types.py index 78d9fbe3..23961bae 100644 --- a/hosting/management/commands/create_vm_types.py +++ b/hosting/management/commands/create_vm_types.py @@ -51,4 +51,5 @@ class Command(BaseCommand): def handle(self, *args, **options): data = self.get_data() - [VirtualMachineType.objects.create(**data[key]) for key in data.keys()] + [VirtualMachineType.objects.create(hosting_company=key, **data[key]) + for key in data.keys()] diff --git a/hosting/migrations/0006_auto_20160418_0103.py b/hosting/migrations/0006_auto_20160418_0103.py new file mode 100644 index 00000000..51a93abd --- /dev/null +++ b/hosting/migrations/0006_auto_20160418_0103.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-04-18 01:03 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0005_auto_20160418_0038'), + ] + + operations = [ + migrations.AlterField( + model_name='virtualmachinetype', + name='hosting_company', + field=models.CharField(choices=[('hetzner_nug', 'Hetzner No Uptime Guarantee'), ('hetzner', 'Hetzner'), ('hetzner_raid6', 'Hetzner Raid6'), ('hetzner_glusterfs', 'Hetzner Glusterfs'), ('bern', 'Bern')], max_length=15), + ), + ] diff --git a/hosting/migrations/0007_auto_20160418_0103.py b/hosting/migrations/0007_auto_20160418_0103.py new file mode 100644 index 00000000..bff7570e --- /dev/null +++ b/hosting/migrations/0007_auto_20160418_0103.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-04-18 01:03 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0006_auto_20160418_0103'), + ] + + operations = [ + migrations.AlterField( + model_name='virtualmachinetype', + name='hosting_company', + field=models.CharField(choices=[('hetzner_nug', 'Hetzner No Uptime Guarantee'), ('hetzner', 'Hetzner'), ('hetzner_raid6', 'Hetzner Raid6'), ('hetzner_glusterfs', 'Hetzner Glusterfs'), ('bern', 'Bern')], max_length=30), + ), + ] diff --git a/hosting/models.py b/hosting/models.py index ea9d4d35..e66dbe28 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -3,8 +3,6 @@ from django.utils.translation import ugettext_lazy as _ from django.core import serializers - - class RailsBetaUser(models.Model): email = models.EmailField(unique=True) received_date = models.DateTimeField('date received') @@ -34,7 +32,10 @@ class VirtualMachineType(models.Model): memory_price = models.FloatField() core_price = models.FloatField() disk_size_price = models.FloatField() - hosting_company = models.CharField(max_length=10, choices=HOSTING_TYPES) + hosting_company = models.CharField(max_length=30, choices=HOSTING_TYPES) + + def __str__(self): + return "%s" % (self.get_hosting_company_display()) def get_serialized_data(self): return serializers("json", self) From cb51e08cefff960a48bfae1e1702ecdccb0bb868 Mon Sep 17 00:00:00 2001 From: Levi Date: Tue, 19 Apr 2016 01:04:15 -0500 Subject: [PATCH 3/4] Added serializer to VM model, Rewrite django hosting view , Created price selection templates , Added price selector with automatic price change --- hosting/models.py | 18 ++- hosting/static/hosting/css/pricing.css | 95 +++++++++++++ hosting/static/hosting/js/pricing.js | 58 ++++++++ hosting/templates/hosting/base.html | 26 +++- hosting/templates/hosting/pricing.html | 186 +++++++++++++++++++++++++ hosting/urls.py | 4 +- hosting/views.py | 30 +++- 7 files changed, 412 insertions(+), 5 deletions(-) create mode 100644 hosting/static/hosting/css/pricing.css create mode 100644 hosting/static/hosting/js/pricing.js create mode 100644 hosting/templates/hosting/pricing.html diff --git a/hosting/models.py b/hosting/models.py index e66dbe28..ba38219a 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -1,6 +1,7 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ from django.core import serializers +import json class RailsBetaUser(models.Model): @@ -37,5 +38,20 @@ class VirtualMachineType(models.Model): def __str__(self): return "%s" % (self.get_hosting_company_display()) + @classmethod + def get_serialized_vm_types(cls): + return [vm.get_serialized_data() + for vm in cls.objects.all()] + # return serializers.serialize("json",) + def get_serialized_data(self): - return serializers("json", self) + return { + 'description': self.description, + 'base_price': self.base_price, + 'core_price': self.core_price, + 'disk_size_price': self.disk_size_price, + 'memory_price': self.memory_price, + 'hosting_company_name': self.get_hosting_company_display(), + 'hosting_company': self.hosting_company, + 'id': self.id, + } diff --git a/hosting/static/hosting/css/pricing.css b/hosting/static/hosting/css/pricing.css new file mode 100644 index 00000000..870b3cf9 --- /dev/null +++ b/hosting/static/hosting/css/pricing.css @@ -0,0 +1,95 @@ +.pricing { + text-align: center; + border: 1px solid #f0f0f0; + color: #777; + font-size: 14px; + padding-left: 0; + margin-bottom: 30px; + font-family: 'Lato'; +} +.pricing img { + display: block; + margin: auto; + width: 32px; +} +.pricing li:first-child, +.pricing li:last-child { + padding: 20px 13px; +} +.pricing li { + list-style: none; + padding: 13px; +} +.pricing li + li { + border-top: 1px solid #f0f0f0; +} +.pricing big { + font-size: 32px; +} +.pricing h3 { + margin-bottom: 0; + font-size: 36px; +} +.pricing span { + font-size: 12px; + color: #999; + font-weight: normal; +} +.pricing li:nth-last-child(2) { + padding: 30px 13px; +} +.pricing button { + width: auto; + margin: auto; + font-size: 15px; + font-weight: bold; + border-radius: 50px; + color: #fff; + padding: 9px 24px; + background: #aaa; + opacity: 1; + transition: opacity .2s ease; + border: none; + outline: none; +} +.pricing button:hover { + opacity: .9; +} +.pricing button:active { + box-shadow: inset 0px 2px 2px rgba(0, 0, 0, 0.1); +} +/* pricing color */ +.p-green big, +.p-green h3 { + color: #4c7737; +} +.p-green button { + background: #4c7737; +} +.p-yel big, +.p-yel h3 { + color: #ffbb42; +} +.p-yel button { + background: #ffbb42; +} +.p-red big, +.p-red h3 { + color: #e13c4c; +} + +.pricing .short-input{ + min-width: 0; + width: 90px; +} + +.p-red button { + background: #e13c4c; +} +.p-blue big, +.p-blue h3 { + color: #3f4bb8; +} +.p-blue button { + background: #3f4bb8; +} \ No newline at end of file diff --git a/hosting/static/hosting/js/pricing.js b/hosting/static/hosting/js/pricing.js new file mode 100644 index 00000000..667239ab --- /dev/null +++ b/hosting/static/hosting/js/pricing.js @@ -0,0 +1,58 @@ +$( document ).ready(function() { + + //we need to load first VMTypesData from base.html django template + var pricingData = window.VMTypesData; + + + // Function to calculate the price given a vm type + function calculate_price(vm_type){ + + var ID_SELECTOR = "#"; + var CURRENCY = "$"; + var final_price_selector = ID_SELECTOR.concat(vm_type.concat('-final-price')); + var core_selector = ID_SELECTOR.concat(vm_type.concat('-cores')); + var memory_selector = ID_SELECTOR.concat(vm_type.concat('-memory')); + var disk_size_selector = ID_SELECTOR.concat(vm_type.concat('-disk_space')); + + //Get vm type prices + var cores = $(core_selector).val(); + var memory = $(memory_selector).val(); + var disk_size = $(disk_size_selector).val(); + var pricingData = eval(window.VMTypesData); + var company_prices = _.head(_.filter(pricingData, {hosting_company: vm_type})); + + //Calculate final price + var price = company_prices.base_price; + price += company_prices.core_price*cores; + price += company_prices.memory_price*memory; + price += company_prices.disk_size_price*disk_size; + + console.log(final_price_selector); + $(final_price_selector).text(price.toString().concat(CURRENCY)); + + + + + + + } + + //Listener function + function change_attribute(e){ + + var vm_type = this.getAttribute('data-vm-type'); + calculate_price(vm_type); + } + + + //Listeners + $('.cores-selector').on('change',change_attribute); + + $('.memory-selector').on('change',change_attribute); + + $('.disk-space-selector').on('change',change_attribute); + + console.log("mirame",window.VMTypesData); + + +}); \ No newline at end of file diff --git a/hosting/templates/hosting/base.html b/hosting/templates/hosting/base.html index d0d567c1..4c80530a 100644 --- a/hosting/templates/hosting/base.html +++ b/hosting/templates/hosting/base.html @@ -13,12 +13,17 @@ {{ domain }} - {{ hosting }} hosting as easy as possible + + + + + @@ -215,7 +220,9 @@
-
+ {% include "hosting/pricing.html" %} + +
@@ -384,9 +391,24 @@ + + {% if vm_types %} + + {%endif%} + + + + + + + + + diff --git a/hosting/templates/hosting/pricing.html b/hosting/templates/hosting/pricing.html new file mode 100644 index 00000000..95e8cc83 --- /dev/null +++ b/hosting/templates/hosting/pricing.html @@ -0,0 +1,186 @@ +
+
+ + {% for vm in vm_types %} +
+
+
+
+ + + {{vm.hosting_company_name}} + + +

+ {{vm.description}} +

+
+
+
+
+ + +
+
+
+ +
+ + + GiB +
+
+
+ + + GiB +
+
+

$199

+
+
+ +
+ + + + + +
+
+ {% endfor %} + {% for vm in vm_types %} +
+
+
    +
  • + +

    {{vm.hosting_company_name}}

    +
  • +
  • + +
    +
    + + +
    +
    + +
  • +
  • +
    +
    + + + GiB +
    +
    +
  • +
  • +
    + + + GiB +
    +
  • +
  • +

    select

    + per month +
  • +
  • + +
  • +
+
+
+ {% endfor %} + + + + + +
+
diff --git a/hosting/urls.py b/hosting/urls.py index 105c0ce9..ee79deb9 100644 --- a/hosting/urls.py +++ b/hosting/urls.py @@ -1,10 +1,12 @@ from django.conf.urls import url from . import views +from .views import VMPricingView, DjangoHostingView urlpatterns = [ url(r'beta$', views.beta, name='beta'), - url(r'django$', views.djangohosting, name='djangohosting'), + url(r'pricing/?$', VMPricingView.as_view(), name='pricing'), + url(r'django/?$', DjangoHostingView.as_view(), name='djangohosting'), url(r'nodejs$', views.nodejshosting, name='nodejshosting'), url(r'rails$', views.railshosting, name='railshosting'), ] diff --git a/hosting/views.py b/hosting/views.py index fc687b60..7bbb2b85 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -7,8 +7,36 @@ from django.core.urlresolvers import reverse from django.core.mail import send_mail from django.core.mail import mail_managers +from django.views.generic import View, DetailView + + +from .models import RailsBetaUser, VirtualMachineType + + +class VMPricingView(View): + template_name = "hosting/pricing.html" + + def get(self, request, *args, **kwargs): + return render(request, self.template_name, request) + + +class DjangoHostingView(View): + template_name = "hosting/django.html" + + def get_context_data(self, **kwargs): + context = {} + context["hosting"] = "django" + context["hosting_long"] = "Django" + context["domain"] = "django-hosting.ch" + context["google_analytics"] = "UA-62285904-6" + context["email"] = "info@django-hosting.ch" + context["vm_types"] = VirtualMachineType.get_serialized_vm_types() + return context + + def get(self, request, *args, **kwargs): + context = self.get_context_data() + return render(request, self.template_name, context) -from .models import RailsBetaUser class RailsBetaUserForm(ModelForm): required_css_class = 'form-control' From 64a484e749e2131072f34f9d1807160385df86c9 Mon Sep 17 00:00:00 2001 From: Levi Date: Wed, 20 Apr 2016 01:03:32 -0500 Subject: [PATCH 4/4] Separated base hosting page into html sections, Added pricing selector to Django Page, Added pricing selector to Rails Page, Added pricing selector to NodeJS Page, Implemented hosting signup , Implemented hosting login, Created forms to handle login/signup errors --- dynamicweb/urls.py | 4 +- hosting/forms.py | 50 +++ hosting/models.py | 10 +- hosting/static/hosting/css/landing-page.css | 6 +- hosting/static/hosting/js/pricing.js | 5 - hosting/templates/hosting/base.html | 334 ++---------------- .../templates/hosting/includes/_contact.html | 28 ++ .../templates/hosting/includes/_footer.html | 33 ++ .../templates/hosting/includes/_header.html | 31 ++ .../templates/hosting/includes/_navbar.html | 39 ++ .../hosting/includes/_our_infrastructure.html | 23 ++ .../templates/hosting/includes/_pricing.html | 144 ++++++++ .../includes/_your_infrastructure.html | 20 ++ hosting/templates/hosting/index.html | 10 +- hosting/templates/hosting/login.html | 53 ++- hosting/templates/hosting/pricing.html | 186 ---------- hosting/templates/hosting/signup.html | 59 ++-- hosting/urls.py | 12 +- hosting/views.py | 169 ++++++--- 19 files changed, 578 insertions(+), 638 deletions(-) create mode 100644 hosting/forms.py create mode 100644 hosting/templates/hosting/includes/_contact.html create mode 100644 hosting/templates/hosting/includes/_footer.html create mode 100644 hosting/templates/hosting/includes/_header.html create mode 100644 hosting/templates/hosting/includes/_navbar.html create mode 100644 hosting/templates/hosting/includes/_our_infrastructure.html create mode 100644 hosting/templates/hosting/includes/_pricing.html create mode 100644 hosting/templates/hosting/includes/_your_infrastructure.html delete mode 100644 hosting/templates/hosting/pricing.html diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py index daa7cbee..78c06077 100644 --- a/dynamicweb/urls.py +++ b/dynamicweb/urls.py @@ -5,12 +5,12 @@ from django.conf.urls.i18n import i18n_patterns from django.conf.urls.static import static from django.conf import settings -from hosting.views import railshosting +from hosting.views import RailsHostingView from membership import urls as membership_urls urlpatterns = [ url(r'^hosting/', include('hosting.urls', namespace="hosting")), - url(r'^railshosting/', railshosting, name="rails.hosting"), + url(r'^railshosting/', RailsHostingView.as_view(), name="rails.hosting"), url(r'^taggit_autosuggest/', include('taggit_autosuggest.urls')), url(r'^jsi18n/(?P\S+?)/$', 'django.views.i18n.javascript_catalog'), diff --git a/hosting/forms.py b/hosting/forms.py new file mode 100644 index 00000000..ddb30e1c --- /dev/null +++ b/hosting/forms.py @@ -0,0 +1,50 @@ +from django import forms +from membership.models import CustomUser +from django.contrib.auth import authenticate + + +class HostingUserLoginForm(forms.Form): + + email = forms.CharField(widget=forms.EmailInput()) + password = forms.CharField(widget=forms.PasswordInput()) + + class Meta: + fields = ['email', 'password'] + + def clean(self): + email = self.cleaned_data.get('email') + password = self.cleaned_data.get('password') + is_auth = authenticate(email=email, password=password) + if not is_auth: + raise forms.ValidationError("Your username and/or password were incorrect.") + return self.cleaned_data + + def clean_email(self): + email = self.cleaned_data.get('email') + try: + CustomUser.objects.get(email=email) + return email + except CustomUser.DoesNotExist: + raise forms.ValidationError("User does not exists") + else: + return email + + +class HostingUserSignupForm(forms.ModelForm): + + confirm_password = forms.CharField(widget=forms.PasswordInput()) + password = forms.CharField(widget=forms.PasswordInput()) + + class Meta: + model = CustomUser + fields = ['name', 'email', 'password'] + widgets = { + 'name': forms.TextInput(attrs={'placeholder': 'Enter your name or company name'}), + } + + def clean_confirm_password(self): + password = self.cleaned_data.get('password') + confirm_password = self.cleaned_data.get('confirm_password') + if not confirm_password == password: + raise forms.ValidationError("Passwords don't match") + return confirm_password diff --git a/hosting/models.py b/hosting/models.py index ba38219a..59ba8521 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -41,9 +41,16 @@ class VirtualMachineType(models.Model): @classmethod def get_serialized_vm_types(cls): return [vm.get_serialized_data() - for vm in cls.objects.all()] + for vm in cls.objects.all()] # return serializers.serialize("json",) + def defeault_price(self): + price = self.base_price + price += self.core_price + price += self.memory_price + price += self.disk_size_price * 10 + return price + def get_serialized_data(self): return { 'description': self.description, @@ -53,5 +60,6 @@ class VirtualMachineType(models.Model): 'memory_price': self.memory_price, 'hosting_company_name': self.get_hosting_company_display(), 'hosting_company': self.hosting_company, + 'default_price': self.defeault_price(), 'id': self.id, } diff --git a/hosting/static/hosting/css/landing-page.css b/hosting/static/hosting/css/landing-page.css index 6698c5ec..24be9dec 100644 --- a/hosting/static/hosting/css/landing-page.css +++ b/hosting/static/hosting/css/landing-page.css @@ -31,7 +31,8 @@ h6 { } .intro-header { - padding-top: 50px; /* If you're making other pages, make sure there is 50px of padding to make sure the navbar doesn't overlap content! */ + height: 85%; + padding-top: 10%; /* If you're making other pages, make sure there is 50px of padding to make sure the navbar doesn't overlap content! */ padding-bottom: 50px; text-align: center; color: #f8f8f8; @@ -47,7 +48,8 @@ h6 { background-size: cover; } .intro-header-2 { - padding-top: 50px; /* If you're making other pages, make sure there is 50px of padding to make sure the navbar doesn't overlap content! */ + height: 85%; + padding-top: 100px; /* If you're making other pages, make sure there is 50px of padding to make sure the navbar doesn't overlap content! */ padding-bottom: 50px; text-align: center; color: #f8f8f8; diff --git a/hosting/static/hosting/js/pricing.js b/hosting/static/hosting/js/pricing.js index 667239ab..64e80638 100644 --- a/hosting/static/hosting/js/pricing.js +++ b/hosting/static/hosting/js/pricing.js @@ -30,11 +30,6 @@ $( document ).ready(function() { console.log(final_price_selector); $(final_price_selector).text(price.toString().concat(CURRENCY)); - - - - - } //Listener function diff --git a/hosting/templates/hosting/base.html b/hosting/templates/hosting/base.html index 4c80530a..72ebff2e 100644 --- a/hosting/templates/hosting/base.html +++ b/hosting/templates/hosting/base.html @@ -60,336 +60,48 @@ - - + {% include "hosting/includes/_navbar.html" %} - -
-
- -
-
- -
- -

{{ domain }}

-

{{ hosting_long }} as easy as possible

-
- -
-
-
- -
- - -
- + {% include "hosting/includes/_header.html" %} -
- -
- -
-
-
-
-

How it works :

    - {% block specification %} - {% endblock %} -
-
- {% with 'hosting/img/card-'|add:hosting|add:'.png' as image_static %} -
- -
- {% endwith %} -
- -
- - -
- -
-
-
-
-
-
-

Option 1 : Your own infrastructure

-

We configure your own infrastructure for {{ hosting_long }}. Keep the comfort and safety of being at your home, while we set things up for you.

-
-
- -
-
- -
- -
- - - -
-
-
-
-
-

Option 2 : Our infrastructure

-

We take care of everything for you! You don't need your infrastructure. We give you everything you need in {{ hosting_long }} hosting. Full root access, 24x7 support.

+
+
+

How it works :

+
    + {% block specification %} + {% endblock %} +
+ {% with 'hosting/img/card-'|add:hosting|add:'.png' as image_static %}
- +
+ {% endwith %}
+
+
- - + + {% include "hosting/includes/_your_infrastructure.html" %} - - - - -
+ + {% include "hosting/includes/_our_infrastructure.html" %} -
+ + {% include "hosting/includes/_pricing.html" %} -
-
-
-
-

Hosting Price Samples

-

Here are samples of our {{ hosting_long }} hosting offers, suited for different projects. Our offer examples come in different size, speed, and storage.

-
- -
-
-
- - - -
- - {% include "hosting/pricing.html" %} - - -
- -
- -
- - -
- - -
-
- -
-
- -
-

Let me try!

-

 

-

 

- {% if error_message %}

{{ error_message }}

{% endif %} - {{ form.non_field_errors }} - {{ form.email.errors }} -
- {% csrf_token %} -
- - -
- -
- - - -
-
-
- -
- - -
- - - - - + + {% include "hosting/includes/_contact.html" %} - + {% include "hosting/includes/_footer.html" %} {% if vm_types %} diff --git a/hosting/templates/hosting/includes/_contact.html b/hosting/templates/hosting/includes/_contact.html new file mode 100644 index 00000000..b0ad9ff7 --- /dev/null +++ b/hosting/templates/hosting/includes/_contact.html @@ -0,0 +1,28 @@ + + \ No newline at end of file diff --git a/hosting/templates/hosting/includes/_footer.html b/hosting/templates/hosting/includes/_footer.html new file mode 100644 index 00000000..270c9b61 --- /dev/null +++ b/hosting/templates/hosting/includes/_footer.html @@ -0,0 +1,33 @@ +{% load staticfiles %} + + \ No newline at end of file diff --git a/hosting/templates/hosting/includes/_header.html b/hosting/templates/hosting/includes/_header.html new file mode 100644 index 00000000..03e3e5c2 --- /dev/null +++ b/hosting/templates/hosting/includes/_header.html @@ -0,0 +1,31 @@ +{% load staticfiles %} + + +
+
+ +
+
+ +
+ +

{{ domain }}

+

{{ hosting_long }} as easy as possible

+
+ +
+
+
+ +
+ + +
+ \ No newline at end of file diff --git a/hosting/templates/hosting/includes/_navbar.html b/hosting/templates/hosting/includes/_navbar.html new file mode 100644 index 00000000..62ae9a12 --- /dev/null +++ b/hosting/templates/hosting/includes/_navbar.html @@ -0,0 +1,39 @@ +{% load staticfiles %} + + + \ No newline at end of file diff --git a/hosting/templates/hosting/includes/_our_infrastructure.html b/hosting/templates/hosting/includes/_our_infrastructure.html new file mode 100644 index 00000000..135d6ba4 --- /dev/null +++ b/hosting/templates/hosting/includes/_our_infrastructure.html @@ -0,0 +1,23 @@ +{% load staticfiles %} + + +
+ +
+ +
+
+
+
+

Option 2 : Our infrastructure

+

We take care of everything for you! You don't need your infrastructure. We give you everything you need in {{ hosting_long }} hosting. Full root access, 24x7 support.

+
+
+ +
+
+ +
+ + +
\ No newline at end of file diff --git a/hosting/templates/hosting/includes/_pricing.html b/hosting/templates/hosting/includes/_pricing.html new file mode 100644 index 00000000..628a65f8 --- /dev/null +++ b/hosting/templates/hosting/includes/_pricing.html @@ -0,0 +1,144 @@ + +
+
+
+
+
+
+

Hosting Price Samples

+

Here are samples of our {{ hosting_long }} hosting offers, suited for different projects. Our offer examples come in different size, speed, and storage.

+
+ +
+
+
+ + +
+ +
+ + {% for vm in vm_types %} +
+
+
+
+ + + {{vm.hosting_company_name}} + + +

+ {{vm.description}} +

+
+
+
+
+ + +
+
+
+ +
+ + + GiB +
+
+
+ + + GiB +
+
+

$199

+
+
+ +
+ + + + + +
+
+ {% endfor %} + {% for vm in vm_types %} +
+
+
    +
  • + +

    {{vm.hosting_company_name}}

    +
  • +
  • + +
    +
    + + +
    +
    + +
  • +
  • +
    +
    + + + GiB +
    +
    +
  • +
  • +
    + + + GiB +
    +
  • +
  • +

    {{vm.default_price|floatformat}}$

    + per month +
  • +
  • + +
  • +
+
+
+ {% endfor %} + +
+
+
+ +
+
\ No newline at end of file diff --git a/hosting/templates/hosting/includes/_your_infrastructure.html b/hosting/templates/hosting/includes/_your_infrastructure.html new file mode 100644 index 00000000..e70a6261 --- /dev/null +++ b/hosting/templates/hosting/includes/_your_infrastructure.html @@ -0,0 +1,20 @@ +{% load staticfiles %} + + +
+
+
+
+
+
+

Option 1 : Your own infrastructure

+

We configure your own infrastructure for {{ hosting_long }}. Keep the comfort and safety of being at your home, while we set things up for you.

+
+
+ +
+
+ +
+ +
\ No newline at end of file diff --git a/hosting/templates/hosting/index.html b/hosting/templates/hosting/index.html index 0956b500..446534d4 100644 --- a/hosting/templates/hosting/index.html +++ b/hosting/templates/hosting/index.html @@ -14,16 +14,16 @@ Rails Hosting.ch - Ruby on Rails as easy as possible - + - + - + - + @@ -296,7 +296,7 @@ {% if error_message %}

{{ error_message }}

{% endif %} {{ form.non_field_errors }} {{ form.email.errors }} -
+ {% csrf_token %}
diff --git a/hosting/templates/hosting/login.html b/hosting/templates/hosting/login.html index 3a00b83e..04def39f 100644 --- a/hosting/templates/hosting/login.html +++ b/hosting/templates/hosting/login.html @@ -1,3 +1,4 @@ +{% load staticfiles bootstrap3%} @@ -12,10 +13,10 @@ Rails Hosting.ch - Ruby on Rails as easy as possible - + - + @@ -77,34 +78,26 @@
-
 
- -
-

Log In

- -
- - -
-
- - -
- - -

-
    - -
 
-
-
+
 
+
+

Login

+
+ {% csrf_token %} + {% for field in form %} + {% bootstrap_field field show_label=False type='fields'%} + {% endfor %} + {% bootstrap_form_errors form type='non_fields'%} + {% buttons %} + + {% endbuttons %} +
+
    + +
+
-
@@ -138,7 +131,7 @@ Contact - +
diff --git a/hosting/templates/hosting/pricing.html b/hosting/templates/hosting/pricing.html deleted file mode 100644 index 95e8cc83..00000000 --- a/hosting/templates/hosting/pricing.html +++ /dev/null @@ -1,186 +0,0 @@ -
-
- - {% for vm in vm_types %} -
-
-
-
- - - {{vm.hosting_company_name}} - - -

- {{vm.description}} -

-
-
-
-
- - -
-
-
- -
- - - GiB -
-
-
- - - GiB -
-
-

$199

-
-
- -
- - - - - -
-
- {% endfor %} - {% for vm in vm_types %} -
-
-
    -
  • - -

    {{vm.hosting_company_name}}

    -
  • -
  • - -
    -
    - - -
    -
    - -
  • -
  • -
    -
    - - - GiB -
    -
    -
  • -
  • -
    - - - GiB -
    -
  • -
  • -

    select

    - per month -
  • -
  • - -
  • -
-
-
- {% endfor %} - - - - - -
-
diff --git a/hosting/templates/hosting/signup.html b/hosting/templates/hosting/signup.html index b7dc3239..d92957bc 100644 --- a/hosting/templates/hosting/signup.html +++ b/hosting/templates/hosting/signup.html @@ -1,3 +1,5 @@ +{% load staticfiles bootstrap3%} + @@ -9,13 +11,13 @@ - Rails Hosting.ch - Ruby on Rails as easy as possible + Signup - + - + @@ -45,7 +47,7 @@ - + @@ -139,7 +132,7 @@ Contact - + diff --git a/hosting/urls.py b/hosting/urls.py index ee79deb9..0852bc0d 100644 --- a/hosting/urls.py +++ b/hosting/urls.py @@ -1,12 +1,14 @@ from django.conf.urls import url -from . import views -from .views import VMPricingView, DjangoHostingView +from .views import VMPricingView, DjangoHostingView, RailsHostingView, \ + NodeJSHostingView, LoginView, SignupView, IndexView urlpatterns = [ - url(r'beta$', views.beta, name='beta'), + url(r'index/?$', IndexView.as_view(), name='index'), url(r'pricing/?$', VMPricingView.as_view(), name='pricing'), url(r'django/?$', DjangoHostingView.as_view(), name='djangohosting'), - url(r'nodejs$', views.nodejshosting, name='nodejshosting'), - url(r'rails$', views.railshosting, name='railshosting'), + url(r'nodejs/?$', NodeJSHostingView.as_view(), name='nodejshosting'), + url(r'rails/?$', RailsHostingView.as_view(), name='railshosting'), + url(r'login/?$', LoginView.as_view(), name='login'), + url(r'signup/?$', SignupView.as_view(), name='signup'), ] diff --git a/hosting/views.py b/hosting/views.py index 7bbb2b85..27bbeea2 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1,16 +1,14 @@ -import datetime from django.shortcuts import get_object_or_404, render -from django.forms import ModelForm +from django.core.urlresolvers import reverse_lazy, reverse + +from django.views.generic import View, CreateView, FormView from django.http import HttpResponseRedirect -from django.core.urlresolvers import reverse - -from django.core.mail import send_mail -from django.core.mail import mail_managers -from django.views.generic import View, DetailView - +from django.contrib.auth import authenticate, login +from membership.models import CustomUser from .models import RailsBetaUser, VirtualMachineType +from .forms import HostingUserSignupForm, HostingUserLoginForm class VMPricingView(View): @@ -38,67 +36,122 @@ class DjangoHostingView(View): return render(request, self.template_name, context) -class RailsBetaUserForm(ModelForm): - required_css_class = 'form-control' - class Meta: - model = RailsBetaUser - fields = [ 'email' ] +class RailsHostingView(View): + template_name = "hosting/rails.html" -def hosting(request, context): - email = RailsBetaUser(received_date=datetime.datetime.now()) + def get_context_data(self, **kwargs): + context = {} + context["hosting"] = "rails" + context["hosting_long"] = "Ruby On Rails" + context["domain"] = "rails-hosting.ch" + context["google_analytics"] = "UA-62285904-5" + context["email"] = "info@rails-hosting.ch" + context["vm_types"] = VirtualMachineType.get_serialized_vm_types() + return context - if request.method == 'POST': - context['form'] = RailsBetaUserForm(request.POST, instance=email) - if context['form'].is_valid(): - context['form'].save() - email = context['form'].cleaned_data['email'] - subject = "%shosting request" % context['hosting'] - message = "Request for beta by: %s" % email + def get(self, request, *args, **kwargs): + context = self.get_context_data() + return render(request, self.template_name, context) - mail_managers(subject, message) - return HttpResponseRedirect(reverse("hosting:beta")) - else: - context['form'] = RailsBetaUserForm() - context['error_message'] = "a problem" +class NodeJSHostingView(View): + template_name = "hosting/nodejs.html" - page = "hosting/%s.html" % context['hosting'] + def get_context_data(self, **kwargs): + context = {} + context["hosting"] = "nodejs" + context["hosting_long"] = "NodeJS" + context["domain"] = "node-hosting.ch" + context["google_analytics"] = "UA-62285904-7" + context["email"] = "info@node-hosting.ch" + context["vm_types"] = VirtualMachineType.get_serialized_vm_types() + return context - return render(request, page, context) + def get(self, request, *args, **kwargs): + context = self.get_context_data() + return render(request, self.template_name, context) -################################################################################ -# Hostings -# -def djangohosting(request): - context = {} - context["hosting"]="django" - context["hosting_long"]="Django" - context["domain"]="django-hosting.ch" - context["google_analytics"]="UA-62285904-6" - context["email"]="info@django-hosting.ch" - return hosting(request, context) +class IndexView(View): + template_name = "hosting/index.html" -def railshosting(request): - context = {} - context["hosting"]="rails" - context["hosting_long"]="Ruby On Rails" - context["domain"]="rails-hosting.ch" - context["google_analytics"]="UA-62285904-5" - context["email"]="info@rails-hosting.ch" + def get_context_data(self, **kwargs): + context = {} + context["hosting"] = "nodejs" + context["hosting_long"] = "NodeJS" + context["domain"] = "node-hosting.ch" + context["google_analytics"] = "UA-62285904-7" + context["email"] = "info@node-hosting.ch" + context["vm_types"] = VirtualMachineType.get_serialized_vm_types() + return context - return hosting(request, context) + def get(self, request, *args, **kwargs): + context = self.get_context_data() + return render(request, self.template_name, context) -def nodejshosting(request): - context = {} - context["hosting"]="nodejs" - context["hosting_long"]="NodeJS" - context["domain"]="node-hosting.ch" - context["google_analytics"]="UA-62285904-7" - context["email"]="info@node-hosting.ch" +class LoginView(FormView): + template_name = 'hosting/login.html' + form_class = HostingUserLoginForm + moodel = CustomUser + success_url = reverse_lazy('hosting:login') - return hosting(request, context) + def form_valid(self, form): + email = form.cleaned_data.get('email') + password = form.cleaned_data.get('password') + auth_user = authenticate(email=email, password=password) + if auth_user: + login(self.request, auth_user) + return HttpResponseRedirect(self.get_success_url()) + return HttpResponseRedirect(self.get_success_url()) -def beta(request): - return render(request, 'hosting/beta.html') + +class SignupView(CreateView): + template_name = 'hosting/signup.html' + form_class = HostingUserSignupForm + moodel = CustomUser + + def get_success_url(self): + return reverse_lazy('hosting:signup') + + def form_valid(self, form): + name = form.cleaned_data.get('name') + email = form.cleaned_data.get('email') + password = form.cleaned_data.get('password') + CustomUser.register(name, password, email) + auth_user = authenticate(email=email, password=password) + login(self.request, auth_user) + return HttpResponseRedirect(self.get_success_url()) + + + +# class RailsBetaUserForm(ModelForm): +# required_css_class = 'form-control' +# class Meta: +# model = RailsBetaUser +# fields = [ 'email' ] + +# def hosting(request, context): +# email = RailsBetaUser(received_date=datetime.datetime.now()) + +# if request.method == 'POST': +# context['form'] = RailsBetaUserForm(request.POST, instance=email) +# if context['form'].is_valid(): +# context['form'].save() +# email = context['form'].cleaned_data['email'] +# subject = "%shosting request" % context['hosting'] +# message = "Request for beta by: %s" % email + +# mail_managers(subject, message) + +# return HttpResponseRedirect(reverse("hosting:beta")) +# else: +# context['form'] = RailsBetaUserForm() +# context['error_message'] = "a problem" + +# page = "hosting/%s.html" % context['hosting'] + +# return render(request, page, context) + +# def beta(request): +# return render(request, 'hosting/beta.html')