Add UserView and GroupView part 1

This commit is contained in:
Norman Jäckel 2012-10-27 18:17:22 +02:00
parent 3f0c31d12b
commit 015dc159ed
4 changed files with 63 additions and 16 deletions

View File

@ -0,0 +1,9 @@
{% extends "participant/base_participant.html" %}
{% block title %}{{ block.super }} {{ object }}{% endblock %}
{% block content %}
{{ object }}
{% endblock %}

View File

@ -0,0 +1,9 @@
{% extends "participant/base_participant.html" %}
{% block title %}{{ block.super }} {{ object }}{% endblock %}
{% block content %}
{{ object }}
{% endblock %}

View File

@ -14,14 +14,16 @@ from django.conf.urls.defaults import url, patterns
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from openslides.participant.views import ( from openslides.participant.views import (
ParticipantsListPDF, ParticipantsPasswordsPDF, Overview, UserCreateView, UserOverview, UserCreateView, UserDetailView, UserUpdateView,
UserUpdateView, UserDeleteView, SetUserStatusView, UserImportView, UserDeleteView, ResetPasswordView, SetUserStatusView, UserImportView,
ResetPasswordView, GroupOverviewView, GroupCreateView, GroupUpdateView, GroupOverview, GroupCreateView, GroupDetailView, GroupUpdateView, GroupDeleteView,
GroupDeleteView) ParticipantsListPDF, ParticipantsPasswordsPDF)
urlpatterns = patterns('openslides.participant.views', urlpatterns = patterns('',
# User
url(r'^$', url(r'^$',
Overview.as_view(), UserOverview.as_view(),
name='user_overview', name='user_overview',
), ),
@ -30,6 +32,11 @@ urlpatterns = patterns('openslides.participant.views',
name='user_new', name='user_new',
), ),
url(r'^(?P<pk>\d+)/$',
UserDetailView.as_view(),
name='user_detail',
),
url(r'^(?P<pk>\d+)/edit/$', url(r'^(?P<pk>\d+)/edit/$',
UserUpdateView.as_view(), UserUpdateView.as_view(),
name='user_edit', name='user_edit',
@ -45,12 +52,6 @@ urlpatterns = patterns('openslides.participant.views',
name='user_reset_password', name='user_reset_password',
), ),
url(r'^(?P<pk>\d+)/status/toggle/$',
SetUserStatusView.as_view(),
{'action': 'toggle'},
name='user_status_toggle',
),
url(r'^(?P<pk>\d+)/status/activate/$', url(r'^(?P<pk>\d+)/status/activate/$',
SetUserStatusView.as_view(), SetUserStatusView.as_view(),
{'action': 'activate'}, {'action': 'activate'},
@ -63,13 +64,20 @@ urlpatterns = patterns('openslides.participant.views',
name='user_status_deactivate', name='user_status_deactivate',
), ),
url(r'^(?P<pk>\d+)/status/toggle/$',
SetUserStatusView.as_view(),
{'action': 'toggle'},
name='user_status_toggle',
),
url(r'^import/$', url(r'^import/$',
UserImportView.as_view(), UserImportView.as_view(),
name='user_import', name='user_import',
), ),
# Group
url(r'^group/$', url(r'^group/$',
GroupOverviewView.as_view(), GroupOverview.as_view(),
name='user_group_overview', name='user_group_overview',
), ),
@ -78,6 +86,11 @@ urlpatterns = patterns('openslides.participant.views',
name='user_group_new', name='user_group_new',
), ),
url(r'^group/(?P<pk>\d+)/$',
GroupDetailView.as_view(),
name='user_group_detail',
),
url(r'^group/(?P<pk>\d+)/edit/$', url(r'^group/(?P<pk>\d+)/edit/$',
GroupUpdateView.as_view(), GroupUpdateView.as_view(),
name='user_group_edit', name='user_group_edit',
@ -88,6 +101,7 @@ urlpatterns = patterns('openslides.participant.views',
name='user_group_delete', name='user_group_delete',
), ),
# PDF
url(r'^print/$', url(r'^print/$',
ParticipantsListPDF.as_view(), ParticipantsListPDF.as_view(),
name='user_print', name='user_print',

View File

@ -56,7 +56,7 @@ from openslides.participant.forms import (
from openslides.participant.models import User, Group from openslides.participant.models import User, Group
class Overview(ListView): class UserOverview(ListView):
""" """
Show all participants (users). Show all participants (users).
""" """
@ -112,7 +112,7 @@ class Overview(ListView):
return query.all() return query.all()
def get_context_data(self, **kwargs): 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() all_users = User.objects.count()
@ -140,6 +140,21 @@ class Overview(ListView):
return context 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): class UserCreateView(CreateView):
""" """
Create a new participant. Create a new participant.
@ -354,7 +369,7 @@ class ResetPasswordView(RedirectView, SingleObjectMixin, QuestionMixin):
return reverse('user_reset_password', args=[self.object.id]) return reverse('user_reset_password', args=[self.object.id])
class GroupOverviewView(ListView): class GroupOverview(ListView):
""" """
Overview over all groups. Overview over all groups.
""" """