summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--uauth/organization/forms.py9
-rw-r--r--uauth/organization/tables.py2
-rw-r--r--uauth/organization/templates/organization/edit_user.html18
-rw-r--r--uauth/organization/templates/organization/user.html9
-rw-r--r--uauth/organization/templates/organization/view_user.html15
-rw-r--r--uauth/organization/urls.py2
-rw-r--r--uauth/organization/views.py31
-rw-r--r--uauth/static/css/style.css15
8 files changed, 98 insertions, 3 deletions
diff --git a/uauth/organization/forms.py b/uauth/organization/forms.py
index 661283e..90c13e2 100644
--- a/uauth/organization/forms.py
+++ b/uauth/organization/forms.py
@@ -14,6 +14,15 @@ class LocalAccountForm(forms.ModelForm):
'password': forms.PasswordInput
}
+ def save(self):
+ # save previous password
+ old_password = self.initial.get('password')
+ obj = super(LocalAccountForm, self).save(commit=False)
+ if not self.cleaned_data.get('password'):
+ obj.password = old_password
+ obj.save()
+ return obj
+
class LocalAccountCreateForm(LocalAccountForm):
accounts_number = forms.IntegerField(_('Number of accounts to create'), required=False)
diff --git a/uauth/organization/tables.py b/uauth/organization/tables.py
index bcd03ab..611e41c 100644
--- a/uauth/organization/tables.py
+++ b/uauth/organization/tables.py
@@ -6,7 +6,7 @@ from .models import LocalAccount
class AccountTable(tables.Table):
username = tables.TemplateColumn(
- '<a rel="popup" href="#" %}">{{ record.username }}</a>',
+ '<a href="{% url "edit-user" organization.slug record.pk %}" rel="popup"><i class="icon-edit"></i></a><a href="{% url "view-user" organization.slug record.pk %}">{{ record.username }}</a>',
verbose_name=_('Username'))
class Meta:
diff --git a/uauth/organization/templates/organization/edit_user.html b/uauth/organization/templates/organization/edit_user.html
new file mode 100644
index 0000000..6e4e264
--- /dev/null
+++ b/uauth/organization/templates/organization/edit_user.html
@@ -0,0 +1,18 @@
+{% extends "organization/base.html" %}
+{% load i18n %}
+
+{% block content %}
+<form method="post" autocomplete="off">
+ {% csrf_token %}
+ <table>
+ {{ form.as_table }}
+ </table>
+ <div class="form-actions">
+ <input type="submit" value="{% trans "Update" %}" class="btn btn-primary" />
+ <button name="delete" class="ui-state-default delete-button icon-delete">{% trans "Delete" %}</button>
+ </div>
+ <script>
+ $('input.datepicker').datepicker({dateFormat: "yy-mm-dd", weekStart: 1 });
+ </script>
+</form>
+{% endblock %}
diff --git a/uauth/organization/templates/organization/user.html b/uauth/organization/templates/organization/user.html
new file mode 100644
index 0000000..465fd27
--- /dev/null
+++ b/uauth/organization/templates/organization/user.html
@@ -0,0 +1,9 @@
+{% load i18n %}
+
+<div class="user">
+ <h3>{% trans "Login" %} {{ user.username }} {% if user.get_fullname %}({{ user.get_fullname }}){% endif %}</h3>
+ <h4>{% trans "Password:" %} {{ user.password }}</h4>
+ <p class="expire">{% trans "Expiring:" %} {% if user.expiration_date %}{{ user.expiration_date|date:"DATETIME_FORMAT" }}{% else %}{% trans "never" %}{% endif %}</p>
+ <p><strong>{% trans "Description" %}</strong></p>
+ <p>{{ user.description }}</p>
+</div>
diff --git a/uauth/organization/templates/organization/view_user.html b/uauth/organization/templates/organization/view_user.html
new file mode 100644
index 0000000..31dd32f
--- /dev/null
+++ b/uauth/organization/templates/organization/view_user.html
@@ -0,0 +1,15 @@
+{% extends "organization/base.html" %}
+{% load i18n %}
+
+{% block page-title %}
+{% trans 'User details' %}
+{% endblock %}
+
+{% block appbar %}
+<h2>{% trans "User details" %}</h2>
+{% endblock %}
+
+{% block content %}
+{% include "organization/user.html" with user=object %}
+{% endblock %}
+
diff --git a/uauth/organization/urls.py b/uauth/organization/urls.py
index ed4d1d8..9697a1f 100644
--- a/uauth/organization/urls.py
+++ b/uauth/organization/urls.py
@@ -6,4 +6,6 @@ urlpatterns = patterns('',
url(r'^$', manage, name='manage'),
url(r'^users/?$', users, name='manage-users'),
url(r'^users/create$', create_users, name='create-users'),
+ url(r'^users/(?P<pk>[\w]+)/$', view_user, name='view-user'),
+ url(r'^users/(?P<pk>[\w]+)/edit$', edit_user, name='edit-user'),
)
diff --git a/uauth/organization/views.py b/uauth/organization/views.py
index 3175cd6..adae5e7 100644
--- a/uauth/organization/views.py
+++ b/uauth/organization/views.py
@@ -1,16 +1,18 @@
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse_lazy
+from django.http import HttpResponseRedirect
from django.views.generic.base import TemplateView
from django.views.generic.list import ListView
-from django.views.generic.edit import FormView
+from django.views.generic.edit import FormView, UpdateView
+from django.views.generic import DetailView
from django.contrib import messages
from django_tables2 import RequestConfig
from .utils import create_user
from .models import LocalAccount, Organization
-from .forms import LocalAccountCreateForm
+from .forms import LocalAccountCreateForm, LocalAccountForm
from .tables import AccountTable
@@ -75,3 +77,28 @@ class UsersCreateView(OrganizationMixin, FormView):
return super(UsersCreateView, self).form_valid(form)
create_users = UsersCreateView.as_view()
+
+
+class ShowUserView(OrganizationMixin, DetailView):
+ model = LocalAccount
+ template_name = 'organization/view_user.html'
+
+view_user = ShowUserView.as_view()
+
+
+class UserEditView(OrganizationMixin, UpdateView):
+ template_name = 'organization/edit_user.html'
+ model = LocalAccount
+ form_class = LocalAccountForm
+
+ def form_valid(self, form):
+ username = self.object.username
+ if 'delete' in self.request.POST:
+ self.object.delete()
+ messages.info(self.request, _('Account "%s" successfully deleted' % username))
+ return HttpResponseRedirect(self.get_success_url())
+ else:
+ messages.info(self.request, _('Account "%s" successfully updated' % username))
+ return super(UserEditView, self).form_valid(form)
+
+edit_user = UserEditView.as_view()
diff --git a/uauth/static/css/style.css b/uauth/static/css/style.css
index e3b1b46..de28ea0 100644
--- a/uauth/static/css/style.css
+++ b/uauth/static/css/style.css
@@ -46,4 +46,19 @@ ul.login li, #guest-login ul li, #voucher-login ul li, .loginbox li {
padding: 5px;
color: #fff;
background: #999;
+}
+
+.user {
+ border: 2px solid #aaa;
+ padding: 5px;
+}
+
+.icon-edit:before {
+ content: '\f044';
+ margin: 0 3px;
+}
+
+.icon-delete:before {
+ content: '\f1f8';
+ margin: 0 3px;
} \ No newline at end of file