merge master
This commit is contained in:
commit
3ed2399337
68 changed files with 3099 additions and 950 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from django import forms
|
||||
|
||||
from .models import BetaAccess
|
||||
from .models import BetaAccess, ContactUs
|
||||
|
||||
|
||||
class BetaAccessForm(forms.ModelForm):
|
||||
|
|
@ -11,6 +11,13 @@ class BetaAccessForm(forms.ModelForm):
|
|||
model = BetaAccess
|
||||
|
||||
|
||||
class ContactForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
fields = ['name', 'email', 'message']
|
||||
model = ContactUs
|
||||
|
||||
|
||||
# class BetaAccessVMForm(forms.ModelForm):
|
||||
# type = forms.CharField(widget=forms.EmailInput())
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2017-08-03 03:10+0530\n"
|
||||
"POT-Creation-Date: 2017-08-24 11:28+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
@ -82,6 +82,24 @@ msgstr "Bitte gib eine gültige E-Mailadresse ein."
|
|||
msgid "Continue"
|
||||
msgstr "Weiter"
|
||||
|
||||
msgid "Thank you for contacting us."
|
||||
msgstr "Nachricht gesendet."
|
||||
|
||||
msgid "Your message was successfully sent to our team."
|
||||
msgstr "Vielen Dank für Deine Nachricht."
|
||||
|
||||
msgid "Get in touch with us!"
|
||||
msgstr "Sende uns eine Nachricht."
|
||||
|
||||
msgid "Message"
|
||||
msgstr "Nachricht"
|
||||
|
||||
msgid "Sorry, there was an unexpected error. Kindly retry."
|
||||
msgstr "Bitte entschuldige, es scheint ein unerwarteter Fehler aufgetreten zu sein. Versuche es doch bitte noch einmal."
|
||||
|
||||
msgid "SUBMIT"
|
||||
msgstr "ABSENDEN"
|
||||
|
||||
msgid "Thank you for your request."
|
||||
msgstr "Vielen Dank für Ihre Anfrage."
|
||||
|
||||
|
|
@ -234,15 +252,12 @@ msgstr ""
|
|||
msgid "Affordable VM hosting based in Switzerland"
|
||||
msgstr "Bezahlbares VM Hosting in der Schweiz"
|
||||
|
||||
msgid "Contact us"
|
||||
msgstr "Kontaktiere uns"
|
||||
|
||||
msgid "Switzerland "
|
||||
msgstr "Schweiz"
|
||||
|
||||
msgid "Questions?"
|
||||
msgstr "Fragen?"
|
||||
|
||||
msgid "Contact us!"
|
||||
msgstr "Kontaktiere uns!"
|
||||
|
||||
msgid "Confirm Order"
|
||||
msgstr "Bestellung Bestätigen"
|
||||
|
||||
|
|
@ -276,6 +291,19 @@ msgstr "Konfiguration"
|
|||
msgid "Total"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
#| msgid "month"
|
||||
msgid "Month"
|
||||
msgstr "Monat"
|
||||
|
||||
#, python-format
|
||||
msgid ""
|
||||
"By clicking \"Place order\" this plan will charge your credit card account "
|
||||
"with the fee of %(vm_price)sCHF/month"
|
||||
msgstr ""
|
||||
"Wenn Du \"bestellen\" auswählst, wird Deine Kreditkarte mit %(vm_price)sCHF "
|
||||
"pro Monat belastet"
|
||||
|
||||
msgid "Place order"
|
||||
msgstr "Bestellen"
|
||||
|
||||
|
|
@ -399,6 +427,9 @@ msgstr "ist kein gültiger Name"
|
|||
msgid "is not a proper email"
|
||||
msgstr "ist keine gültige E-Mailadresse"
|
||||
|
||||
#~ msgid "Questions?"
|
||||
#~ msgstr "Fragen?"
|
||||
|
||||
#~ msgid "Please enter a value greater than or equal to 1."
|
||||
#~ msgstr "Bitte gib einen Wert größer oder gleich 1 ein."
|
||||
|
||||
|
|
|
|||
24
datacenterlight/migrations/0007_contactus.py
Normal file
24
datacenterlight/migrations/0007_contactus.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2017-08-19 21:08
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('datacenterlight', '0006_vmtemplate'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ContactUs',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=250)),
|
||||
('email', models.CharField(max_length=250)),
|
||||
('message', models.TextField()),
|
||||
],
|
||||
),
|
||||
]
|
||||
22
datacenterlight/migrations/0007_stripeplan.py
Normal file
22
datacenterlight/migrations/0007_stripeplan.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2017-08-16 19:47
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('datacenterlight', '0006_vmtemplate'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='StripePlan',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('stripe_plan_id', models.CharField(max_length=100, null=True)),
|
||||
],
|
||||
),
|
||||
]
|
||||
20
datacenterlight/migrations/0008_auto_20170821_2024.py
Normal file
20
datacenterlight/migrations/0008_auto_20170821_2024.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2017-08-21 20:24
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('datacenterlight', '0007_stripeplan'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='stripeplan',
|
||||
name='stripe_plan_id',
|
||||
field=models.CharField(max_length=256, null=True),
|
||||
),
|
||||
]
|
||||
23
datacenterlight/migrations/0008_contactus_field.py
Normal file
23
datacenterlight/migrations/0008_contactus_field.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2017-08-23 13:06
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import datetime
|
||||
from django.db import migrations, models
|
||||
from django.utils.timezone import utc
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('datacenterlight', '0007_contactus'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='contactus',
|
||||
name='field',
|
||||
field=models.DateTimeField(auto_now_add=True, default=datetime.datetime(2017, 8, 23, 13, 6, 24, 650869, tzinfo=utc)),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
16
datacenterlight/migrations/0009_merge.py
Normal file
16
datacenterlight/migrations/0009_merge.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2017-08-27 07:55
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('datacenterlight', '0007_contactus'),
|
||||
('datacenterlight', '0008_auto_20170821_2024'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
]
|
||||
16
datacenterlight/migrations/0010_merge.py
Normal file
16
datacenterlight/migrations/0010_merge.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2017-08-27 08:02
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('datacenterlight', '0009_merge'),
|
||||
('datacenterlight', '0008_contactus_field'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
]
|
||||
|
|
@ -57,5 +57,25 @@ class VMTemplate(models.Model):
|
|||
|
||||
@classmethod
|
||||
def create(cls, name, opennebula_vm_template_id):
|
||||
vm_template = cls(name=name, opennebula_vm_template_id=opennebula_vm_template_id)
|
||||
vm_template = cls(
|
||||
name=name, opennebula_vm_template_id=opennebula_vm_template_id)
|
||||
return vm_template
|
||||
|
||||
|
||||
class StripePlan(models.Model):
|
||||
"""
|
||||
A model to store Data Center Light's created Stripe plans
|
||||
"""
|
||||
stripe_plan_id = models.CharField(max_length=256, null=True)
|
||||
|
||||
@classmethod
|
||||
def create(cls, stripe_plan_id):
|
||||
stripe_plan = cls(stripe_plan_id=stripe_plan_id)
|
||||
return stripe_plan
|
||||
|
||||
|
||||
class ContactUs(models.Model):
|
||||
name = models.CharField(max_length=250)
|
||||
email = models.CharField(max_length=250)
|
||||
message = models.TextField()
|
||||
field = models.DateTimeField(auto_now_add=True)
|
||||
|
|
|
|||
47
datacenterlight/static/datacenterlight/css/cms.css
Normal file
47
datacenterlight/static/datacenterlight/css/cms.css
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
.dcl-cms_page-full-width {
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
background-image: -ms-linear-gradient(right, #29427A 50%, #4F6699 100%);
|
||||
background-image: -moz-linear-gradient(right, #29427A 50%, #4F6699 100%);
|
||||
background-image: -o-linear-gradient(right, #29427A 50%, #4F6699 100%);
|
||||
background-image: -webkit-gradient(linear, right top, left top, color-stop(50, #29427A), color-stop(100, #4F6699));
|
||||
background-image: -webkit-linear-gradient(right, #29427A 50%, #4F6699 100%);
|
||||
background-image: linear-gradient(to left, #29427A 50%, #4F6699 100%);
|
||||
}
|
||||
|
||||
.dcl-cms_page-header {
|
||||
padding: 150px 0 150px 0;
|
||||
text-align: center;
|
||||
color: #f8f8f8;
|
||||
background: url(../img/pattern.jpg) no-repeat center center;
|
||||
background-size: cover;
|
||||
position: relative;
|
||||
background-attachment: fixed;
|
||||
}
|
||||
|
||||
.dcl-cms_page-header::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: rgba(90, 116, 175, 0.85);
|
||||
}
|
||||
|
||||
#dcl-cms_page-text {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
#dcl-cms_page-text h3 {
|
||||
font-size: 42px;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
#dcl-cms_page-text h3 {
|
||||
font-size: 30px;
|
||||
line-height: 40px;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,10 +4,10 @@
|
|||
* For details, see http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*/
|
||||
|
||||
@font-face {
|
||||
/*@font-face {
|
||||
font-family: 'Lato-Light';
|
||||
src: url('../fonts/Lato/Lato-Light.ttf');
|
||||
}
|
||||
}*/
|
||||
|
||||
body,
|
||||
html {
|
||||
|
|
@ -22,7 +22,12 @@ h3,
|
|||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
font-family: 'Lato-Light', sans-serif;
|
||||
/*font-family: 'Lato-Light', sans-serif;*/
|
||||
font-family: 'Lato', sans-serif;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
button, input, optgroup, select, textarea {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
|
|
@ -143,13 +148,15 @@ h6 {
|
|||
|
||||
.navbar-default .navbar-nav>li>a {
|
||||
cursor: pointer;
|
||||
font-family: 'Lato-Light', sans-serif;
|
||||
/*font-family: 'Lato-Light', sans-serif;*/
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.navbar-transparent .navbar-nav>li>a {
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
font-family: 'Lato-Light', sans-serif;
|
||||
/*font-family: 'Lato-Light', sans-serif;*/
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.navbar-transparent .navbar-nav>li>a:hover {
|
||||
|
|
@ -202,13 +209,15 @@ h6 {
|
|||
|
||||
.navbar-transparent .nav-language .select-language {
|
||||
color: #fff;
|
||||
font-family: 'Lato-Light', sans-serif;
|
||||
/*font-family: 'Lato-Light', sans-serif;*/
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.nav-language .select-language span {
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
font-family: 'Lato', sans-serif;
|
||||
/*font-family: 'Lato', sans-serif;*/
|
||||
font-weight: normal;
|
||||
}
|
||||
.nav-language .drop-language{
|
||||
/*position: absolute;*/
|
||||
|
|
@ -237,7 +246,8 @@ h6 {
|
|||
.nav-language .drop-language a{
|
||||
cursor: pointer;
|
||||
padding: 5px 10px !important;
|
||||
font-family: 'Lato-Light', sans-serif;
|
||||
/*font-family: 'Lato-Light', sans-serif;*/
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
/* Show the dropdown menu on hover */
|
||||
|
|
@ -260,7 +270,8 @@ h6 {
|
|||
.navbar-transparent .nav-language .drop-language a {
|
||||
color: #fff;
|
||||
padding: 5px 10px !important;
|
||||
font-family: 'Lato-Light', sans-serif;
|
||||
/*font-family: 'Lato-Light', sans-serif;*/
|
||||
font-weight: 300;
|
||||
}
|
||||
/* .nav-language:hover .drop-language{
|
||||
display: block;
|
||||
|
|
@ -312,9 +323,9 @@ h6 {
|
|||
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! */
|
||||
padding-bottom: 50px;
|
||||
text-align: center;
|
||||
/* text-align: center; */
|
||||
color: #f8f8f8;
|
||||
background: url(../img/banner-bg.jpg) no-repeat center center;
|
||||
background: url(../img/pattern.jpg) no-repeat center center;
|
||||
background-size: cover;
|
||||
position: relative;
|
||||
}
|
||||
|
|
@ -343,7 +354,7 @@ h6 {
|
|||
|
||||
.intro-message>h1 {
|
||||
margin: 0;
|
||||
font-weight: 400;
|
||||
font-weight: 300;
|
||||
font-size: 6em;
|
||||
}
|
||||
|
||||
|
|
@ -643,74 +654,161 @@ h6 {
|
|||
position: relative;
|
||||
}
|
||||
|
||||
.full-contact-section {
|
||||
background-image: -ms-linear-gradient(right, #29427A 50%, #4F6699 100%);
|
||||
background-image: -moz-linear-gradient(right, #29427A 50%, #4F6699 100%);
|
||||
background-image: -o-linear-gradient(right, #29427A 50%, #4F6699 100%);
|
||||
background-image: -webkit-gradient(linear, right top, left top, color-stop(50, #29427A), color-stop(100, #4F6699));
|
||||
background-image: -webkit-linear-gradient(right, #29427A 50%, #4F6699 100%);
|
||||
background-image: linear-gradient(to left, #29427A 50%, #4F6699 100%);
|
||||
}
|
||||
|
||||
.contact-section {
|
||||
padding: 60px 0;
|
||||
color: #fff;
|
||||
padding: 80px 0;
|
||||
color: rgba(255,255,255,0.9);
|
||||
background-attachment: fixed;
|
||||
}
|
||||
|
||||
.contact-section .card {
|
||||
text-align: center;
|
||||
width: 350px;
|
||||
margin: 0 auto;
|
||||
background: #fff;
|
||||
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
|
||||
padding-bottom: 40px;
|
||||
border-radius: 7px;
|
||||
color: #4c4444;
|
||||
box-sizing: border-box;
|
||||
padding: 45px;
|
||||
margin-top: -115px;
|
||||
.contact-section .modal {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.contact-section .card .social a {
|
||||
color: #29427A;
|
||||
.contact-details {
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.contact-section .description{
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.contact-section .social a {
|
||||
color: #fff;
|
||||
font-size: 45px;
|
||||
}
|
||||
|
||||
.contact-section .card .subtitle h3 {
|
||||
font-size: 30px;
|
||||
margin-bottom: 23px;
|
||||
.contact-section .social .fa-facebook {
|
||||
font-size: 40px;
|
||||
background: #fff;
|
||||
border-radius: 100%;
|
||||
color: #425d89;
|
||||
width: 40px;
|
||||
text-align: center;
|
||||
top: -2px;
|
||||
position: relative;
|
||||
left: 10px;
|
||||
}
|
||||
.contact-section .social .fa-facebook:before {
|
||||
font-size: 32px;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
left: -1px;
|
||||
}
|
||||
|
||||
.contact-section .card .social a:hover {
|
||||
.contact-section .social a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.contact-section .title {
|
||||
margin-right: auto;
|
||||
width: 80%;
|
||||
max-width: 468px;
|
||||
.contact-section .subtitle h3 {
|
||||
font-size: 30px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.contact-section .contact-form-success {
|
||||
font-size: 18px;
|
||||
text-align: center;
|
||||
background-color: rgba(0,0,0,0.2);
|
||||
padding: 0 15px 35px;
|
||||
margin-top: 25px;
|
||||
}
|
||||
|
||||
.contact-section .title h2 {
|
||||
font-size: 65px;
|
||||
margin: 0;
|
||||
color: #fff;
|
||||
padding-bottom: 25px;
|
||||
position: relative;
|
||||
text-align: right;
|
||||
/* color: #eee;
|
||||
padding-bottom: 25px;
|
||||
text-align: right; */
|
||||
}
|
||||
|
||||
.contact-section .title h2::before {
|
||||
content: "";
|
||||
.contact-form .form-group {
|
||||
border: 0;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.contact-form .form-group label {
|
||||
letter-spacing: 0.6px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.contact-form .btn {
|
||||
min-width: 140px;
|
||||
background: rgba(23, 23, 23, 0.18);
|
||||
color: #fff;
|
||||
border-radius: 4px;
|
||||
border-width: 2px;
|
||||
box-shadow: none;
|
||||
letter-spacing: 2px;
|
||||
border-color: #fff;
|
||||
}
|
||||
|
||||
.contact-form .btn.sending {
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
@keyframes sending {
|
||||
0% {content: '.';}
|
||||
50% {content: '..';}
|
||||
100% {content: '...';}
|
||||
}
|
||||
|
||||
.contact-form .btn.sending:after {
|
||||
content: '.';
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
background: #fff;
|
||||
height: 7px;
|
||||
width: 70px;
|
||||
right: 0;
|
||||
display: inline-block;
|
||||
text-align: left;
|
||||
margin-left: 5px;
|
||||
width: 20px;
|
||||
animation: sending 1s linear infinite;
|
||||
}
|
||||
|
||||
.contact-form .btn:hover,
|
||||
.contact-form .btn:focus {
|
||||
background: rgba(23, 23, 23, 0.28);
|
||||
border-color: #fff;
|
||||
box-shadow: none;
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.contact-form .form-control {
|
||||
box-shadow: none;
|
||||
border-color: #ccc;
|
||||
}
|
||||
|
||||
.contact-form .errorlist {
|
||||
list-style: none;
|
||||
padding: 5px;
|
||||
margin: 0;
|
||||
color: rgb(255, 164, 164);
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
|
||||
.contact-form .form-error {
|
||||
background: rgba(255,255,255,0.9);
|
||||
color: #eb4d5c;
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.contact-form .has-error label {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.contact-form .has-error .form-control {
|
||||
border: 2px solid #e8534b;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.contact-form .subtitle {
|
||||
padding: 22px 0 15px;
|
||||
}
|
||||
|
||||
.contact-form textarea {
|
||||
resize: none;
|
||||
}
|
||||
|
||||
/*Why DCL*/
|
||||
|
||||
|
|
@ -792,7 +890,8 @@ tech-sub-sec h2 {
|
|||
}
|
||||
|
||||
.percent-text {
|
||||
font-family: 'Lato', sans-serif;
|
||||
/*font-family: 'Lato', sans-serif;*/
|
||||
/* font-weight: normal; */
|
||||
font-size: 50px;
|
||||
color: #999;
|
||||
}
|
||||
|
|
@ -879,7 +978,7 @@ tech-sub-sec h2 {
|
|||
.dropdown-menu>li>a {
|
||||
font-size: 13px;
|
||||
font-weight: 300;
|
||||
font-family: 'Lato-Light', sans-serif;
|
||||
/*font-family: 'Lato-Light', sans-serif;*/
|
||||
}
|
||||
|
||||
.navbar-default .navbar-nav>.active>a,
|
||||
|
|
@ -898,7 +997,8 @@ tech-sub-sec h2 {
|
|||
background: -webkit-linear-gradient(top, #f0f4f7, #fff) no-repeat;
|
||||
background: linear-gradient(to bottom, #f0f4f7, #fff) no-repeat;
|
||||
display: flex;
|
||||
font-family: 'Lato', sans-serif;
|
||||
/*font-family: 'Lato', sans-serif;*/
|
||||
/* font-weight: normal; */
|
||||
}
|
||||
|
||||
.price-calc-section .text {
|
||||
|
|
@ -963,7 +1063,8 @@ tech-sub-sec h2 {
|
|||
}
|
||||
|
||||
.price-calc-section .card .title h3 {
|
||||
font-family: 'Lato', sans-serif;
|
||||
/*font-family: 'Lato', sans-serif;*/
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.price-calc-section .card .price {
|
||||
|
|
@ -1050,8 +1151,9 @@ tech-sub-sec h2 {
|
|||
|
||||
.price-calc-section .card .description.input label {
|
||||
font-size: 15px;
|
||||
font-weight: 800;
|
||||
font-family: 'Lato';
|
||||
font-weight: 700;
|
||||
/*font-weight: 800;*/
|
||||
/*font-family: 'Lato';*/
|
||||
margin-bottom: 0;
|
||||
width: 40px;
|
||||
}
|
||||
|
|
@ -1081,19 +1183,6 @@ tech-sub-sec h2 {
|
|||
padding: 0;
|
||||
}
|
||||
|
||||
.has-error .checkbox,
|
||||
.has-error .checkbox-inline,
|
||||
.has-error .control-label,
|
||||
.has-error .help-block,
|
||||
.has-error .radio,
|
||||
.has-error .radio-inline,
|
||||
.has-error.checkbox label,
|
||||
.has-error.checkbox-inline label,
|
||||
.has-error.radio label,
|
||||
.has-error.radio-inline label {
|
||||
color: #eb4d5c;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin: 0;
|
||||
border-bottom: 1px solid rgba(128, 128, 128, 0.3);
|
||||
|
|
@ -1309,9 +1398,9 @@ tech-sub-sec h2 {
|
|||
margin: 0 auto;
|
||||
}
|
||||
.contact-section .title h2 {
|
||||
font-size: 35px;
|
||||
font-size: 45px;
|
||||
line-height: 40px;
|
||||
text-align: center;
|
||||
/* text-align: center; */
|
||||
margin-top: 35px;
|
||||
}
|
||||
.contact-section .title h2::before {
|
||||
|
|
@ -1364,7 +1453,8 @@ tech-sub-sec h2 {
|
|||
padding: 30px;
|
||||
}
|
||||
.percent-text {
|
||||
font-family: 'Lato';
|
||||
/*font-family: 'Lato';*/
|
||||
font-weight: normal;
|
||||
font-size: 37px;
|
||||
/* text-align: center; */
|
||||
}
|
||||
|
|
@ -1402,7 +1492,7 @@ tech-sub-sec h2 {
|
|||
.network-name {
|
||||
text-transform: uppercase;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
font-weight: 300;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
|
||||
|
|
@ -1519,4 +1609,40 @@ a#forgotpassword {
|
|||
|
||||
.w380 {
|
||||
max-width: 380px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* bootstrap danger color override from #a94442 */
|
||||
.text-danger,
|
||||
.has-error .help-block,
|
||||
.has-error .control-label,
|
||||
.has-error .radio,
|
||||
.has-error .checkbox,
|
||||
.has-error .radio-inline,
|
||||
.has-error .checkbox-inline,
|
||||
.has-error.radio label,
|
||||
.has-error.checkbox label,
|
||||
.has-error.radio-inline label,
|
||||
.has-error.checkbox-inline label,
|
||||
.has-error .form-control,
|
||||
.has-error .form-control-feedback,
|
||||
.alert-danger,
|
||||
.list-group-item-danger,
|
||||
a.list-group-item-danger,
|
||||
a.list-group-item-danger:hover,
|
||||
a.list-group-item-danger:focus,
|
||||
.panel-danger > .panel-heading {
|
||||
color: #eb4d5c;
|
||||
}
|
||||
.has-error .input-group-addon {
|
||||
color: #eb4d5c;
|
||||
border-color: #eb4d5c;
|
||||
}
|
||||
a.list-group-item-danger.active,
|
||||
a.list-group-item-danger.active:hover,
|
||||
a.list-group-item-danger.active:focus {
|
||||
background-color: #eb4d5c;
|
||||
border-color: #eb4d5c;
|
||||
}
|
||||
.panel-danger > .panel-heading .badge {
|
||||
background-color: #eb4d5c;
|
||||
}
|
||||
|
|
|
|||
11
datacenterlight/static/datacenterlight/img/facebook_logo.svg
Normal file
11
datacenterlight/static/datacenterlight/img/facebook_logo.svg
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="57px" height="66px" viewBox="0 0 57 66" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!-- Generator: Sketch 46.2 (44496) - http://www.bohemiancoding.com/sketch -->
|
||||
<title>Slice 20</title>
|
||||
<desc>Created with Sketch.</desc>
|
||||
<defs></defs>
|
||||
<g id="contact-us" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<ellipse id="Oval-2" fill="#FFFFFF" cx="28.7865939" cy="33.4691264" rx="19.7865939" ry="19.4691264"></ellipse>
|
||||
<path d="M35.3784886,34.6387051 L30.2336176,34.6387051 L30.2336176,50.2467762 L22.6226844,50.2467762 L22.6226844,34.6387051 L19,34.6387051 L19,29.1194625 L22.6226844,29.1194625 L22.6226844,25.5403791 C22.6226844,22.9849851 24.0459888,19 30.3115248,19 L35.9567996,19.0178699 L35.9567996,24.3762836 L31.8546864,24.3762836 C31.1894789,24.3762836 30.2426069,24.6596489 30.2426069,25.8824599 L30.2426069,29.1194625 L36.0436961,29.1194625 L35.3784886,34.6387051 Z" id="Shape" fill="#5E79AD" fill-rule="nonzero"></path>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
|
|
@ -39,7 +39,7 @@
|
|||
_initScroll();
|
||||
_initNavUrl();
|
||||
_initPricing();
|
||||
|
||||
ajaxForms();
|
||||
});
|
||||
|
||||
$(window).resize(function() {
|
||||
|
|
@ -157,4 +157,27 @@
|
|||
$('#valueTotal').text(numbers * price * 31);
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
function ajaxForms() {
|
||||
$('body').on('submit', '.ajax-form', function(e){
|
||||
e.preventDefault();
|
||||
var $form = $(this);
|
||||
$form.find('[type=submit]').addClass('sending');
|
||||
$.ajax({
|
||||
url: $form.attr('action'),
|
||||
type: $form.attr('method'),
|
||||
data: $form.serialize(),
|
||||
|
||||
success: function(response) {
|
||||
var responseContain = $($form.attr('data-response'));
|
||||
responseContain.html(response);
|
||||
$form.find('[type=submit]').removeClass('sending');
|
||||
},
|
||||
|
||||
error: function() {
|
||||
$form.find('[type=submit]').removeClass('sending');
|
||||
$form.find('.form-error').removeClass('hide');
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
})(jQuery);
|
||||
174
datacenterlight/tasks.py
Normal file
174
datacenterlight/tasks.py
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
from dynamicweb.celery import app
|
||||
from celery.utils.log import get_task_logger
|
||||
from django.conf import settings
|
||||
from opennebula_api.models import OpenNebulaManager
|
||||
from opennebula_api.serializers import VirtualMachineSerializer
|
||||
from hosting.models import HostingOrder, HostingBill
|
||||
from utils.forms import UserBillingAddressForm
|
||||
from datetime import datetime
|
||||
from membership.models import StripeCustomer
|
||||
from django.core.mail import EmailMessage
|
||||
from utils.models import BillingAddress
|
||||
from celery.exceptions import MaxRetriesExceededError
|
||||
|
||||
logger = get_task_logger(__name__)
|
||||
|
||||
|
||||
def retry_task(task, exception=None):
|
||||
"""Retries the specified task using a "backing off countdown",
|
||||
meaning that the interval between retries grows exponentially
|
||||
with every retry.
|
||||
|
||||
Arguments:
|
||||
task:
|
||||
The task to retry.
|
||||
|
||||
exception:
|
||||
Optionally, the exception that caused the retry.
|
||||
"""
|
||||
|
||||
def backoff(attempts):
|
||||
return 2 ** attempts
|
||||
|
||||
kwargs = {
|
||||
'countdown': backoff(task.request.retries),
|
||||
}
|
||||
|
||||
if exception:
|
||||
kwargs['exc'] = exception
|
||||
|
||||
raise task.retry(**kwargs)
|
||||
|
||||
|
||||
@app.task(bind=True, max_retries=settings.CELERY_MAX_RETRIES)
|
||||
def create_vm_task(self, vm_template_id, user, specs, template,
|
||||
stripe_customer_id, billing_address_data,
|
||||
billing_address_id,
|
||||
charge, cc_details):
|
||||
vm_id = None
|
||||
try:
|
||||
final_price = specs.get('price')
|
||||
billing_address = BillingAddress.objects.filter(
|
||||
id=billing_address_id).first()
|
||||
customer = StripeCustomer.objects.filter(id=stripe_customer_id).first()
|
||||
# Create OpenNebulaManager
|
||||
manager = OpenNebulaManager(email=settings.OPENNEBULA_USERNAME,
|
||||
password=settings.OPENNEBULA_PASSWORD)
|
||||
|
||||
# Create a vm using oneadmin, also specify the name
|
||||
vm_id = manager.create_vm(
|
||||
template_id=vm_template_id,
|
||||
specs=specs,
|
||||
ssh_key=settings.ONEADMIN_USER_SSH_PUBLIC_KEY,
|
||||
vm_name="{email}-{template_name}-{date}".format(
|
||||
email=user.get('email'),
|
||||
template_name=template.get('name'),
|
||||
date=int(datetime.now().strftime("%s")))
|
||||
)
|
||||
|
||||
if vm_id is None:
|
||||
raise Exception("Could not create VM")
|
||||
|
||||
# Create a Hosting Order
|
||||
order = HostingOrder.create(
|
||||
price=final_price,
|
||||
vm_id=vm_id,
|
||||
customer=customer,
|
||||
billing_address=billing_address
|
||||
)
|
||||
|
||||
# Create a Hosting Bill
|
||||
HostingBill.create(
|
||||
customer=customer, billing_address=billing_address)
|
||||
|
||||
# Create Billing Address for User if he does not have one
|
||||
if not customer.user.billing_addresses.count():
|
||||
billing_address_data.update({
|
||||
'user': customer.user.id
|
||||
})
|
||||
billing_address_user_form = UserBillingAddressForm(
|
||||
billing_address_data)
|
||||
billing_address_user_form.is_valid()
|
||||
billing_address_user_form.save()
|
||||
|
||||
# Associate an order with a stripe subscription
|
||||
charge_object = DictDotLookup(charge)
|
||||
order.set_subscription_id(charge_object, cc_details)
|
||||
|
||||
# If the Stripe payment succeeds, set order status approved
|
||||
order.set_approved()
|
||||
|
||||
vm = VirtualMachineSerializer(manager.get_vm(vm_id)).data
|
||||
|
||||
context = {
|
||||
'name': user.get('name'),
|
||||
'email': user.get('email'),
|
||||
'cores': specs.get('cpu'),
|
||||
'memory': specs.get('memory'),
|
||||
'storage': specs.get('disk_size'),
|
||||
'price': specs.get('price'),
|
||||
'template': template.get('name'),
|
||||
'vm.name': vm['name'],
|
||||
'vm.id': vm['vm_id'],
|
||||
'order.id': order.id
|
||||
}
|
||||
email_data = {
|
||||
'subject': settings.DCL_TEXT + " Order from %s" % context['email'],
|
||||
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
||||
'to': ['info@ungleich.ch'],
|
||||
'body': "\n".join(
|
||||
["%s=%s" % (k, v) for (k, v) in context.items()]),
|
||||
'reply_to': [context['email']],
|
||||
}
|
||||
email = EmailMessage(**email_data)
|
||||
email.send()
|
||||
except Exception as e:
|
||||
logger.error(str(e))
|
||||
try:
|
||||
retry_task(self)
|
||||
except MaxRetriesExceededError:
|
||||
msg_text = 'Finished {} retries for create_vm_task'.format(
|
||||
self.request.retries)
|
||||
logger.error(msg_text)
|
||||
# Try sending email and stop
|
||||
email_data = {
|
||||
'subject': '{} CELERY TASK ERROR: {}'.format(settings.DCL_TEXT,
|
||||
msg_text),
|
||||
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
||||
'to': ['info@ungleich.ch'],
|
||||
'body': ',\n'.join(str(i) for i in self.request.args)
|
||||
}
|
||||
email = EmailMessage(**email_data)
|
||||
email.send()
|
||||
return
|
||||
|
||||
return vm_id
|
||||
|
||||
|
||||
class DictDotLookup(object):
|
||||
"""
|
||||
Creates objects that behave much like a dictionaries, but allow nested
|
||||
key access using object '.' (dot) lookups.
|
||||
"""
|
||||
|
||||
def __init__(self, d):
|
||||
for k in d:
|
||||
if isinstance(d[k], dict):
|
||||
self.__dict__[k] = DictDotLookup(d[k])
|
||||
elif isinstance(d[k], (list, tuple)):
|
||||
l = []
|
||||
for v in d[k]:
|
||||
if isinstance(v, dict):
|
||||
l.append(DictDotLookup(v))
|
||||
else:
|
||||
l.append(v)
|
||||
self.__dict__[k] = l
|
||||
else:
|
||||
self.__dict__[k] = d[k]
|
||||
|
||||
def __getitem__(self, name):
|
||||
if name in self.__dict__:
|
||||
return self.__dict__[name]
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.__dict__.keys())
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
{% load staticfiles i18n%}
|
||||
{% load staticfiles i18n cms_tags sekizai_tags %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{LANGUAGE_CODE}}">
|
||||
|
|
@ -33,13 +33,15 @@
|
|||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
{% render_block "css" postprocessor "compressor.contrib.sekizai.compress" %}
|
||||
{% render_block "js" postprocessor "compressor.contrib.sekizai.compress" %}
|
||||
<!-- Google analytics -->
|
||||
{% include "google_analytics.html" %}
|
||||
<!-- End Google Analytics -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
{% cms_toolbar %}
|
||||
<!-- Navigation -->
|
||||
{% include "datacenterlight/includes/_navbar.html" %}
|
||||
|
||||
|
|
|
|||
33
datacenterlight/templates/datacenterlight/cms_page.html
Normal file
33
datacenterlight/templates/datacenterlight/cms_page.html
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{% extends "datacenterlight/base.html" %}
|
||||
{% load staticfiles cms_tags sekizai_tags %}
|
||||
{% block content %}
|
||||
{% addtoblock "css" %}
|
||||
<link href="{% static 'datacenterlight/css/cms.css' %}" media="screen" rel="stylesheet" type="text/css"/>
|
||||
{% endaddtoblock %}
|
||||
|
||||
<div class="dcl-cms_page-full-width">
|
||||
<div class="dcl-cms_page-header">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-12">
|
||||
<div class="single-heading">
|
||||
<h2>{% placeholder 'datacenterlight_cms_page_title' %}</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="split-section left" id="dcl-cms_page-text">
|
||||
<div class="space">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{% placeholder 'datacenterlight_cms_page_text' %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
50
datacenterlight/templates/datacenterlight/contact_form.html
Normal file
50
datacenterlight/templates/datacenterlight/contact_form.html
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% if success %}
|
||||
<div class="contact-form-success">
|
||||
<div class="subtitle text-center">
|
||||
<h3>{% trans "Thank you for contacting us." %}</h3>
|
||||
</div>
|
||||
<p>
|
||||
{% trans "Your message was successfully sent to our team." %}
|
||||
</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="row">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<div class="subtitle">
|
||||
<h3>{% trans "Get in touch with us!" %}</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form class="form-horizontal ajax-form" method="POST" action="{% url 'datacenterlight:contact_us' %}" data-toggle="validator" data-response="#contact-form">
|
||||
{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" for="name">{% trans "Name" %}</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" name="name" class="form-control" data-minlength="3" data-error="{% trans 'Please enter your name.' %}" required>
|
||||
{{contact_form.name.errors}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" for="email">{% trans "Email" %}</label>
|
||||
<div class="col-sm-10">
|
||||
<input name="email" type="email" pattern="^[^@\s]+@([^@\s]+\.)+[^@\s]+$" class="form-control" data-error="{% trans 'Please enter a valid email address.' %}" required>
|
||||
{{contact_form.email.errors}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" for="message">{% trans "Message" %}</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea class="form-control" name="message" id="message" rows="6" required></textarea>
|
||||
{{contact_form.message.errors}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10 text-right">
|
||||
<div class="form-error hide">{% trans "Sorry, there was an unexpected error. Kindly retry." %}</div>
|
||||
<button type="submit" class="btn btn-default">{% trans "SUBMIT" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
|
@ -58,4 +58,4 @@
|
|||
</ul>
|
||||
<!-- /.navbar-collapse -->
|
||||
</div>
|
||||
</nav>
|
||||
</nav>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{% extends "datacenterlight/base.html" %}
|
||||
{% load staticfiles i18n%}
|
||||
{% load staticfiles i18n %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
|
@ -149,32 +149,34 @@
|
|||
|
||||
</div>
|
||||
|
||||
<!-- / contact section -->
|
||||
<!-- / contact section -->
|
||||
<div class="full-contact-section">
|
||||
<div class="intro-header-2 contact-section" id="contact">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-6 col-md-6">
|
||||
<div class="card">
|
||||
<div class="col-sm-6">
|
||||
<div class="title">
|
||||
<h2>{% trans "Contact us" %}</h2>
|
||||
</div>
|
||||
<div class="contact-details">
|
||||
<div class="subtitle">
|
||||
<h3>ungleich GmbH </h3>
|
||||
<h3>ungleich GmbH</h3>
|
||||
</div>
|
||||
<div class="description">
|
||||
<p><i class="fa fa-envelope-o"></i> info@datacenterlight.ch</p>
|
||||
<p>info@datacenterlight.ch</p>
|
||||
<p>In der Au 7, Schwanden 8762</p>
|
||||
<p>{% trans "Switzerland " %}</p>
|
||||
</div>
|
||||
<div class="social">
|
||||
<a target="_blank" class="" href="https://twitter.com/datacenterlight"><i class="fa fa-twitter fa-fw"></i></a>
|
||||
<a target="_blank" class="" href="https://github.com/ungleich"><i class="fa fa-github fa-fw"></i></a>
|
||||
<a target="_blank" class="" href="https://www.facebook.com/ungleich.ch/"><i class="fa fa-facebook fa-fw"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="social">
|
||||
<a target="_blank" class="" href="https://twitter.com/datacenterlight"><i class="fa fa-twitter fa-fw"></i></a>
|
||||
<a target="_blank" class="" href="https://github.com/ungleich"><i class="fa fa-github fa-fw"></i></a>
|
||||
<a target="_blank" class="" href="https://www.facebook.com/ungleich.ch/"><i class="fa fa-facebook"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-6">
|
||||
<div class="title">
|
||||
<h2>{% trans "Questions?" %} {% trans "Contact us!" %}</h2>
|
||||
<div class="col-sm-6">
|
||||
<div id="contact-form" class="contact-form">
|
||||
{% include "datacenterlight/contact_form.html" %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -72,15 +72,20 @@
|
|||
<hr>
|
||||
<p><b>{% trans "Configuration"%}</b> <span class="pull-right">{{request.session.template.name}}</span></p>
|
||||
<hr>
|
||||
<h4>{% trans "Total"%}<p class="pull-right"><b>{{vm.price}} CHF</b></p></h4>
|
||||
<h4>{% trans "Total"%}<p class="pull-right"><b>{{vm.price}} CHF</b><span class="dcl-price-month"> /{% trans "Month" %}</span></p></h4>
|
||||
{% endwith %}
|
||||
</div>
|
||||
<br/>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<div class=" content pull-right">
|
||||
<a href="{{next_url}}" ><button class="btn btn-info">{% trans "Place order"%}</button></a>
|
||||
</div>
|
||||
{% csrf_token %}
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<p class="dcl-place-order-text">{% blocktrans with vm_price=request.session.specs.price %}By clicking "Place order" this plan will charge your credit card account with the fee of {{ vm_price }}CHF/month{% endblocktrans %}.</p>
|
||||
</div>
|
||||
<div class="col-sm-4 content">
|
||||
<a href="{{next_url}}" ><button class="btn btn-info pull-right">{% trans "Place order"%}</button></a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,143 @@
|
|||
# from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
from time import sleep
|
||||
|
||||
import stripe
|
||||
from celery.result import AsyncResult
|
||||
from django.conf import settings
|
||||
from django.core.management import call_command
|
||||
from django.test import TestCase, override_settings
|
||||
from model_mommy import mommy
|
||||
from datacenterlight.models import VMTemplate
|
||||
from datacenterlight.tasks import create_vm_task
|
||||
from membership.models import StripeCustomer
|
||||
from opennebula_api.serializers import VMTemplateSerializer
|
||||
from utils.models import BillingAddress
|
||||
from utils.stripe_utils import StripeUtils
|
||||
|
||||
|
||||
class CeleryTaskTestCase(TestCase):
|
||||
@override_settings(
|
||||
task_eager_propagates=True,
|
||||
task_always_eager=True,
|
||||
)
|
||||
def setUp(self):
|
||||
self.customer_password = 'test_password'
|
||||
self.customer_email = 'celery-createvm-task-test@ungleich.ch'
|
||||
self.customer_name = "Monty Python"
|
||||
self.user = {
|
||||
'email': self.customer_email,
|
||||
'name': self.customer_name
|
||||
}
|
||||
self.customer = mommy.make('membership.CustomUser')
|
||||
self.customer.set_password(self.customer_password)
|
||||
self.customer.email = self.customer_email
|
||||
self.customer.save()
|
||||
self.stripe_utils = StripeUtils()
|
||||
stripe.api_key = settings.STRIPE_API_PRIVATE_KEY_TEST
|
||||
self.token = stripe.Token.create(
|
||||
card={
|
||||
"number": '4111111111111111',
|
||||
"exp_month": 12,
|
||||
"exp_year": 2022,
|
||||
"cvc": '123'
|
||||
},
|
||||
)
|
||||
# Run fetchvmtemplates so that we have the VM templates from
|
||||
# OpenNebula
|
||||
call_command('fetchvmtemplates')
|
||||
|
||||
def test_create_vm_task(self):
|
||||
"""Tests the create vm task for monthly subscription
|
||||
|
||||
This test is supposed to validate the proper execution
|
||||
of celery create_vm_task on production, as we have no
|
||||
other way to do this.
|
||||
"""
|
||||
|
||||
# We create a VM from the first template available to DCL
|
||||
vm_template = VMTemplate.objects.all().first()
|
||||
template_data = VMTemplateSerializer(vm_template).data
|
||||
|
||||
# The specs of VM that we want to create
|
||||
specs = {
|
||||
'cpu': 1,
|
||||
'memory': 2,
|
||||
'disk_size': 10,
|
||||
'price': 15
|
||||
}
|
||||
|
||||
stripe_customer = StripeCustomer.get_or_create(
|
||||
email=self.customer_email,
|
||||
token=self.token)
|
||||
card_details = self.stripe_utils.get_card_details(
|
||||
stripe_customer.stripe_id,
|
||||
self.token)
|
||||
card_details_dict = card_details.get('response_object')
|
||||
billing_address = BillingAddress(
|
||||
cardholder_name=self.customer_name,
|
||||
postal_code='1232',
|
||||
country='CH',
|
||||
street_address='Monty\'s Street',
|
||||
city='Hollywood')
|
||||
billing_address.save()
|
||||
billing_address_data = {'cardholder_name': self.customer_name,
|
||||
'postal_code': '1231',
|
||||
'country': 'CH',
|
||||
'token': self.token,
|
||||
'street_address': 'Monty\'s Street',
|
||||
'city': 'Hollywood'}
|
||||
|
||||
billing_address_id = billing_address.id
|
||||
vm_template_id = template_data.get('id', 1)
|
||||
|
||||
cpu = specs.get('cpu')
|
||||
memory = specs.get('memory')
|
||||
disk_size = specs.get('disk_size')
|
||||
amount_to_be_charged = (cpu * 5) + (memory * 2) + (disk_size * 0.6)
|
||||
plan_name = "{cpu} Cores, {memory} GB RAM, {disk_size} GB SSD".format(
|
||||
cpu=cpu,
|
||||
memory=memory,
|
||||
disk_size=disk_size)
|
||||
|
||||
stripe_plan_id = StripeUtils.get_stripe_plan_id(cpu=cpu,
|
||||
ram=memory,
|
||||
ssd=disk_size,
|
||||
version=1,
|
||||
app='dcl')
|
||||
stripe_plan = self.stripe_utils.get_or_create_stripe_plan(
|
||||
amount=amount_to_be_charged,
|
||||
name=plan_name,
|
||||
stripe_plan_id=stripe_plan_id)
|
||||
subscription_result = self.stripe_utils.subscribe_customer_to_plan(
|
||||
stripe_customer.stripe_id,
|
||||
[{"plan": stripe_plan.get(
|
||||
'response_object').stripe_plan_id}])
|
||||
stripe_subscription_obj = subscription_result.get('response_object')
|
||||
# Check if the subscription was approved and is active
|
||||
if stripe_subscription_obj is None or \
|
||||
stripe_subscription_obj.status != 'active':
|
||||
msg = subscription_result.get('error')
|
||||
raise Exception("Creating subscription failed: {}".format(msg))
|
||||
|
||||
async_task = create_vm_task.delay(vm_template_id, self.user,
|
||||
specs,
|
||||
template_data,
|
||||
stripe_customer.id,
|
||||
billing_address_data,
|
||||
billing_address_id,
|
||||
stripe_subscription_obj,
|
||||
card_details_dict)
|
||||
new_vm_id = 0
|
||||
res = None
|
||||
for i in range(0, 10):
|
||||
sleep(5)
|
||||
res = AsyncResult(async_task.task_id)
|
||||
if res.result is not None and res.result > 0:
|
||||
new_vm_id = res.result
|
||||
break
|
||||
|
||||
# We expect a VM to be created within 50 seconds
|
||||
self.assertGreater(new_vm_id, 0,
|
||||
"VM could not be created. res._get_task_meta() = {}"
|
||||
.format(res._get_task_meta()))
|
||||
|
|
|
|||
|
|
@ -1,17 +1,24 @@
|
|||
from django.conf.urls import url
|
||||
|
||||
from .views import IndexView, BetaProgramView, LandingProgramView, BetaAccessView, PricingView, SuccessView, \
|
||||
PaymentOrderView, OrderConfirmationView, WhyDataCenterLightView
|
||||
|
||||
from .views import IndexView, BetaProgramView, LandingProgramView, \
|
||||
BetaAccessView, PricingView, SuccessView, \
|
||||
PaymentOrderView, OrderConfirmationView, \
|
||||
WhyDataCenterLightView, ContactUsView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
url(r'^whydatacenterlight/?$', WhyDataCenterLightView.as_view(), name='whydatacenterlight'),
|
||||
url(r'^t$', IndexView.as_view(), name='index_t'),
|
||||
url(r'^g$', IndexView.as_view(), name='index_g'),
|
||||
url(r'^f$', IndexView.as_view(), name='index_f'),
|
||||
url(r'^whydatacenterlight/?$', WhyDataCenterLightView.as_view(),
|
||||
name='whydatacenterlight'),
|
||||
url(r'^beta-program/?$', BetaProgramView.as_view(), name='beta'),
|
||||
url(r'^landing/?$', LandingProgramView.as_view(), name='landing'),
|
||||
url(r'^pricing/?$', PricingView.as_view(), name='pricing'),
|
||||
url(r'^payment/?$', PaymentOrderView.as_view(), name='payment'),
|
||||
url(r'^order-confirmation/?$', OrderConfirmationView.as_view(), name='order_confirmation'),
|
||||
url(r'^order-confirmation/?$', OrderConfirmationView.as_view(),
|
||||
name='order_confirmation'),
|
||||
url(r'^order-success/?$', SuccessView.as_view(), name='order_success'),
|
||||
url(r'^beta_access?$', BetaAccessView.as_view(), name='beta_access'),
|
||||
url(r'^contact/?$', ContactUsView.as_view(), name='contact_us'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,26 +1,67 @@
|
|||
from django.views.generic import FormView, CreateView, TemplateView, DetailView
|
||||
from django.http import HttpResponseRedirect
|
||||
from .forms import BetaAccessForm
|
||||
from .models import BetaAccess, BetaAccessVMType, BetaAccessVM, VMTemplate
|
||||
from django.contrib import messages
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.mail import EmailMessage
|
||||
from utils.mailer import BaseEmail
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import redirect
|
||||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.views.decorators.cache import cache_control
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import redirect
|
||||
from django.shortcuts import render
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from utils.forms import BillingAddressForm, UserBillingAddressForm
|
||||
from utils.models import BillingAddress
|
||||
from hosting.models import HostingOrder, HostingBill
|
||||
from utils.stripe_utils import StripeUtils
|
||||
from datetime import datetime
|
||||
from django.views.decorators.cache import cache_control
|
||||
from django.views.generic import FormView, CreateView, TemplateView, DetailView
|
||||
|
||||
from datacenterlight.tasks import create_vm_task
|
||||
from hosting.models import HostingOrder
|
||||
from membership.models import CustomUser, StripeCustomer
|
||||
from opennebula_api.models import OpenNebulaManager
|
||||
from opennebula_api.serializers import VirtualMachineTemplateSerializer, VirtualMachineSerializer, VMTemplateSerializer
|
||||
from opennebula_api.serializers import VirtualMachineTemplateSerializer, \
|
||||
VMTemplateSerializer
|
||||
from utils.forms import BillingAddressForm
|
||||
from utils.mailer import BaseEmail
|
||||
from utils.stripe_utils import StripeUtils
|
||||
from utils.tasks import send_plain_email_task
|
||||
from .forms import BetaAccessForm, ContactForm
|
||||
from .models import BetaAccess, BetaAccessVMType, BetaAccessVM, VMTemplate
|
||||
|
||||
|
||||
class ContactUsView(FormView):
|
||||
template_name = "datacenterlight/contact_form.html"
|
||||
form_class = ContactForm
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return HttpResponseRedirect(reverse('datacenterlight:index'))
|
||||
|
||||
def form_invalid(self, form):
|
||||
if self.request.is_ajax():
|
||||
return self.render_to_response(
|
||||
self.get_context_data(contact_form=form))
|
||||
else:
|
||||
return render(self.request,
|
||||
'datacenterlight/index.html',
|
||||
self.get_context_data(contact_form=form))
|
||||
|
||||
def form_valid(self, form):
|
||||
form.save()
|
||||
email_data = {
|
||||
'subject': "{dcl_text} Message from {sender}".format(
|
||||
dcl_text=settings.DCL_TEXT,
|
||||
sender=form.cleaned_data.get('email')
|
||||
),
|
||||
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
||||
'to': ['info@ungleich.ch'],
|
||||
'body': "\n".join(
|
||||
["%s=%s" % (k, v) for (k, v) in form.cleaned_data.items()]),
|
||||
'reply_to': [form.cleaned_data.get('email')],
|
||||
}
|
||||
send_plain_email_task.delay(email_data)
|
||||
if self.request.is_ajax():
|
||||
return self.render_to_response(
|
||||
self.get_context_data(success=True, contact_form=form))
|
||||
else:
|
||||
return render(self.request,
|
||||
'datacenterlight/index.html',
|
||||
self.get_context_data(success=True,
|
||||
contact_form=form))
|
||||
|
||||
|
||||
class LandingProgramView(TemplateView):
|
||||
|
|
@ -33,13 +74,14 @@ class SuccessView(TemplateView):
|
|||
def get(self, request, *args, **kwargs):
|
||||
if 'specs' not in request.session or 'user' not in request.session:
|
||||
return HttpResponseRedirect(reverse('datacenterlight:index'))
|
||||
|
||||
elif 'token' not in request.session:
|
||||
return HttpResponseRedirect(reverse('datacenterlight:payment'))
|
||||
elif 'order_confirmation' not in request.session:
|
||||
return HttpResponseRedirect(reverse('datacenterlight:order_confirmation'))
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:order_confirmation'))
|
||||
else:
|
||||
for session_var in ['specs', 'user', 'template', 'billing_address', 'billing_address_data',
|
||||
for session_var in ['specs', 'user', 'template', 'billing_address',
|
||||
'billing_address_data',
|
||||
'token', 'customer']:
|
||||
if session_var in request.session:
|
||||
del request.session[session_var]
|
||||
|
|
@ -55,7 +97,8 @@ class PricingView(TemplateView):
|
|||
templates = manager.get_templates()
|
||||
|
||||
context = {
|
||||
'templates': VirtualMachineTemplateSerializer(templates, many=True).data,
|
||||
'templates': VirtualMachineTemplateSerializer(templates,
|
||||
many=True).data,
|
||||
}
|
||||
except:
|
||||
messages.error(request,
|
||||
|
|
@ -102,7 +145,8 @@ class BetaAccessView(FormView):
|
|||
|
||||
def form_valid(self, form):
|
||||
context = {
|
||||
'base_url': "{0}://{1}".format(self.request.scheme, self.request.get_host())
|
||||
'base_url': "{0}://{1}".format(self.request.scheme,
|
||||
self.request.get_host())
|
||||
}
|
||||
|
||||
email_data = {
|
||||
|
|
@ -132,8 +176,8 @@ class BetaAccessView(FormView):
|
|||
email = BaseEmail(**email_data)
|
||||
email.send()
|
||||
|
||||
messages.add_message(
|
||||
self.request, messages.SUCCESS, self.success_message)
|
||||
messages.add_message(self.request, messages.SUCCESS,
|
||||
self.success_message)
|
||||
return render(self.request, 'datacenterlight/beta_success.html', {})
|
||||
|
||||
|
||||
|
|
@ -158,7 +202,8 @@ class BetaProgramView(CreateView):
|
|||
# data = VirtualMachineTemplateSerializer(templates, many=True).data
|
||||
|
||||
context.update({
|
||||
'base_url': "{0}://{1}".format(self.request.scheme, self.request.get_host()),
|
||||
'base_url': "{0}://{1}".format(self.request.scheme,
|
||||
self.request.get_host()),
|
||||
'vms': vms
|
||||
})
|
||||
return context
|
||||
|
|
@ -168,7 +213,8 @@ class BetaProgramView(CreateView):
|
|||
vms = BetaAccessVM.create(data)
|
||||
|
||||
context = {
|
||||
'base_url': "{0}://{1}".format(self.request.scheme, self.request.get_host()),
|
||||
'base_url': "{0}://{1}".format(self.request.scheme,
|
||||
self.request.get_host()),
|
||||
'email': data.get('email'),
|
||||
'name': data.get('name'),
|
||||
'vms': vms
|
||||
|
|
@ -185,8 +231,8 @@ class BetaProgramView(CreateView):
|
|||
email = BaseEmail(**email_data)
|
||||
email.send()
|
||||
|
||||
messages.add_message(
|
||||
self.request, messages.SUCCESS, self.success_message)
|
||||
messages.add_message(self.request, messages.SUCCESS,
|
||||
self.success_message)
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
|
||||
|
|
@ -243,41 +289,46 @@ class IndexView(CreateView):
|
|||
cores = cores_field.clean(cores)
|
||||
except ValidationError as err:
|
||||
msg = '{} : {}.'.format(cores, str(err))
|
||||
messages.add_message(
|
||||
self.request, messages.ERROR, msg, extra_tags='cores')
|
||||
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
||||
messages.add_message(self.request, messages.ERROR, msg,
|
||||
extra_tags='cores')
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:index') + "#order_form")
|
||||
|
||||
try:
|
||||
memory = memory_field.clean(memory)
|
||||
except ValidationError as err:
|
||||
msg = '{} : {}.'.format(memory, str(err))
|
||||
messages.add_message(
|
||||
self.request, messages.ERROR, msg, extra_tags='memory')
|
||||
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
||||
messages.add_message(self.request, messages.ERROR, msg,
|
||||
extra_tags='memory')
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:index') + "#order_form")
|
||||
|
||||
try:
|
||||
storage = storage_field.clean(storage)
|
||||
except ValidationError as err:
|
||||
msg = '{} : {}.'.format(storage, str(err))
|
||||
messages.add_message(
|
||||
self.request, messages.ERROR, msg, extra_tags='storage')
|
||||
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
||||
messages.add_message(self.request, messages.ERROR, msg,
|
||||
extra_tags='storage')
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:index') + "#order_form")
|
||||
|
||||
try:
|
||||
name = name_field.clean(name)
|
||||
except ValidationError as err:
|
||||
msg = '{} {}.'.format(name, _('is not a proper name'))
|
||||
messages.add_message(
|
||||
self.request, messages.ERROR, msg, extra_tags='name')
|
||||
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
||||
messages.add_message(self.request, messages.ERROR, msg,
|
||||
extra_tags='name')
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:index') + "#order_form")
|
||||
|
||||
try:
|
||||
email = email_field.clean(email)
|
||||
except ValidationError as err:
|
||||
msg = '{} {}.'.format(email, _('is not a proper email'))
|
||||
messages.add_message(
|
||||
self.request, messages.ERROR, msg, extra_tags='email')
|
||||
return HttpResponseRedirect(reverse('datacenterlight:index') + "#order_form")
|
||||
messages.add_message(self.request, messages.ERROR, msg,
|
||||
extra_tags='email')
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:index') + "#order_form")
|
||||
|
||||
specs = {
|
||||
'cpu': cores,
|
||||
|
|
@ -304,14 +355,17 @@ class IndexView(CreateView):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super(IndexView, self).get_context_data(**kwargs)
|
||||
context.update({
|
||||
'base_url': "{0}://{1}".format(self.request.scheme, self.request.get_host())
|
||||
'base_url': "{0}://{1}".format(self.request.scheme,
|
||||
self.request.get_host()),
|
||||
'contact_form': ContactForm
|
||||
})
|
||||
return context
|
||||
|
||||
def form_valid(self, form):
|
||||
|
||||
context = {
|
||||
'base_url': "{0}://{1}".format(self.request.scheme, self.request.get_host())
|
||||
'base_url': "{0}://{1}".format(self.request.scheme,
|
||||
self.request.get_host())
|
||||
}
|
||||
|
||||
email_data = {
|
||||
|
|
@ -341,8 +395,8 @@ class IndexView(CreateView):
|
|||
email = BaseEmail(**email_data)
|
||||
email.send()
|
||||
|
||||
messages.add_message(
|
||||
self.request, messages.SUCCESS, self.success_message)
|
||||
messages.add_message(self.request, messages.SUCCESS,
|
||||
self.success_message)
|
||||
return super(IndexView, self).form_valid(form)
|
||||
|
||||
|
||||
|
|
@ -407,16 +461,17 @@ class PaymentOrderView(FormView):
|
|||
token=token)
|
||||
if not customer:
|
||||
form.add_error("__all__", "Invalid credit card")
|
||||
return self.render_to_response(self.get_context_data(form=form))
|
||||
return self.render_to_response(
|
||||
self.get_context_data(form=form))
|
||||
|
||||
# Create Billing Address
|
||||
billing_address = form.save()
|
||||
|
||||
request.session['billing_address_data'] = billing_address_data
|
||||
request.session['billing_address'] = billing_address.id
|
||||
request.session['token'] = token
|
||||
request.session['customer'] = customer.id
|
||||
return HttpResponseRedirect(reverse('datacenterlight:order_confirmation'))
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:order_confirmation'))
|
||||
else:
|
||||
return self.form_invalid(form)
|
||||
|
||||
|
|
@ -436,8 +491,15 @@ class OrderConfirmationView(DetailView):
|
|||
stripe_customer_id = request.session.get('customer')
|
||||
customer = StripeCustomer.objects.filter(id=stripe_customer_id).first()
|
||||
stripe_utils = StripeUtils()
|
||||
card_details = stripe_utils.get_card_details(
|
||||
customer.stripe_id, request.session.get('token'))
|
||||
card_details = stripe_utils.get_card_details(customer.stripe_id,
|
||||
request.session.get(
|
||||
'token'))
|
||||
if not card_details.get('response_object'):
|
||||
msg = card_details.get('error')
|
||||
messages.add_message(self.request, messages.ERROR, msg,
|
||||
extra_tags='failed_payment')
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:payment') + '#payment_error')
|
||||
context = {
|
||||
'site_url': reverse('datacenterlight:index'),
|
||||
'cc_last4': card_details.get('response_object').get('last4'),
|
||||
|
|
@ -453,91 +515,54 @@ class OrderConfirmationView(DetailView):
|
|||
customer = StripeCustomer.objects.filter(id=stripe_customer_id).first()
|
||||
billing_address_data = request.session.get('billing_address_data')
|
||||
billing_address_id = request.session.get('billing_address')
|
||||
billing_address = BillingAddress.objects.filter(
|
||||
id=billing_address_id).first()
|
||||
vm_template_id = template.get('id', 1)
|
||||
final_price = specs.get('price')
|
||||
|
||||
# Make stripe charge to a customer
|
||||
stripe_utils = StripeUtils()
|
||||
charge_response = stripe_utils.make_charge(amount=final_price,
|
||||
customer=customer.stripe_id)
|
||||
charge = charge_response.get('response_object')
|
||||
card_details = stripe_utils.get_card_details(customer.stripe_id,
|
||||
request.session.get(
|
||||
'token'))
|
||||
if not card_details.get('response_object'):
|
||||
msg = card_details.get('error')
|
||||
messages.add_message(self.request, messages.ERROR, msg,
|
||||
extra_tags='failed_payment')
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:payment') + '#payment_error')
|
||||
card_details_dict = card_details.get('response_object')
|
||||
cpu = specs.get('cpu')
|
||||
memory = specs.get('memory')
|
||||
disk_size = specs.get('disk_size')
|
||||
amount_to_be_charged = (cpu * 5) + (memory * 2) + (disk_size * 0.6)
|
||||
plan_name = "{cpu} Cores, {memory} GB RAM, {disk_size} GB SSD".format(
|
||||
cpu=cpu,
|
||||
memory=memory,
|
||||
disk_size=disk_size)
|
||||
|
||||
# Check if the payment was approved
|
||||
if not charge:
|
||||
context = {}
|
||||
context.update({
|
||||
'paymentError': charge_response.get('error')
|
||||
})
|
||||
return render(request, self.payment_template_name, context)
|
||||
|
||||
charge = charge_response.get('response_object')
|
||||
|
||||
# Create OpenNebulaManager
|
||||
manager = OpenNebulaManager(email=settings.OPENNEBULA_USERNAME,
|
||||
password=settings.OPENNEBULA_PASSWORD)
|
||||
|
||||
# Create a vm using oneadmin, also specify the name
|
||||
vm_id = manager.create_vm(
|
||||
template_id=vm_template_id,
|
||||
specs=specs,
|
||||
vm_name="{email}-{template_name}-{date}".format(
|
||||
email=user.get('email'),
|
||||
template_name=template.get('name'),
|
||||
date=int(datetime.now().strftime("%s")))
|
||||
)
|
||||
|
||||
# Create a Hosting Order
|
||||
order = HostingOrder.create(
|
||||
price=final_price,
|
||||
vm_id=vm_id,
|
||||
customer=customer,
|
||||
billing_address=billing_address
|
||||
)
|
||||
|
||||
# Create a Hosting Bill
|
||||
HostingBill.create(
|
||||
customer=customer, billing_address=billing_address)
|
||||
|
||||
# Create Billing Address for User if he does not have one
|
||||
if not customer.user.billing_addresses.count():
|
||||
billing_address_data.update({
|
||||
'user': customer.user.id
|
||||
})
|
||||
billing_address_user_form = UserBillingAddressForm(
|
||||
billing_address_data)
|
||||
billing_address_user_form.is_valid()
|
||||
billing_address_user_form.save()
|
||||
|
||||
# Associate an order with a stripe payment
|
||||
order.set_stripe_charge(charge)
|
||||
|
||||
# If the Stripe payment was successed, set order status approved
|
||||
order.set_approved()
|
||||
|
||||
vm = VirtualMachineSerializer(manager.get_vm(vm_id)).data
|
||||
|
||||
context = {
|
||||
'name': user.get('name'),
|
||||
'email': user.get('email'),
|
||||
'cores': specs.get('cpu'),
|
||||
'memory': specs.get('memory'),
|
||||
'storage': specs.get('disk_size'),
|
||||
'price': specs.get('price'),
|
||||
'template': template.get('name'),
|
||||
'vm.name': vm['name'],
|
||||
'vm.id': vm['vm_id'],
|
||||
'order.id': order.id
|
||||
}
|
||||
email_data = {
|
||||
'subject': settings.DCL_TEXT + " Order from %s" % context['email'],
|
||||
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
|
||||
'to': ['info@ungleich.ch'],
|
||||
'body': "\n".join(["%s=%s" % (k, v) for (k, v) in context.items()]),
|
||||
'reply_to': [context['email']],
|
||||
}
|
||||
email = EmailMessage(**email_data)
|
||||
email.send()
|
||||
stripe_plan_id = StripeUtils.get_stripe_plan_id(cpu=cpu,
|
||||
ram=memory,
|
||||
ssd=disk_size,
|
||||
version=1,
|
||||
app='dcl')
|
||||
stripe_plan = stripe_utils.get_or_create_stripe_plan(
|
||||
amount=amount_to_be_charged,
|
||||
name=plan_name,
|
||||
stripe_plan_id=stripe_plan_id)
|
||||
subscription_result = stripe_utils.subscribe_customer_to_plan(
|
||||
customer.stripe_id,
|
||||
[{"plan": stripe_plan.get(
|
||||
'response_object').stripe_plan_id}])
|
||||
stripe_subscription_obj = subscription_result.get('response_object')
|
||||
# Check if the subscription was approved and is active
|
||||
if stripe_subscription_obj is None or \
|
||||
stripe_subscription_obj.status != 'active':
|
||||
msg = subscription_result.get('error')
|
||||
messages.add_message(self.request, messages.ERROR, msg,
|
||||
extra_tags='failed_payment')
|
||||
return HttpResponseRedirect(
|
||||
reverse('datacenterlight:payment') + '#payment_error')
|
||||
create_vm_task.delay(vm_template_id, user, specs, template,
|
||||
stripe_customer_id, billing_address_data,
|
||||
billing_address_id,
|
||||
stripe_subscription_obj, card_details_dict)
|
||||
request.session['order_confirmation'] = True
|
||||
return HttpResponseRedirect(reverse('datacenterlight:order_success'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue