Fix login / logout views
This commit is contained in:
parent
889c71d069
commit
91e7f44eed
4 changed files with 45 additions and 9 deletions
|
@ -11,31 +11,31 @@
|
||||||
{% trans "Welcome" %} {{request.user.name}}
|
{% trans "Welcome" %} {{request.user.name}}
|
||||||
</div>
|
</div>
|
||||||
<div class="hosting-dashboard-content">
|
<div class="hosting-dashboard-content">
|
||||||
<a href="{% url 'hosting:create_virtual_machine' %}" class="hosting-dashboard-item">
|
<a href="{% url 'hosting:dashboard' %}" class="hosting-dashboard-item">
|
||||||
<h2>{% trans "Create VM" %}</h2>
|
<h2>{% trans "Create VM" %}</h2>
|
||||||
<div class="hosting-dashboard-image">
|
<div class="hosting-dashboard-image">
|
||||||
<img class="svg-img" src="{% static 'hosting/img/plusVM.svg' %}">
|
<img class="svg-img" src="{% static 'hosting/img/plusVM.svg' %}">
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<a href="{% url 'hosting:virtual_machines' %}" class="hosting-dashboard-item">
|
<a href="{% url 'hosting:dashboard' %}" class="hosting-dashboard-item">
|
||||||
<h2>{% trans "My VMs" %}</h2>
|
<h2>{% trans "My VMs" %}</h2>
|
||||||
<div class="hosting-dashboard-image">
|
<div class="hosting-dashboard-image">
|
||||||
<img class="svg-img" src="{% static 'hosting/img/vm.svg' %}">
|
<img class="svg-img" src="{% static 'hosting/img/vm.svg' %}">
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<a href="{% url 'hosting:ssh_keys' %}" class="hosting-dashboard-item">
|
<a href="{% url 'hosting:dashboard' %}" class="hosting-dashboard-item">
|
||||||
<h2>{% trans "My SSH Keys" %}</h2>
|
<h2>{% trans "My SSH Keys" %}</h2>
|
||||||
<div class="hosting-dashboard-image">
|
<div class="hosting-dashboard-image">
|
||||||
<img class="svg-img" src="{% static 'hosting/img/key.svg' %}">
|
<img class="svg-img" src="{% static 'hosting/img/key.svg' %}">
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<a href="{% url 'hosting:invoices' %}" class="hosting-dashboard-item">
|
<a href="{% url 'hosting:dashboard' %}" class="hosting-dashboard-item">
|
||||||
<h2>{% trans "My Bills" %}</h2>
|
<h2>{% trans "My Bills" %}</h2>
|
||||||
<div class="hosting-dashboard-image">
|
<div class="hosting-dashboard-image">
|
||||||
<img class="svg-img" src="{% static 'hosting/img/billing.svg' %}">
|
<img class="svg-img" src="{% static 'hosting/img/billing.svg' %}">
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<a href="{% url 'hosting:settings' %}" class="hosting-dashboard-item">
|
<a href="{% url 'hosting:dashboard' %}" class="hosting-dashboard-item">
|
||||||
<h2>{% trans "My Settings" %}</h2>
|
<h2>{% trans "My Settings" %}</h2>
|
||||||
<div class="hosting-dashboard-image">
|
<div class="hosting-dashboard-image">
|
||||||
<img class="svg-img" src="{% static 'hosting/img/dashboard_settings.svg' %}">
|
<img class="svg-img" src="{% static 'hosting/img/dashboard_settings.svg' %}">
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% load static i18n %}
|
{% load static i18n custom_tags %}
|
||||||
|
|
||||||
<!-- Navigation -->
|
<!-- Navigation -->
|
||||||
<nav class="navbar navbar-default navbar-fixed-top topnav" role="navigation">
|
<nav class="navbar navbar-default navbar-fixed-top topnav" role="navigation">
|
||||||
|
|
|
@ -12,7 +12,7 @@ from .views import (
|
||||||
#HostingPricingView, CreateVirtualMachinesView, HostingBillListView,
|
#HostingPricingView, CreateVirtualMachinesView, HostingBillListView,
|
||||||
#HostingBillDetailView, SSHKeyDeleteView, SSHKeyListView,
|
#HostingBillDetailView, SSHKeyDeleteView, SSHKeyListView,
|
||||||
#SSHKeyChoiceView, DashboardView, SettingsView,
|
#SSHKeyChoiceView, DashboardView, SettingsView,
|
||||||
ResendActivationEmailView,
|
ResendActivationEmailView, DashboardView, CustomLogoutView
|
||||||
#InvoiceListView, InvoiceDetailView, CheckUserVM
|
#InvoiceListView, InvoiceDetailView, CheckUserVM
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -30,7 +30,8 @@ urlpatterns = [
|
||||||
name='reset_password'),
|
name='reset_password'),
|
||||||
re_path(r'reset-password-confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
|
re_path(r'reset-password-confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
|
||||||
PasswordResetConfirmView.as_view(), name='reset_password_confirm'),
|
PasswordResetConfirmView.as_view(), name='reset_password_confirm'),
|
||||||
re_path('^logout/', auth_views.LogoutView.as_view(), name='logout'),
|
re_path('^logout/', CustomLogoutView.as_view(), name='logout'),
|
||||||
re_path(r'^validate/(?P<validate_slug>.*)/$',
|
re_path(r'^validate/(?P<validate_slug>.*)/$',
|
||||||
SignupValidatedView.as_view(), name='validate')
|
SignupValidatedView.as_view(), name='validate'),
|
||||||
|
re_path(r'dashboard/?$', DashboardView.as_view(), name='dashboard'),
|
||||||
]
|
]
|
|
@ -2,6 +2,8 @@ import uuid
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.tokens import default_token_generator
|
from django.contrib.auth.tokens import default_token_generator
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.contrib.auth.views import LogoutView
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.urls import reverse_lazy, reverse
|
from django.urls import reverse_lazy, reverse
|
||||||
|
@ -316,3 +318,36 @@ class IndexView(View):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
context = self.get_context_data()
|
context = self.get_context_data()
|
||||||
return render(request, self.template_name, context)
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
|
|
||||||
|
class DashboardView(LoginRequiredMixin, View):
|
||||||
|
template_name = "hosting/dashboard.html"
|
||||||
|
login_url = reverse_lazy('hosting:login')
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = {}
|
||||||
|
return context
|
||||||
|
|
||||||
|
@method_decorator(decorators)
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
context = self.get_context_data()
|
||||||
|
context['has_invoices'] = False
|
||||||
|
bills = []
|
||||||
|
# try:
|
||||||
|
# if hasattr(self.request.user, 'stripecustomer'):
|
||||||
|
# bills = MonthlyHostingBill.objects.filter(
|
||||||
|
# customer=self.request.user.stripecustomer
|
||||||
|
# )
|
||||||
|
# if len(bills) > 0:
|
||||||
|
# context['has_invoices'] = True
|
||||||
|
# except MonthlyHostingBill.DoesNotExist as dne:
|
||||||
|
# logger.error("{}'s monthly hosting bill not imported ?".format(
|
||||||
|
# self.request.user.email
|
||||||
|
# ))
|
||||||
|
return render(request, self.template_name, context)
|
||||||
|
|
||||||
|
|
||||||
|
class CustomLogoutView(LogoutView):
|
||||||
|
next_page = reverse_lazy('hosting:login')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue