New layout for user area (change password, delete acc, change profil)
This commit is contained in:
parent
8994be6ca1
commit
e69fe96904
@ -1,49 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
{% load i18n %}{% load bootstrap %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<h2>{% trans "User Profile of" %} {{ request.user.username }}</h2>
|
||||
<hr />
|
||||
<form class="form-horizontal" role="form" method="post">
|
||||
{% csrf_token %}
|
||||
{{ userform|bootstrap_horizontal:"col-sm-3 col-lg-3" }}
|
||||
{{ profileform|bootstrap_horizontal:"col-sm-3 col-lg-3" }}
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-3 col-sm-9">
|
||||
<input type="submit" class="btn btn-primary" value="{% trans "Submit" %}" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<h3>{% trans "Associate with remote Account" %}</h3>
|
||||
{% for backend in backends.not_associated %}
|
||||
<form method="get" action="{% url 'social:begin' backend %}"
|
||||
style="display: inline-block;">
|
||||
<button type="submit" class="btn btn-xs btn-success">{{ backend }}</button>
|
||||
</form>
|
||||
{% endfor %}
|
||||
<h3>{% trans "Disassociate from remote Account" %}</h3>
|
||||
{% for socauth in backends.associated %}
|
||||
<form method="post" action="{% url 'social:disconnect_individual' socauth.provider socauth.pk %}"
|
||||
style="display: inline-block;">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-xs btn-danger">{{ socauth.provider }}</button>
|
||||
</form>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h3>{% trans "Delete User Profile" %}</h3>
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
If you'ld like to stop using this service and delete this user profile and
|
||||
all your data (especially all hosts and all domains created by this user),
|
||||
you can do it here.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<a class="btn btn-danger" href="{% url 'account_delete' %}">
|
||||
<i class="fa fa-exclamation-triangle"></i> {% trans "Delete User Profile" %}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,59 @@
|
||||
{% extends "accounts/user_settings_base.html" %}
|
||||
{% load i18n %}{% load bootstrap %}
|
||||
|
||||
{% block title %}{% trans 'Account settings' %}{% endblock %}
|
||||
|
||||
{% block settings_panel %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{% trans 'Change password' %}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" role="form" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form|bootstrap_horizontal:"col-sm-3 col-lg-3" }}
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-3 col-sm-8">
|
||||
<input type="submit" class="btn btn-primary" value="{% trans 'Change my password' %}" /> <a href="{% url 'django.contrib.auth.views.password_reset' %}">{% trans 'Forgot your password?' %}</a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{% trans 'Social Auth' %}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<h3>{% trans "Associate with remote Account" %}</h3>
|
||||
{% for backend in backends.not_associated %}
|
||||
<form method="get" action="{% url 'social:begin' backend %}"
|
||||
style="display: inline-block;">
|
||||
<button type="submit" class="btn btn-xs btn-success">{{ backend }}</button>
|
||||
</form>
|
||||
{% endfor %}
|
||||
<h3>{% trans "Disassociate from remote Account" %}</h3>
|
||||
{% for socauth in backends.associated %}
|
||||
<form method="post" action="{% url 'social:disconnect_individual' socauth.provider socauth.pk %}"
|
||||
style="display: inline-block;">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-xs btn-danger">{{ socauth.provider }}</button>
|
||||
</form>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-danger">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{% trans "Delete account" %}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<p>{% blocktrans trimmed %}
|
||||
If you'ld like to stop using this service and delete this user profile and
|
||||
all your data (especially all hosts and all domains created by this user),
|
||||
you can do it here.
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
<a class="btn btn-danger" href="{% url 'account_delete' %}"><i class="fa fa-exclamation-triangle"></i> {% trans "Delete User Profile" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
22
nsupdate/accounts/templates/accounts/user_settings_base.html
Normal file
22
nsupdate/accounts/templates/accounts/user_settings_base.html
Normal file
@ -0,0 +1,22 @@
|
||||
{% extends "base.html" %}
|
||||
{% load i18n %}{% load bootstrap %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Personal settings</h3>
|
||||
</div>
|
||||
<div class="list-group">
|
||||
<a href="{% url 'account_profile' %}" class="list-group-item">Profile</a>
|
||||
<a href="{% url 'account_settings' %}" class="list-group-item">Account settings</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
{% block settings_panel %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,24 @@
|
||||
{% extends "accounts/user_settings_base.html" %}
|
||||
{% load i18n %}{% load bootstrap %}
|
||||
|
||||
{% block title %}{% trans 'Profile settings' %}{% endblock %}
|
||||
|
||||
{% block settings_panel %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{% trans 'Profile' %}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<form class="form-horizontal" role="form" method="post">
|
||||
{% csrf_token %}
|
||||
{{ userform|bootstrap_horizontal:"col-sm-3 col-lg-3" }}
|
||||
{{ profileform|bootstrap_horizontal:"col-sm-3 col-lg-3" }}
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-3 col-sm-9">
|
||||
<input type="submit" class="btn btn-primary" value="{% trans "Submit" %}" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -5,13 +5,15 @@ from django.views.generic.base import TemplateView
|
||||
from registration.backends.default.views import ActivationView
|
||||
from registration.backends.default.views import RegistrationView
|
||||
|
||||
from .views import UserProfileView, DeleteUserView
|
||||
from .views import UserProfileView, DeleteUserView, UserChangePasswordView
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^profile/', UserProfileView.as_view(), name="account_profile"),
|
||||
url(r'^settings/', UserChangePasswordView.as_view(), name='account_settings'),
|
||||
url(r'^delete/', DeleteUserView.as_view(), name="account_delete"),
|
||||
|
||||
# registration start
|
||||
url(r'^activate/complete/$',
|
||||
TemplateView.as_view(template_name='registration/activation_complete.html'),
|
||||
|
@ -1,18 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.views.generic import TemplateView
|
||||
from django.views.generic import TemplateView, FormView
|
||||
from django.contrib.auth import logout
|
||||
from django.contrib.auth.forms import PasswordChangeForm
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.views.decorators.csrf import csrf_protect
|
||||
from django.views.decorators.debug import sensitive_post_parameters
|
||||
from django.core.urlresolvers import reverse, reverse_lazy
|
||||
from django.shortcuts import redirect
|
||||
from django.contrib import messages
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.contrib.auth import update_session_auth_hash
|
||||
|
||||
from .forms import UserForm, UserProfileForm
|
||||
from .models import UserProfile
|
||||
|
||||
|
||||
class UserProfileView(TemplateView):
|
||||
template_name = "accounts/user_profile.html"
|
||||
template_name = "accounts/user_settings_profile.html"
|
||||
|
||||
@method_decorator(login_required)
|
||||
def dispatch(self, *args, **kwargs):
|
||||
@ -42,6 +48,31 @@ class UserProfileView(TemplateView):
|
||||
return self.render_to_response(context)
|
||||
|
||||
|
||||
class UserChangePasswordView(FormView):
|
||||
form_class = PasswordChangeForm
|
||||
success_url = reverse_lazy('account_settings')
|
||||
template_name = 'accounts/user_settings_account.html'
|
||||
|
||||
@method_decorator(login_required)
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(UserChangePasswordView, self).dispatch(*args, **kwargs)
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super(UserChangePasswordView, self).get_form_kwargs()
|
||||
kwargs['user'] = self.request.user
|
||||
return kwargs
|
||||
|
||||
def form_valid(self, form):
|
||||
form.save()
|
||||
# Updating the password logs out all other sessions for the user
|
||||
# except the current one if
|
||||
# django.contrib.auth.middleware.SessionAuthenticationMiddleware
|
||||
# is enabled.
|
||||
update_session_auth_hash(self.request, form.user)
|
||||
messages.add_message(self.request, messages.SUCCESS, _('Your password was changed!'))
|
||||
return super(UserChangePasswordView, self).form_valid(form)
|
||||
|
||||
|
||||
class DeleteUserView(TemplateView):
|
||||
template_name = "accounts/delete_user.html"
|
||||
|
||||
|
@ -1,21 +0,0 @@
|
||||
{% extends "registration/registration_base.html" %}
|
||||
{% load i18n %}{% load bootstrap %}
|
||||
{% block title %}{% trans 'Password change' %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>{% trans 'Password change' %}</h2>
|
||||
<hr />
|
||||
<p>{% trans "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." %}</p>
|
||||
<div class="col-md-7">
|
||||
<form class="form-horizontal" role="form" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form|bootstrap_horizontal:"col-sm-4 col-lg-4" }}
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-4 col-sm-8">
|
||||
<input type="submit" class="btn btn-primary" value="{% trans 'Change my password' %}" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/javascript">document.getElementById("id_old_password").focus();</script>
|
||||
{% endblock %}
|
@ -1,8 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
{% load i18n %}{% load bootstrap %}
|
||||
{% block title %}{% trans 'Password change successful' %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>{% trans 'Password change successful' %}</h2>
|
||||
<p>{% trans 'Your password was changed.' %}</p>
|
||||
{% endblock %}
|
@ -18,10 +18,4 @@ urlpatterns = patterns(
|
||||
{'template_name': 'password_reset_confirm.html'}, name='password_reset_confirm'),
|
||||
url(r'^password_reset_complete/$', 'django.contrib.auth.views.password_reset_complete',
|
||||
{'template_name': 'password_reset_complete.html'}, name='password_reset_complete'),
|
||||
|
||||
# password change urls
|
||||
url(r'^password_change/$', 'django.contrib.auth.views.password_change',
|
||||
{'template_name': 'password_change.html'}, name='password_change'),
|
||||
url(r'^password_change_done/$', 'django.contrib.auth.views.password_change_done',
|
||||
{'template_name': 'password_change_done.html'}, name='password_change_done'),
|
||||
)
|
||||
|
@ -64,7 +64,7 @@
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user fa-fw"></i> {{ request.user.username }} <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{% url 'account_profile' %}"><i class="fa fa-cogs fa-fw"></i> {% trans 'Profile' %}</a></li>
|
||||
<li><a href="{% url 'django.contrib.auth.views.password_change' %}"><i class="fa fa-key fa-fw"></i> {% trans 'Password change' %}</a></li>
|
||||
<li><a href="{% url 'account_settings' %}"><i class="fa fa-key fa-fw"></i> {% trans 'Password change' %}</a></li>
|
||||
{% if request.user.is_staff %}
|
||||
<li><a href="{% url 'admin:index' %}"><i class="fa fa-wrench fa-fw"></i> {% trans 'Admin interface' %}</a></li>
|
||||
{% endif %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user