Merge pull request #346 from pcoder/task/3387/cleanup_order_page_new
Task/3387/cleanup order page new
This commit is contained in:
commit
8f9971acf2
3 changed files with 3 additions and 174 deletions
|
@ -1,98 +0,0 @@
|
||||||
{% extends "datacenterlight/base.html" %}
|
|
||||||
{% load staticfiles i18n %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<div class="intro-pricing">
|
|
||||||
|
|
||||||
<div class="intro-message">
|
|
||||||
<h2 class="section-heading">{% trans "We are cutting down the costs significantly!" %}</h2>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="price-calc-section">
|
|
||||||
<div class="card">
|
|
||||||
<img class="img-beta" src="{% static 'datacenterlight/img/beta-img.png' %}" alt="">
|
|
||||||
<div class="caption">
|
|
||||||
<form id="order_form" method="POST" action="">
|
|
||||||
{% csrf_token %}
|
|
||||||
|
|
||||||
<div class="title">
|
|
||||||
<h3>{% trans "VM hosting" %} </h3>
|
|
||||||
</div>
|
|
||||||
<div class="price">
|
|
||||||
<span id="total">15</span>
|
|
||||||
<span>CHF</span>
|
|
||||||
<div class="price-text">
|
|
||||||
<p>{% trans "VAT included" %}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="descriptions">
|
|
||||||
<div class="description">
|
|
||||||
<p>{% trans "Hosted in Switzerland" %}</p>
|
|
||||||
</div>
|
|
||||||
<div class="description">
|
|
||||||
<i class="fa fa-minus-circle left" data-minus="cpu" aria-hidden="true"></i>
|
|
||||||
<input class="input-price" type="number" min="1" max="42" id="coreValue" name="cpu">
|
|
||||||
<span> Core</span>
|
|
||||||
<i class="fa fa-plus-circle right" data-plus="cpu" aria-hidden="true"></i>
|
|
||||||
</div>
|
|
||||||
<div class="description">
|
|
||||||
<i class="fa fa-minus-circle left" data-minus="ram" aria-hidden="true"></i>
|
|
||||||
<input id="ramValue" class="input-price" type="number" min="2" max="200" name="ram">
|
|
||||||
<span> GB RAM</span>
|
|
||||||
<i class="fa fa-plus-circle right" data-plus="ram" aria-hidden="true"></i>
|
|
||||||
</div>
|
|
||||||
<div class="description">
|
|
||||||
<i class="fa fa-minus-circle left" data-minus="storage" aria-hidden="true"></i>
|
|
||||||
<input id="storageValue" class="input-price" type="number" min="10" max="500" step="10" name="storage">
|
|
||||||
<span>{% trans "GB Storage (SSD)" %}</span>
|
|
||||||
<i class="fa fa-plus-circle right" data-plus="storage" aria-hidden="true"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="description select-configuration input">
|
|
||||||
<label for="config">OS</label>
|
|
||||||
<select name="config" id="">
|
|
||||||
{% for template in templates %}
|
|
||||||
<option value="{{template.id}}">{{template.name}} </option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<input type="hidden" name="total">
|
|
||||||
<!--<div class="description check-ip">
|
|
||||||
<input type="checkbox" name="ipv6"> Ipv6 Only<br>
|
|
||||||
</div>-->
|
|
||||||
|
|
||||||
<div class="description input">
|
|
||||||
<label for="name">Name</label>
|
|
||||||
<input type="text" name="name" placeholder="Your Name">
|
|
||||||
</div>
|
|
||||||
<div class="description input">
|
|
||||||
<label for="email">Email</label>
|
|
||||||
<input type="email" name="email" placeholder="Your Email">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<input type="submit" class="btn btn-primary" value="{% trans 'Order Now!' %}"></input>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div id="error_message_box" class="error-message-box"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="text">
|
|
||||||
<h2 class="section-heading">{% trans "Simple and affordable: Try our virtual machine with featherlight price." %}</h2>
|
|
||||||
|
|
||||||
<div class="description">
|
|
||||||
<p>{% trans "Our VMs are hosted in Glarus, Switzerland, and our website is currently running in BETA mode. If you want more information that you did not find on our website, or if your order is more detailed, or if you encounter any technical hiccups, please contact us at support@datacenterlight.ch, our team will get in touch with you asap." %}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
</html>
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
|
|
||||||
from .views import IndexView, BetaProgramView, LandingProgramView, BetaAccessView, PricingView, SuccessView, OrderView
|
from .views import IndexView, BetaProgramView, LandingProgramView, BetaAccessView, PricingView, SuccessView
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
@ -8,7 +8,6 @@ urlpatterns = [
|
||||||
url(r'^/beta-program/?$', BetaProgramView.as_view(), name='beta'),
|
url(r'^/beta-program/?$', BetaProgramView.as_view(), name='beta'),
|
||||||
url(r'^/landing/?$', LandingProgramView.as_view(), name='landing'),
|
url(r'^/landing/?$', LandingProgramView.as_view(), name='landing'),
|
||||||
url(r'^/pricing/?$', PricingView.as_view(), name='pricing'),
|
url(r'^/pricing/?$', PricingView.as_view(), name='pricing'),
|
||||||
url(r'^/order/?$', OrderView.as_view(), name='order'),
|
|
||||||
url(r'^/order-success/?$', SuccessView.as_view(), name='order_success'),
|
url(r'^/order-success/?$', SuccessView.as_view(), name='order_success'),
|
||||||
url(r'^/beta_access?$', BetaAccessView.as_view(), name='beta_access'),
|
url(r'^/beta_access?$', BetaAccessView.as_view(), name='beta_access'),
|
||||||
]
|
]
|
||||||
|
|
|
@ -70,78 +70,6 @@ class PricingView(TemplateView):
|
||||||
return redirect(reverse('hosting:payment'))
|
return redirect(reverse('hosting:payment'))
|
||||||
|
|
||||||
|
|
||||||
class OrderView(TemplateView):
|
|
||||||
template_name = "datacenterlight/order.html"
|
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
|
||||||
try:
|
|
||||||
manager = OpenNebulaManager()
|
|
||||||
templates = manager.get_templates()
|
|
||||||
|
|
||||||
context = {
|
|
||||||
'templates': VirtualMachineTemplateSerializer(templates, many=True).data,
|
|
||||||
}
|
|
||||||
except:
|
|
||||||
messages.error( request,
|
|
||||||
'We have a temporary problem to connect to our backend. \
|
|
||||||
Please try again in a few minutes'
|
|
||||||
)
|
|
||||||
context = {
|
|
||||||
'error' : 'connection'
|
|
||||||
}
|
|
||||||
|
|
||||||
return render(request, self.template_name, context)
|
|
||||||
|
|
||||||
def post(self, request):
|
|
||||||
|
|
||||||
cores = request.POST.get('cpu')
|
|
||||||
memory = request.POST.get('ram')
|
|
||||||
storage = request.POST.get('storage')
|
|
||||||
price = request.POST.get('total')
|
|
||||||
template_id = int(request.POST.get('config'))
|
|
||||||
manager = OpenNebulaManager()
|
|
||||||
template = manager.get_template(template_id)
|
|
||||||
template_data = VirtualMachineTemplateSerializer(template).data
|
|
||||||
|
|
||||||
name = request.POST.get('name')
|
|
||||||
email = request.POST.get('email')
|
|
||||||
name_field = forms.CharField()
|
|
||||||
email_field = forms.EmailField()
|
|
||||||
try:
|
|
||||||
name = name_field.clean(name)
|
|
||||||
except ValidationError as err:
|
|
||||||
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper name.'.format(name))
|
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:order'))
|
|
||||||
|
|
||||||
try:
|
|
||||||
email = email_field.clean(email)
|
|
||||||
except ValidationError as err:
|
|
||||||
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper email.'.format(email))
|
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:order'))
|
|
||||||
|
|
||||||
context = {
|
|
||||||
'name': name,
|
|
||||||
'email': email,
|
|
||||||
'cores': cores,
|
|
||||||
'memory': memory,
|
|
||||||
'storage': storage,
|
|
||||||
'price': price,
|
|
||||||
'template': template_data['name'],
|
|
||||||
}
|
|
||||||
email_data = {
|
|
||||||
'subject': "Data Center Light Order from %s" % context['email'],
|
|
||||||
'from_address': '(datacenterlight) datacenterlight Support <support@datacenterlight.ch>',
|
|
||||||
'to': 'info@ungleich.ch',
|
|
||||||
'context': context,
|
|
||||||
'template_name': 'new_order_notification',
|
|
||||||
'template_path': 'datacenterlight/emails/'
|
|
||||||
}
|
|
||||||
email = EmailMessage(**email_data)
|
|
||||||
email.send()
|
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:order_success'))
|
|
||||||
|
|
||||||
|
|
||||||
class BetaAccessView(FormView):
|
class BetaAccessView(FormView):
|
||||||
template_name = "datacenterlight/beta_access.html"
|
template_name = "datacenterlight/beta_access.html"
|
||||||
form_class = BetaAccessForm
|
form_class = BetaAccessForm
|
||||||
|
@ -277,13 +205,13 @@ class IndexView(CreateView):
|
||||||
name = name_field.clean(name)
|
name = name_field.clean(name)
|
||||||
except ValidationError as err:
|
except ValidationError as err:
|
||||||
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper name.'.format(name))
|
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper name.'.format(name))
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:order'))
|
return HttpResponseRedirect(reverse('datacenterlight:index'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
email = email_field.clean(email)
|
email = email_field.clean(email)
|
||||||
except ValidationError as err:
|
except ValidationError as err:
|
||||||
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper email.'.format(email))
|
messages.add_message(self.request, messages.ERROR, '%(value) is not a proper email.'.format(email))
|
||||||
return HttpResponseRedirect(reverse('datacenterlight:order'))
|
return HttpResponseRedirect(reverse('datacenterlight:index'))
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'name': name,
|
'name': name,
|
||||||
|
|
Loading…
Reference in a new issue