commit
784ed0976b
9 changed files with 90 additions and 9 deletions
|
@ -449,7 +449,6 @@ STRIPE_DESCRIPTION_ON_PAYMENT = "Payment for ungleich GmbH services"
|
||||||
REGISTRATION_MESSAGE = {'subject': "Validation mail",
|
REGISTRATION_MESSAGE = {'subject': "Validation mail",
|
||||||
'message': 'Thank You for registering for account on Digital Glarus.\nPlease verify Your account under following link http://{host}/en-us/digitalglarus/login/validate/{slug}',
|
'message': 'Thank You for registering for account on Digital Glarus.\nPlease verify Your account under following link http://{host}/en-us/digitalglarus/login/validate/{slug}',
|
||||||
}
|
}
|
||||||
|
|
||||||
STRIPE_API_PRIVATE_KEY = env('STRIPE_API_PRIVATE_KEY')
|
STRIPE_API_PRIVATE_KEY = env('STRIPE_API_PRIVATE_KEY')
|
||||||
STRIPE_API_PUBLIC_KEY = env('STRIPE_API_PUBLIC_KEY')
|
STRIPE_API_PUBLIC_KEY = env('STRIPE_API_PUBLIC_KEY')
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,20 @@ class VirtualMachinePlan(models.Model):
|
||||||
instance = cls.objects.create(**data)
|
instance = cls.objects.create(**data)
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def generate_RSA(bits=2048):
|
||||||
|
'''
|
||||||
|
Generate an RSA keypair with an exponent of 65537 in PEM format
|
||||||
|
param: bits The key length in bits
|
||||||
|
Return private key and public key
|
||||||
|
'''
|
||||||
|
from Crypto.PublicKey import RSA
|
||||||
|
import os
|
||||||
|
new_key = RSA.generate(2048, os.urandom)
|
||||||
|
public_key = new_key.publickey()
|
||||||
|
private_key = new_key.exportKey("OpenSSH")
|
||||||
|
return private_key, public_key
|
||||||
|
|
||||||
|
|
||||||
class HostingOrder(models.Model):
|
class HostingOrder(models.Model):
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,9 @@
|
||||||
<script src="{% static 'hosting/js/jquery.js' %}"></script>
|
<script src="{% static 'hosting/js/jquery.js' %}"></script>
|
||||||
<script type="text/javascript" src="http://cdn.jsdelivr.net/jquery.validation/1.13.1/jquery.validate.min.js"></script>
|
<script type="text/javascript" src="http://cdn.jsdelivr.net/jquery.validation/1.13.1/jquery.validate.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Copy Clipboard -->
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.10/clipboard.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<!-- Bootstrap Core JavaScript -->
|
<!-- Bootstrap Core JavaScript -->
|
||||||
<script src="{% static 'hosting/js/bootstrap.min.js' %}"></script>
|
<script src="{% static 'hosting/js/bootstrap.min.js' %}"></script>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
{% block messages %}
|
{% block messages %}
|
||||||
{% if request.GET.logged_out %}
|
{% if request.GET.logged_out %}
|
||||||
<div class="alert alert-warning"> <!-- singular -->
|
<div class="alert"> <!-- singular -->
|
||||||
<a class="close" data-dismiss="alert">×</a>
|
<a class="close" data-dismiss="alert">×</a>
|
||||||
You haven been logged out
|
You haven been logged out
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
{% for field in form %}
|
{% for field in form %}
|
||||||
{% bootstrap_field field show_label=False type='fields'%}
|
{% bootstrap_field field show_label=False type='fields'%}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% bootstrap_form_errors form type='non_fields'%}
|
<p>{{form.non_field_errors|striptags}}</p>
|
||||||
{% buttons %}
|
{% buttons %}
|
||||||
<button type="submit" class="btn btn-default">
|
<button type="submit" class="btn btn-default">
|
||||||
Login
|
Login
|
||||||
|
|
37
hosting/templates/hosting/virtual_machine_key.html
Normal file
37
hosting/templates/hosting/virtual_machine_key.html
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
{% extends "hosting/base_short.html" %}
|
||||||
|
{% load staticfiles bootstrap3 %}
|
||||||
|
{% block content %}
|
||||||
|
<div>
|
||||||
|
<div class="container virtual-machine-container dashboard-container ">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-9 col-md-offset-2">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<h3><i class="fa fa-key" aria-hidden="true"></i> Private Key</h3>
|
||||||
|
<hr/>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="comment">private_key.pem</label>
|
||||||
|
<textarea class="form-control" rows="8" id="ssh_key">{{private_key}}</textarea>
|
||||||
|
<span class="h3 pull-right"><button type="button" class="btn btn-default"><a href=""> Download </a></button></span>
|
||||||
|
<span class="h3 pull-right"><button type="button" data-clipboard-target="#ssh_key" class="btn btn-default">Copy to Clipboard</button></span>
|
||||||
|
</div>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
(function () {new Clipboard('.btn');})();
|
||||||
|
</script>
|
||||||
|
{%endblock%}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from django.conf.urls import url
|
||||||
from .views import DjangoHostingView, RailsHostingView, PaymentVMView, \
|
from .views import DjangoHostingView, RailsHostingView, PaymentVMView, \
|
||||||
NodeJSHostingView, LoginView, SignupView, IndexView, \
|
NodeJSHostingView, LoginView, SignupView, IndexView, \
|
||||||
OrdersHostingListView, OrdersHostingDetailView, VirtualMachinesPlanListView,\
|
OrdersHostingListView, OrdersHostingDetailView, VirtualMachinesPlanListView,\
|
||||||
OrdersHostingDeleteView,VirtualMachineDetailView
|
VirtualMachineDetailView, GenerateVMSSHKeysView, OrdersHostingDeleteView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# url(r'pricing/?$', VMPricingView.as_view(), name='pricing'),
|
# url(r'pricing/?$', VMPricingView.as_view(), name='pricing'),
|
||||||
|
@ -18,6 +18,8 @@ urlpatterns = [
|
||||||
url(r'my-virtual-machines/?$', VirtualMachinesPlanListView.as_view(), name='virtual_machines'),
|
url(r'my-virtual-machines/?$', VirtualMachinesPlanListView.as_view(), name='virtual_machines'),
|
||||||
url(r'my-virtual-machines/(?P<pk>\d+)/?$', VirtualMachineDetailView.as_view(),
|
url(r'my-virtual-machines/(?P<pk>\d+)/?$', VirtualMachineDetailView.as_view(),
|
||||||
name='virtual_machines'),
|
name='virtual_machines'),
|
||||||
|
url(r'my-virtual-machines/(?P<pk>\d+)/key/?$', GenerateVMSSHKeysView.as_view(),
|
||||||
|
name='virtual_machine_key'),
|
||||||
url(r'login/?$', LoginView.as_view(), name='login'),
|
url(r'login/?$', LoginView.as_view(), name='login'),
|
||||||
url(r'signup/?$', SignupView.as_view(), name='signup'),
|
url(r'signup/?$', SignupView.as_view(), name='signup'),
|
||||||
url(r'^logout/?$', 'django.contrib.auth.views.logout',
|
url(r'^logout/?$', 'django.contrib.auth.views.logout',
|
||||||
|
|
|
@ -3,8 +3,8 @@ from django.shortcuts import get_object_or_404, render
|
||||||
from django.core.urlresolvers import reverse_lazy, reverse
|
from django.core.urlresolvers import reverse_lazy, reverse
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
|
||||||
from django.views.generic import View, CreateView, FormView, ListView, DetailView,DeleteView
|
from django.views.generic import View, CreateView, FormView, ListView, DetailView, UpdateView, DeleteView
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect, HttpResponse
|
||||||
from django.contrib.auth import authenticate, login
|
from django.contrib.auth import authenticate, login
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
@ -145,6 +145,31 @@ class SignupView(CreateView):
|
||||||
return HttpResponseRedirect(self.get_success_url())
|
return HttpResponseRedirect(self.get_success_url())
|
||||||
|
|
||||||
|
|
||||||
|
class GenerateVMSSHKeysView(LoginRequiredMixin, UpdateView):
|
||||||
|
model = VirtualMachinePlan
|
||||||
|
template_name = 'hosting/virtual_machine_key.html'
|
||||||
|
success_url = reverse_lazy('hosting:orders')
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
private_key, public_key = VirtualMachinePlan.generate_RSA()
|
||||||
|
context = {
|
||||||
|
'private_key': private_key
|
||||||
|
}
|
||||||
|
return context
|
||||||
|
|
||||||
|
# def get(self, *args, **kwargs):
|
||||||
|
# vm = self.get_object()
|
||||||
|
# private_key, public_key = VirtualMachinePlan.generate_RSA()
|
||||||
|
# print(private_key)
|
||||||
|
# print(public_key)
|
||||||
|
# key_name = "private_key"
|
||||||
|
# response = HttpResponse(content_type='text/plain')
|
||||||
|
# response['Content-Disposition'] = 'attachment; filename="%s.pem"' % key_name
|
||||||
|
# response.write(private_key)
|
||||||
|
# return response
|
||||||
|
# return HttpResponseRedirect(reverse(''))
|
||||||
|
|
||||||
|
|
||||||
class PaymentVMView(LoginRequiredMixin, FormView):
|
class PaymentVMView(LoginRequiredMixin, FormView):
|
||||||
template_name = 'hosting/payment.html'
|
template_name = 'hosting/payment.html'
|
||||||
login_url = reverse_lazy('hosting:login')
|
login_url = reverse_lazy('hosting:login')
|
||||||
|
|
|
@ -17,6 +17,7 @@ django-mptt
|
||||||
easy_thumbnails
|
easy_thumbnails
|
||||||
django-polymorphic
|
django-polymorphic
|
||||||
model-mommy
|
model-mommy
|
||||||
|
pycryptodome
|
||||||
|
|
||||||
#PLUGINS
|
#PLUGINS
|
||||||
djangocms_flash
|
djangocms_flash
|
||||||
|
|
Loading…
Reference in a new issue