core: add user settings and user delete
This commit is contained in:
parent
276c6fb297
commit
71f41e655f
|
@ -9,7 +9,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<div class="">
|
<div class="">
|
||||||
<form action="" method="post" class="form-horizontal">
|
<form action="" method="post" class="form-horizontal">
|
||||||
{% include 'blocks/form.html' with form=form %}
|
{% include 'partials/form.html' with form=form %}
|
||||||
<a class="btn btn-default" href="{% back %}">{% trans "Cancel" %}</a>
|
<a class="btn btn-default" href="{% back %}">{% trans "Cancel" %}</a>
|
||||||
<input type="submit" class="btn btn-primary" value="{% trans 'Create' %}" />
|
<input type="submit" class="btn btn-primary" value="{% trans 'Create' %}" />
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
"""passbook core user forms"""
|
||||||
|
|
||||||
|
from django import forms
|
||||||
|
|
||||||
|
from passbook.core.models import User
|
||||||
|
|
||||||
|
|
||||||
|
class UserDetailForm(forms.ModelForm):
|
||||||
|
"""Update User Details"""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
|
||||||
|
model = User
|
||||||
|
fields = ['username', 'first_name', 'last_name', 'email']
|
|
@ -7,6 +7,5 @@ from django.core.signals import Signal
|
||||||
# from passbook.core.models import Invitation, User
|
# from passbook.core.models import Invitation, User
|
||||||
|
|
||||||
user_signed_up = Signal(providing_args=['request', 'user'])
|
user_signed_up = Signal(providing_args=['request', 'user'])
|
||||||
# TODO: Send this signal in admin interface
|
|
||||||
invitation_created = Signal(providing_args=['request', 'invitation'])
|
invitation_created = Signal(providing_args=['request', 'invitation'])
|
||||||
invitation_used = Signal(providing_args=['request', 'invitation', 'user'])
|
invitation_used = Signal(providing_args=['request', 'invitation', 'user'])
|
||||||
|
|
|
@ -38,13 +38,7 @@
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
<a href="#0">Link</a>
|
<a href="{% url 'passbook_core:user-settings' %}">{% trans 'User Settings' %}</a>
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="#0">Another link</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="#0">Something else here</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<li>
|
<li>
|
||||||
|
@ -55,7 +49,7 @@
|
||||||
</ul>
|
</ul>
|
||||||
{% is_active_app 'passbook_admin' as is_admin %}
|
{% is_active_app 'passbook_admin' as is_admin %}
|
||||||
<ul class="nav navbar-nav navbar-primary {% if is_admin == 'active' %}persistent-secondary{% endif %}">
|
<ul class="nav navbar-nav navbar-primary {% if is_admin == 'active' %}persistent-secondary{% endif %}">
|
||||||
<li class="{% is_active_app 'passbook_core' %}">
|
<li class="{% is_active 'passbook_core:overview' %}">
|
||||||
<a href="{% url 'passbook_core:overview' %}">{% trans 'Overview' %}</a>
|
<a href="{% url 'passbook_core:overview' %}">{% trans 'Overview' %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="{% is_active_app 'passbook_admin' %}">
|
<li class="{% is_active_app 'passbook_admin' %}">
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
{% extends "overview/base.html" %}
|
||||||
|
|
||||||
|
{% load i18n %}
|
||||||
|
{% load is_active %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="container">
|
||||||
|
<div class="col-md-3 ">
|
||||||
|
<div class="nav-category">
|
||||||
|
<h2>{% trans 'User Profile'%}</h2>
|
||||||
|
<ul class="nav nav-pills nav-stacked">
|
||||||
|
<li class="{% is_active 'passbook_core:user-settings' %}"><a href="{% url 'passbook_core:user-settings' %}"><i class="fa fa-desktop"></i>{% trans 'Details' %}</a></li>
|
||||||
|
<li><a href="#"><i class="fa fa-cog"></i>System Services</a></li>
|
||||||
|
<li><a href="#"><i class="fa fa-file-text-o"></i>Journal</a></li>
|
||||||
|
<li><a href="#"><i class="fa fa-cloud"></i>Storage</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-9">
|
||||||
|
{% block page %}
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,13 @@
|
||||||
|
{% extends "user/base.html" %}
|
||||||
|
|
||||||
|
{% load i18n %}
|
||||||
|
|
||||||
|
{% block page %}
|
||||||
|
<h1>{% trans 'Update details' %}</h1>
|
||||||
|
<form action="" method="post" class="form-horizontal">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% include 'partials/form.html' %}
|
||||||
|
<input class="btn btn-primary" type="submit" value="{% trans 'Update' %}">
|
||||||
|
<a class="btn btn-danger" href="{% url 'passbook_core:user-delete' %}?back={{ request.get_full_path }}">{% trans 'Delete user' %}</a>
|
||||||
|
</form>
|
||||||
|
{% endblock %}
|
|
@ -6,7 +6,7 @@ from django.contrib import admin
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
from django.views.generic import RedirectView
|
from django.views.generic import RedirectView
|
||||||
|
|
||||||
from passbook.core.views import authentication, overview
|
from passbook.core.views import authentication, overview, user
|
||||||
from passbook.lib.utils.reflection import get_apps
|
from passbook.lib.utils.reflection import get_apps
|
||||||
|
|
||||||
LOGGER = getLogger(__name__)
|
LOGGER = getLogger(__name__)
|
||||||
|
@ -14,9 +14,14 @@ admin.autodiscover()
|
||||||
admin.site.login = RedirectView.as_view(pattern_name='passbook_core:auth-login')
|
admin.site.login = RedirectView.as_view(pattern_name='passbook_core:auth-login')
|
||||||
|
|
||||||
core_urls = [
|
core_urls = [
|
||||||
|
# Authentication views
|
||||||
path('auth/login/', authentication.LoginView.as_view(), name='auth-login'),
|
path('auth/login/', authentication.LoginView.as_view(), name='auth-login'),
|
||||||
path('auth/logout/', authentication.LogoutView.as_view(), name='auth-logout'),
|
path('auth/logout/', authentication.LogoutView.as_view(), name='auth-logout'),
|
||||||
path('auth/sign_up/', authentication.SignUpView.as_view(), name='auth-sign-up'),
|
path('auth/sign_up/', authentication.SignUpView.as_view(), name='auth-sign-up'),
|
||||||
|
# User views
|
||||||
|
path('user/', user.UserSettingsView.as_view(), name='user-settings'),
|
||||||
|
path('user/delete/', user.UserDeleteView.as_view(), name='user-delete'),
|
||||||
|
# Overview
|
||||||
path('', overview.OverviewView.as_view(), name='overview'),
|
path('', overview.OverviewView.as_view(), name='overview'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -211,20 +211,8 @@ class SignUpView(UserPassesTestMixin, FormView):
|
||||||
sender=SignUpView,
|
sender=SignUpView,
|
||||||
user=new_user,
|
user=new_user,
|
||||||
request=request)
|
request=request)
|
||||||
# try:
|
# TODO: Implement Verification, via email or others
|
||||||
# TODO: Create signal for signup
|
# if needs_confirmation:
|
||||||
# on_user_sign_up.send(
|
# Create Account Confirmation UUID
|
||||||
# sender=None,
|
# AccountConfirmation.objects.create(user=new_user)
|
||||||
# user=new_user,
|
|
||||||
# request=request,
|
|
||||||
# password=data.get('password'),
|
|
||||||
# needs_confirmation=needs_confirmation)
|
|
||||||
# TODO: Implement Verification, via email or others
|
|
||||||
# if needs_confirmation:
|
|
||||||
# Create Account Confirmation UUID
|
|
||||||
# AccountConfirmation.objects.create(user=new_user)
|
|
||||||
# except SignalException as exception:
|
|
||||||
# LOGGER.warning("Failed to sign up user %s", exception, exc_info=exception)
|
|
||||||
# new_user.delete()
|
|
||||||
# raise
|
|
||||||
return new_user
|
return new_user
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
"""passbook core user views"""
|
||||||
|
from django.contrib import messages
|
||||||
|
from django.contrib.auth import logout
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
|
from django.views.generic import DeleteView, UpdateView
|
||||||
|
|
||||||
|
from passbook.core.forms.user import UserDetailForm
|
||||||
|
|
||||||
|
|
||||||
|
class UserSettingsView(UpdateView):
|
||||||
|
"""Update User settings"""
|
||||||
|
template_name = 'user/settings.html'
|
||||||
|
form_class = UserDetailForm
|
||||||
|
|
||||||
|
def get_object(self):
|
||||||
|
return self.request.user
|
||||||
|
|
||||||
|
class UserDeleteView(DeleteView):
|
||||||
|
"""Delete user account"""
|
||||||
|
|
||||||
|
template_name = 'generic/delete.html'
|
||||||
|
|
||||||
|
def get_object(self):
|
||||||
|
return self.request.user
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
messages.success(self.request, _('Successfully deleted user.'))
|
||||||
|
logout(self.request)
|
||||||
|
return reverse('passbook_core:auth-login')
|
|
@ -15,13 +15,13 @@
|
||||||
<form role="form" method="POST">
|
<form role="form" method="POST">
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<h3><clr-icon shape="cog" size="32"></clr-icon>{% trans 'General settings' %}</h3>
|
<h3><clr-icon shape="cog" size="32"></clr-icon>{% trans 'General settings' %}</h3>
|
||||||
{% include 'blocks/form.html' with form=general %}
|
{% include 'partials/form.html' with form=general %}
|
||||||
<h3><clr-icon shape="connect" size="32"></clr-icon>{% trans 'Connection settings' %}</h3>
|
<h3><clr-icon shape="connect" size="32"></clr-icon>{% trans 'Connection settings' %}</h3>
|
||||||
{% include 'blocks/form.html' with form=connection %}
|
{% include 'partials/form.html' with form=connection %}
|
||||||
<h3><clr-icon shape="certificate" size="32"></clr-icon>{% trans 'Authentication backend ' %}</h3>
|
<h3><clr-icon shape="certificate" size="32"></clr-icon>{% trans 'Authentication backend ' %}</h3>
|
||||||
{% include 'blocks/form.html' with form=authentication %}
|
{% include 'partials/form.html' with form=authentication %}
|
||||||
<h3><clr-icon shape="users" size="32"></clr-icon>{% trans 'Create users settings' %}</h3>
|
<h3><clr-icon shape="users" size="32"></clr-icon>{% trans 'Create users settings' %}</h3>
|
||||||
{% include 'blocks/form.html' with form=create_users %}
|
{% include 'partials/form.html' with form=create_users %}
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<button type="submit" value="general" class="btn btn-sm btn-primary">{% trans 'Update' %}</button>
|
<button type="submit" value="general" class="btn btn-sm btn-primary">{% trans 'Update' %}</button>
|
||||||
|
|
Reference in New Issue