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">
{% if LANGUAGE_CODE == 'en-us'%} <div class="select-language">
<option selected="selected" value="{{base_url}}/en-us/datacenterlight/">English</option> {% if LANGUAGE_CODE == 'en-us'%}
{% else %} <span>English</span>
<option value="{{base_url}}/en-us/datacenterlight/">English</option> {% else %}
{% endif %} <span>Deutsch</span>
{% if LANGUAGE_CODE == 'de'%} {% endif %}
<option selected="selected" value="{{base_url}}/de/datacenterlight/">Deutsch</option> <i class="fa fa-globe" aria-hidden="true"></i>
{% else %} </div>
<option value="{{base_url}}/de/datacenterlight/">Deutsch</option> <div class="drop-language">
{% endif %} {% if LANGUAGE_CODE == 'en-us'%}
<a class="url" href="{{base_url}}/de/datacenterlight/order" >Deutsch</a>
{% else %}
<a class="url" href="{{base_url}}/en-us/datacenterlight/order" >English</a>
{% endif %}
</select> </div>
</li>
</ul> </ul>
@ -95,20 +100,20 @@
</div> </div>
<!-- /.container --> <!-- /.container -->
</nav> </nav>
<div class="intro-pricing"> <div class="intro-pricing">
<div class="intro-message"> <div class="intro-message">
<h2 class="section-heading">{% trans "We are cutting down the costs significantly!" %}</h2> <h2 class="section-heading">{% trans "We are cutting down the costs significantly!" %}</h2>
</div> </div>
</div> </div>
<div class="price-calc-section"> <div class="price-calc-section">
<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">
<h3>{% trans "VM hosting" %} </h3> <h3>{% trans "VM hosting" %} </h3>
@ -134,7 +139,7 @@
<i class="fa fa-plus-circle right" data-plus="ram" aria-hidden="true"></i> <i class="fa fa-plus-circle right" data-plus="ram" aria-hidden="true"></i>
</div> </div>
<div class="description"> <div class="description">
<i class="fa fa-minus-circle left" data-minus="storage" aria-hidden="true"></i> <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"> <input id="storageValue" class="input-price" type="number" min="10" max="500" step="10" name="storage">
<span>{% trans "GB Storage (SSD)" %}</span> <span>{% trans "GB Storage (SSD)" %}</span>
<i class="fa fa-plus-circle right" data-plus="storage" aria-hidden="true"></i> <i class="fa fa-plus-circle right" data-plus="storage" aria-hidden="true"></i>
@ -143,16 +148,16 @@
<div class="description select-configuration input"> <div class="description select-configuration input">
<label for="config">OS</label> <label for="config">OS</label>
<select name="config" id=""> <select name="config" id="">
{% for template in templates %} {% for template in templates %}
<option value="{{template.id}}">{{template.name}} </option> <option value="{{template.id}}">{{template.name}} </option>
{% endfor %} {% endfor %}
</select> </select>
</div> </div>
<input type="hidden" name="total"> <input type="hidden" name="total">
<!--<div class="description check-ip"> <!--<div class="description check-ip">
<input type="checkbox" name="ipv6"> Ipv6 Only<br> <input type="checkbox" name="ipv6"> Ipv6 Only<br>
</div>--> </div>-->
<div class="description input"> <div class="description input">
<label for="name">Name</label> <label for="name">Name</label>
@ -167,16 +172,19 @@
</form> </form>
</div> </div>
</div> <div>
<div id="error_message_box" class="error-message-box"></div>
</div>
</div>
<div class="text"> <div class="text">
<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>
<!-- /.banner --> <!-- /.banner -->
@ -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,23 +224,51 @@
<!-- 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 type="text/javascript"> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.16.0/jquery.validate.min.js"></script>
window.onload=function(){ <script type="text/javascript">
$('.selectpicker').selectpicker({ $(document).ready(function(){
style: 'btn-link', $.validator.setDefaults({
windowPadding: 10, ignore: []
}); });
var hash = window.location.hash.substr(1); $('#order_form').validate({
console.log(hash); wrapper: 'div',
if (hash == 'requestform'){ errorLabelContainer: "#error_message_box",
$('#reques-success-message').modal('show'); rules: {
} name: {
required: true,
}; minlength: 3
</script> },
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(){
$('.selectpicker').selectpicker({
style: 'btn-link',
windowPadding: 10,
});
var hash = window.location.hash.substr(1);
console.log(hash);
if (hash == 'requestform'){
$('#reques-success-message').modal('show');
}
};
</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