Merge branch 'master' of github.com:ungleich/dynamicweb

This commit is contained in:
Levi 2017-06-15 16:06:11 -05:00
commit 7a4d3bb41f
31 changed files with 569 additions and 741 deletions

View file

@ -24,6 +24,8 @@ class HostingUserLoginForm(forms.Form):
is_auth = authenticate(email=email, password=password)
if not is_auth:
raise forms.ValidationError("Your username and/or password were incorrect.")
elif is_auth.validated == 0:
raise forms.ValidationError(_("Your account is not activated yet."))
return self.cleaned_data
def clean_email(self):

View file

@ -318,6 +318,17 @@ h6 {
padding: 15px 20px 0 20px;
}
.sign-up-message {
padding: 25px 30px 25px 30px;
text-align: justify;
font-size: 18px;
line-height: 30px;
}
.sign-up-message a {
font-size: 18px;
color: #1e94cc !important;
}
@media (max-width: 1199px) {
ul.banner-social-buttons {
float: left;

View file

@ -62,9 +62,6 @@
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="{% url 'hosting:virtual_machines' %}">
<i class="fa fa-server" aria-hidden="true"></i> {% trans "My Virtual Machines"%}
@ -75,22 +72,21 @@
<i class="fa fa-credit-card"></i> {% trans "My Orders"%}
</a>
</li>
<li>
<a href="{% url 'hosting:notifications' %}">
<i class="fa fa-bell"></i> {% trans "Notifications "%}
</a>
</li>
<li class="dropdown">
<a class="dropdown-toggle" role="button" data-toggle="dropdown" href="#">
<i class="glyphicon glyphicon-user"></i> {{request.user.name}} <span class="caret"></span></a>
<ul id="g-account-menu" class="dropdown-menu" role="menu">
<li>
<a href="{% url 'hosting:ssh_keys' %}">
<i class="fa fa-key"></i> {% trans "Keys"%}
</a>
</li>
<li>
<a href="{% url 'hosting:notifications' %}">
<i class="fa fa-bell"></i> {% trans "Notifications "%}
</a>
</li>
<li><a href="{% url 'hosting:logout' %}"><i class="glyphicon glyphicon-lock"></i>{% trans "Logout"%} </a></li>
<li>
<a href="{% url 'hosting:ssh_keys' %}">
<i class="fa fa-key"></i> {% trans "Keys"%}
</a>
</li>
</ul>
</li>
<!--

View file

@ -49,8 +49,8 @@
<tr>
<td>{{ vm.name }}</td>
<td><span class="pull-right">{{ vm.cores }}</span></td>
<td><span class="pull-right">{{ vm.memory|floatformat }} GiB </span></td>
<td><span class="pull-right">{{ vm.disk_size|floatformat }} GiB </span></td>
<td><span class="pull-right">{{ vm.memory|floatformat }} GB </span></td>
<td><span class="pull-right">{{ vm.disk_size|floatformat }} GB </span></td>
<td><span class="pull-right">{{ vm.price|floatformat }} CHF</span></td>
</tr>

View file

@ -42,14 +42,14 @@
<li>
<div class="form-group">
<div class="btn-group">
<label for="memory">Memory: {{vm.memory}} GiB</label>
<label for="memory">Memory: {{vm.memory}} GB</label>
</div>
</div>
</li>
<li>
<div class="form-group row">
<div class="col-xs-offset-1 col-xs-9 col-sm-12 col-md-12 col-md-offset-0">
<label for="Disk Size">Disk Size: {{vm.disk_size}} GiB</label>
<label for="Disk Size">Disk Size: {{vm.disk_size}} GB</label>
</div>
</div>
</li>
@ -79,4 +79,4 @@
</div>
</div>
</div>
</div>

View file

@ -4,7 +4,20 @@
{% block content %}
<div class="order-detail-container">
{% if messages %}
<div class="row">
<div class="col-xs-12 col-md-8 col-md-offset-2">
<br/>
<div class="alert alert-warning">
{% for message in messages %}
<span>{{ message }}</span>
{% endfor %}
</div>
</div>
</div>
{% endif %}
{% if not error %}
<div class="row">
<div class="col-xs-12 col-md-8 col-md-offset-2">
<div class="invoice-title">
<h2>{% trans "Invoice"%}</h2><h3 class="pull-right">{% trans "Order #"%} {{order.id}}</h3>
@ -51,9 +64,9 @@
<div class="content">
<p><b>{% trans "Cores"%}</b> <span class="pull-right">{{vm.cores}}</span></p>
<hr>
<p><b>{% trans "Memory"%}</b> <span class="pull-right">{{vm.memory}} GiB</span></p>
<p><b>{% trans "Memory"%}</b> <span class="pull-right">{{vm.memory}} GB</span></p>
<hr>
<p><b>{% trans "Disk space"%}</b> <span class="pull-right">{{vm.disk_size}} GiB</span></p>
<p><b>{% trans "Disk space"%}</b> <span class="pull-right">{{vm.disk_size}} GB</span></p>
<hr>
<h4>{% trans "Total"%}<p class="pull-right"><b>{{vm.price}} CHF</b></p></h4>
</div>
@ -66,5 +79,6 @@
{% endif %}
</div>
</div>
{% endif %}
</div>
{%endblock%}

View file

@ -33,9 +33,8 @@
{% endif %}
</td>
<td>
<button type="button" class="btn btn-default"><a
<a class="btn btn-default"
href="{% url 'hosting:orders' order.id %}">{% trans "View Detail"%}</a>
</button>
<button type="button" class="btn btn-default" data-toggle="modal"
data-target="#Modal{{ order.id }}"><a
href="#">{% trans "Cancel Order"%}</a>

View file

@ -18,10 +18,10 @@
class="pull-right">{{request.session.specs.cpu|floatformat}}</span></p>
<hr>
<p><b>{%trans "Memory"%}</b> <span
class="pull-right">{{request.session.specs.memory|floatformat}} GiB</span></p>
class="pull-right">{{request.session.specs.memory|floatformat}} GB</span></p>
<hr>
<p><b>{%trans "Disk space"%}</b> <span
class="pull-right">{{request.session.specs.disk_size|floatformat}} GiB</span></p>
class="pull-right">{{request.session.specs.disk_size|floatformat}} GB</span></p>
<hr>
<h4>Total<p
class="pull-right"><b>{{request.session.specs.price }} CHF</b></p></h4>

View file

@ -0,0 +1,21 @@
{% extends "hosting/base_short.html" %}
{% load staticfiles bootstrap3 i18n %}
{% block content %}
<div class="auth-container">
<div class="auth-bg"></div>
<div class="container">
<div class="auth-title">
<h2>{% trans "Your VM hosted in Switzerland"%}</h2>
</div>
<div class="auth-content">
<div class="intro-message auth-box sign-up">
<h2 class="section-heading">{{section_title}}</h2>
<div class="sign-up-message">
{{message}}
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -80,14 +80,14 @@
<div class="col-md-3">
<div class="well text-center box-setting">
<i class="fa fa-tachometer" aria-hidden="true"></i> {% trans "Memory"%} <br/>
<span class="label label-success">{{virtual_machine.memory}} GiB</span>
<span class="label label-success">{{virtual_machine.memory}} GB</span>
</div>
</div>
<div class="col-md-3">
<div class="well text-center box-setting">
<i class="fa fa-hdd-o" aria-hidden="true"></i>
<span>{% trans "Disk"%}</span>
<span class="label label-success">{{virtual_machine.disk_size|floatformat:2}} GiB</span>
<span class="label label-success">{{virtual_machine.disk_size|floatformat:2}} GB</span>
</div>
</div>
</div><!--/row-->

View file

@ -1,7 +1,7 @@
from django.conf.urls import url
from .views import DjangoHostingView, RailsHostingView, PaymentVMView,\
NodeJSHostingView, LoginView, SignupView, IndexView, \
NodeJSHostingView, LoginView, SignupView, SignupValidateView, SignupValidatedView, IndexView, \
OrdersHostingListView, OrdersHostingDetailView, VirtualMachinesPlanListView,\
VirtualMachineView, OrdersHostingDeleteView, NotificationsView, \
MarkAsReadNotificationView, PasswordResetView, PasswordResetConfirmView, HostingPricingView,\
@ -35,9 +35,11 @@ urlpatterns = [
name='read_notification'),
url(r'login/?$', LoginView.as_view(), name='login'),
url(r'signup/?$', SignupView.as_view(), name='signup'),
url(r'signup-validate/?$', SignupValidateView.as_view(), name='signup-validate'),
url(r'reset-password/?$', PasswordResetView.as_view(), name='reset_password'),
url(r'reset-password-confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
PasswordResetConfirmView.as_view(), name='reset_password_confirm'),
url(r'^logout/?$', 'django.contrib.auth.views.logout',
{'next_page': '/hosting/login?logged_out=true'}, name='logout')
{'next_page': '/hosting/login?logged_out=true'}, name='logout'),
url(r'^validate/(?P<validate_slug>.*)/$', SignupValidatedView.as_view(), name='validate')
]

