From 015dc159edcc7db96ffa7a9d30388e4508fdf8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Sat, 27 Oct 2012 18:17:22 +0200 Subject: [PATCH] Add UserView and GroupView part 1 --- .../templates/participant/group_detail.html | 9 +++++ .../templates/participant/user_detail.html | 9 +++++ openslides/participant/urls.py | 40 +++++++++++++------ openslides/participant/views.py | 21 ++++++++-- 4 files changed, 63 insertions(+), 16 deletions(-) create mode 100644 openslides/participant/templates/participant/group_detail.html create mode 100644 openslides/participant/templates/participant/user_detail.html diff --git a/openslides/participant/templates/participant/group_detail.html b/openslides/participant/templates/participant/group_detail.html new file mode 100644 index 000000000..770380218 --- /dev/null +++ b/openslides/participant/templates/participant/group_detail.html @@ -0,0 +1,9 @@ +{% extends "participant/base_participant.html" %} + +{% block title %}{{ block.super }} – {{ object }}{% endblock %} + +{% block content %} + +{{ object }} + +{% endblock %} diff --git a/openslides/participant/templates/participant/user_detail.html b/openslides/participant/templates/participant/user_detail.html new file mode 100644 index 000000000..770380218 --- /dev/null +++ b/openslides/participant/templates/participant/user_detail.html @@ -0,0 +1,9 @@ +{% extends "participant/base_participant.html" %} + +{% block title %}{{ block.super }} – {{ object }}{% endblock %} + +{% block content %} + +{{ object }} + +{% endblock %} diff --git a/openslides/participant/urls.py b/openslides/participant/urls.py index f55c30756..ed98c45c5 100644 --- a/openslides/participant/urls.py +++ b/openslides/participant/urls.py @@ -14,14 +14,16 @@ from django.conf.urls.defaults import url, patterns from django.core.urlresolvers import reverse from openslides.participant.views import ( - ParticipantsListPDF, ParticipantsPasswordsPDF, Overview, UserCreateView, - UserUpdateView, UserDeleteView, SetUserStatusView, UserImportView, - ResetPasswordView, GroupOverviewView, GroupCreateView, GroupUpdateView, - GroupDeleteView) + UserOverview, UserCreateView, UserDetailView, UserUpdateView, + UserDeleteView, ResetPasswordView, SetUserStatusView, UserImportView, + GroupOverview, GroupCreateView, GroupDetailView, GroupUpdateView, GroupDeleteView, + ParticipantsListPDF, ParticipantsPasswordsPDF) -urlpatterns = patterns('openslides.participant.views', +urlpatterns = patterns('', + + # User url(r'^$', - Overview.as_view(), + UserOverview.as_view(), name='user_overview', ), @@ -30,6 +32,11 @@ urlpatterns = patterns('openslides.participant.views', name='user_new', ), + url(r'^(?P\d+)/$', + UserDetailView.as_view(), + name='user_detail', + ), + url(r'^(?P\d+)/edit/$', UserUpdateView.as_view(), name='user_edit', @@ -45,12 +52,6 @@ urlpatterns = patterns('openslides.participant.views', name='user_reset_password', ), - url(r'^(?P\d+)/status/toggle/$', - SetUserStatusView.as_view(), - {'action': 'toggle'}, - name='user_status_toggle', - ), - url(r'^(?P\d+)/status/activate/$', SetUserStatusView.as_view(), {'action': 'activate'}, @@ -63,13 +64,20 @@ urlpatterns = patterns('openslides.participant.views', name='user_status_deactivate', ), + url(r'^(?P\d+)/status/toggle/$', + SetUserStatusView.as_view(), + {'action': 'toggle'}, + name='user_status_toggle', + ), + url(r'^import/$', UserImportView.as_view(), name='user_import', ), + # Group url(r'^group/$', - GroupOverviewView.as_view(), + GroupOverview.as_view(), name='user_group_overview', ), @@ -78,6 +86,11 @@ urlpatterns = patterns('openslides.participant.views', name='user_group_new', ), + url(r'^group/(?P\d+)/$', + GroupDetailView.as_view(), + name='user_group_detail', + ), + url(r'^group/(?P\d+)/edit/$', GroupUpdateView.as_view(), name='user_group_edit', @@ -88,6 +101,7 @@ urlpatterns = patterns('openslides.participant.views', name='user_group_delete', ), + # PDF url(r'^print/$', ParticipantsListPDF.as_view(), name='user_print', diff --git a/openslides/participant/views.py b/openslides/participant/views.py index 12fe213fc..4fa817128 100644 --- a/openslides/participant/views.py +++ b/openslides/participant/views.py @@ -56,7 +56,7 @@ from openslides.participant.forms import ( from openslides.participant.models import User, Group -class Overview(ListView): +class UserOverview(ListView): """ Show all participants (users). """ @@ -112,7 +112,7 @@ class Overview(ListView): return query.all() def get_context_data(self, **kwargs): - context = super(Overview, self).get_context_data(**kwargs) + context = super(UserOverview, self).get_context_data(**kwargs) all_users = User.objects.count() @@ -140,6 +140,21 @@ class Overview(ListView): return context +from django.views.generic.detail import DetailView +class UserDetailView(DetailView): + """ + Classed based view to show a specific user in the interface. + """ + model = User + + +class GroupDetailView(DetailView): + """ + Classed based view to show a specific group in the interface. + """ + model = Group + + class UserCreateView(CreateView): """ Create a new participant. @@ -354,7 +369,7 @@ class ResetPasswordView(RedirectView, SingleObjectMixin, QuestionMixin): return reverse('user_reset_password', args=[self.object.id]) -class GroupOverviewView(ListView): +class GroupOverview(ListView): """ Overview over all groups. """