Made order and pricing distinct from each other. We use order for feature/manualorder and we leave pricing as it was before.

This commit is contained in:
M.Ravi 2017-06-07 02:02:31 +05:30
parent bef6b03872
commit 94bac7222c
3 changed files with 146 additions and 59 deletions

View file

@ -74,19 +74,24 @@
<a class="url" href="javascript:void(0)" data-url="#contact" >{% trans "Contact" %}</a> <a class="url" href="javascript:void(0)" data-url="#contact" >{% trans "Contact" %}</a>
</li> --> </li> -->
<select class="selectpicker" data-width="fit" onchange="location = this.value;" style="margin-top:10px;"> <li class="nav-language">
<div class="select-language">
{% if LANGUAGE_CODE == 'en-us'%} {% if LANGUAGE_CODE == 'en-us'%}
<option selected="selected" value="{{base_url}}/en-us/datacenterlight/">English</option> <span>English</span>
{% else %} {% else %}
<option value="{{base_url}}/en-us/datacenterlight/">English</option> <span>Deutsch</span>
{% endif %} {% endif %}
{% if LANGUAGE_CODE == 'de'%} <i class="fa fa-globe" aria-hidden="true"></i>
<option selected="selected" value="{{base_url}}/de/datacenterlight/">Deutsch</option> </div>
<div class="drop-language">
{% if LANGUAGE_CODE == 'en-us'%}
<a class="url" href="{{base_url}}/de/datacenterlight/order" >Deutsch</a>
{% else %} {% else %}
<option value="{{base_url}}/de/datacenterlight/">Deutsch</option> <a class="url" href="{{base_url}}/en-us/datacenterlight/order" >English</a>
{% endif %} {% endif %}
</select> </div>
</li>
</ul> </ul>
@ -107,7 +112,7 @@
<div class="card"> <div class="card">
<img class="img-beta" src="{% static 'datacenterlight/img/beta-img.png' %}" alt=""> <img class="img-beta" src="{% static 'datacenterlight/img/beta-img.png' %}" alt="">
<div class="caption"> <div class="caption">
<form method="POST" action=""> <form id="order_form" method="POST" action="">
{% csrf_token %} {% csrf_token %}
<div class="title"> <div class="title">
@ -166,6 +171,9 @@
<input type="submit" class="btn btn-primary" value="{% trans 'Order Now!' %}"></input> <input type="submit" class="btn btn-primary" value="{% trans 'Order Now!' %}"></input>
</form> </form>
</div>
<div>
<div id="error_message_box" class="error-message-box"></div>
</div> </div>
</div> </div>
@ -173,7 +181,7 @@
<h2 class="section-heading">{% trans "Simple and affordable: Try our virtual machine with featherlight price." %}</h2> <h2 class="section-heading">{% trans "Simple and affordable: Try our virtual machine with featherlight price." %}</h2>
<div class="description"> <div class="description">
<p>Our VMs are hosted in Glarus, Switzerland. WARNING: We are currently running in BETA mode, especially our website We hope you will not encounter any hiccups, but if you, please let us know at support@datacenterlight.ch</p> <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> </div>
</div> </div>
@ -192,7 +200,7 @@
</li> </li>
<li class="footer-menu-divider">&sdot;</li> <li class="footer-menu-divider">&sdot;</li>
<li> <li>
<a href="#about">{% trans "How it works" %}</a></li> <a href="#about">{% trans "What is it" %}</a></li>
<li class="footer-menu-divider">&sdot;</li> <li class="footer-menu-divider">&sdot;</li>
<li> <li>
<a href="#about">{% trans "Scale out" %}</a></li> <a href="#about">{% trans "Scale out" %}</a></li>
@ -216,8 +224,37 @@
<!-- jQuery --> <!-- jQuery -->
<script src="{% static 'datacenterlight/js/jquery.js' %}"></script> <script src="{% static 'datacenterlight/js/jquery.js' %}"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.5.4/bootstrap-select.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.16.0/jquery.validate.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){
$.validator.setDefaults({
ignore: []
});
$('#order_form').validate({
wrapper: 'div',
errorLabelContainer: "#error_message_box",
rules: {
name: {
required: true,
minlength: 3
},
email: {
required: true,
email: true
}
},
messages: {
name: "Please enter your name",
email: "Please enter a valid email address"
},
submitHandler: function (form) {
return true;
}
});
});
window.onload=function(){ window.onload=function(){
$('.selectpicker').selectpicker({ $('.selectpicker').selectpicker({
style: 'btn-link', style: 'btn-link',
@ -232,7 +269,6 @@
}; };
</script> </script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.5.4/bootstrap-select.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.5.4/bootstrap-select.js"></script>
<!-- Bootstrap Core JavaScript --> <!-- Bootstrap Core JavaScript -->

View file

@ -1,13 +1,14 @@
from django.conf.urls import url from django.conf.urls import url
from .views import IndexView, BetaProgramView, LandingProgramView, BetaAccessView, PricingView, SuccessView from .views import IndexView, BetaProgramView, LandingProgramView, BetaAccessView, PricingView, SuccessView, OrderView
urlpatterns = [ urlpatterns = [
url(r'^/?$', IndexView.as_view(), name='index'), url(r'^/?$', IndexView.as_view(), name='index'),
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'^/order/?$', 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'),
] ]

View file

@ -22,6 +22,56 @@ class SuccessView(TemplateView):
class PricingView(TemplateView): class PricingView(TemplateView):
template_name = "datacenterlight/pricing.html" template_name = "datacenterlight/pricing.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)
request.session['template'] = VirtualMachineTemplateSerializer(template).data
if not request.user.is_authenticated():
request.session['next'] = reverse('hosting:payment')
request.session['specs'] = {
'cpu':cores,
'memory': memory,
'disk_size': storage,
'price': price,
}
return redirect(reverse('hosting:payment'))
class OrderView(TemplateView):
template_name = "datacenterlight/order.html"
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
try: try:
manager = OpenNebulaManager() manager = OpenNebulaManager()
@ -60,13 +110,13 @@ class PricingView(TemplateView):
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:pricing')) return HttpResponseRedirect(reverse('datacenterlight:order'))
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:pricing')) return HttpResponseRedirect(reverse('datacenterlight:order'))
# We have valid email and name of the customer, hence send an # We have valid email and name of the customer, hence send an
# email to the admin # email to the admin