View file

@ -18,7 +18,7 @@ from guardian.mixins import PermissionRequiredMixin
from stored_messages.settings import stored_messages_settings
from stored_messages.models import Message
from stored_messages.api import mark_read
from django.utils.safestring import mark_safe
from membership.models import CustomUser, StripeCustomer
from utils.stripe_utils import StripeUtils
@ -32,10 +32,11 @@ from .mixins import ProcessVMSelectionMixin
from opennebula_api.models import OpenNebulaManager
from opennebula_api.serializers import VirtualMachineSerializer,\
VirtualMachineTemplateSerializer
from django.utils.translation import ugettext_lazy as _
from oca.exceptions import OpenNebulaException
from oca.pool import WrongNameError
from oca.pool import WrongNameError, WrongIdError
CONNECTION_ERROR = "Your VMs cannot be displayed at the moment due to a backend \
connection error. please try again in a few minutes."
@ -199,15 +200,43 @@ class SignupView(CreateView):
name = form.cleaned_data.get('name')
email = form.cleaned_data.get('email')
password = form.cleaned_data.get('password')
this_base_url = "{0}://{1}".format(self.request.scheme, self.request.get_host())
CustomUser.register(name, password, email, app='dcl', base_url=this_base_url)
CustomUser.register(name, password, email)
auth_user = authenticate(email=email, password=password)
login(self.request, auth_user)
return HttpResponseRedirect(reverse_lazy('hosting:signup-validate'))
return HttpResponseRedirect(self.get_success_url())
class SignupValidateView(TemplateView):
template_name = "hosting/signup_validate.html"
def get_context_data(self, **kwargs):
context = super(SignupValidateView, self).get_context_data(**kwargs)
login_url = reverse('hosting:login')
message= _("Thank you for signing up. We have sent an email to you. Please follow the instructions in it to activate your account. Once activated, you can login using ") + '<a href="' + login_url +'">login</a>'
section_title='Sign up'
context['message'] = mark_safe(message)
context['section_title'] = section_title
return context
class SignupValidatedView(SignupValidateView):
template_name = "hosting/signup_validate.html"
def get_context_data(self, **kwargs):
context = super(SignupValidateView, self).get_context_data(**kwargs)
validated = CustomUser.validate_url(self.kwargs['validate_slug'])
login_url = reverse('hosting:login')
if validated:
message= _("Your account has been activated. You can now ") + '<a href="' + login_url +'">login</a>'
section_title=_('Account activation')
else:
message= _("Sorry. Your request is invalid.") + '<a href="' + login_url +'">login</a>'
section_title=_('Account activation')
context['message'] = mark_safe(message)
context['section_title'] = section_title
return context
class PasswordResetView(PasswordResetViewMixin):
site = 'dcl'
template_name = 'hosting/reset_password.html'
form_class = PasswordResetRequestForm
success_url = reverse_lazy('hosting:login')
@ -583,8 +612,15 @@ class OrdersHostingDetailView(PermissionRequiredMixin, LoginRequiredMixin, Detai
try:
vm = manager.get_vm(obj.vm_id)
context['vm'] = VirtualMachineSerializer(vm).data
except WrongIdError:
messages.error(self.request,
'The VM you are looking for is unavailable at the moment. \
Please contact Data Center Light support.'
)
self.kwargs['error'] = 'WrongIdError'
context['error'] = 'WrongIdError'
except ConnectionRefusedError:
messages.error(request,
messages.error(self.request,
'In order to create a VM, you need to create/upload your SSH KEY first.'
)
return context