diff --git a/openslides/participant/models.py b/openslides/participant/models.py
index 39b0da215..f833f3bd7 100644
--- a/openslides/participant/models.py
+++ b/openslides/participant/models.py
@@ -37,7 +37,7 @@ class OpenSlidesUser(models.Model, PersonMixin):
user = models.OneToOneField(User, unique=True, editable=False)
category = models.CharField(
- max_length=100, null=True, blank=True, verbose_name=_("Name Surfix"),
+ max_length=100, null=True, blank=True, verbose_name=_("Category"),
help_text=_('Shown behind the name.'))
gender = models.CharField(
max_length=50, choices=GENDER_CHOICES, blank=True,
@@ -140,6 +140,7 @@ class OpenSlidesGroup(models.Model, PersonMixin):
group = models.OneToOneField(Group)
group_as_person = models.BooleanField(default=False)
+ description = models.TextField(blank=True)
def __unicode__(self):
return unicode(self.group)
@@ -193,4 +194,10 @@ def default_config(sender, key, **kwargs):
@receiver(signals.post_save, sender=User)
def user_post_save(sender, instance, signal, *args, **kwargs):
# Creates OpenSlidesUser
- profile, new = OpenSlidesUser.objects.get_or_create(user=instance)
+ openslidesuser, new = OpenSlidesUser.objects.get_or_create(user=instance)
+
+
+@receiver(signals.post_save, sender=Group)
+def group_post_save(sender, instance, signal, *args, **kwargs):
+ # Creates OpenSlidesGroup
+ openslidesgroup, new = OpenSlidesGroup.objects.get_or_create(group=instance)
diff --git a/openslides/participant/templates/participant/overview.html b/openslides/participant/templates/participant/overview.html
index f068dd69c..3cd529af4 100644
--- a/openslides/participant/templates/participant/overview.html
+++ b/openslides/participant/templates/participant/overview.html
@@ -8,99 +8,105 @@
{% block header %}
{% if perms.agenda.can_manage_agenda %}
-
-
+
+
{% endif %}
{% endblock %}
+
{% block content %}
{% trans "Participants" %}
-
- {% if users|length == allusers|length %}
- {{ users|length }}
- {% blocktrans count counter=users|length %}participant{% plural %}participants{% endblocktrans %}
+ {% if users.count == allusers %}
+ {{ users.count }}
+ {% blocktrans count counter=users.count %}participant{% plural %}participants{% endblocktrans %}
{% else %}
- {{ users|length }} {% trans "of" %} {{ allusers|length }} {% trans "Participants" %} (= {{ percent }} %)
+ {{ users.count }} {% trans "of" %} {{ allusers }} {% trans "Participants" %} (= {{ percent }} %)
{% endif %}
{% trans "First Name" %} |
{% trans "Last Name" %} |
- {% trans "Group" %} |
+ {% trans "Category" %} |
{% trans "Type" %} |
{% trans "Committee" %} |
{% if perms.participant.can_manage_participant %}
- {% trans "Comment" %} |
- {% trans "Last Login" %} |
- {% trans "Actions" %} |
+ {% trans "Comment" %} |
+ {% trans "Last Login" %} |
+ {% trans "Actions" %} |
{% endif %}
- {% for user in users %}
-
- {{ user.first_name }} |
- {{ user.last_name }} |
- {{ user.openslidesuser.name_surfix }} |
- {{ user.openslidesuser.get_type_display }} |
- {{ user.openslidesuser.committee }} |
- {% if perms.participant.can_manage_participant %}
- {{ user.openslidesuser.comment|first_line }} |
- {% if user.last_login > user.date_joined %}
- {{ user.last_login }}
- {% endif %} |
-
-
-
-
-
-
-
- |
- {% endif %}
-
- {% empty %}
-
- {% trans "No participants available." %} |
-
- {% endfor %}
+ {% for user in users %}
+
+ {{ user.first_name }} |
+ {{ user.last_name }} |
+ {{ user.openslidesuser.category }} |
+ {{ user.openslidesuser.get_type_display }} |
+ {{ user.openslidesuser.committee }} |
+ {% if perms.participant.can_manage_participant %}
+ {{ user.openslidesuser.comment|first_line }} |
+
+ {% if user.last_login > user.date_joined %}
+ {{ user.last_login }}
+ {% endif %}
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+ {% endif %}
+
+ {% empty %}
+
+ {% trans "No participants available." %} |
+
+ {% endfor %}
{% endblock %}
diff --git a/openslides/participant/urls.py b/openslides/participant/urls.py
index e0245d575..2786161bb 100644
--- a/openslides/participant/urls.py
+++ b/openslides/participant/urls.py
@@ -13,12 +13,12 @@
from django.conf.urls.defaults import url, patterns
from django.core.urlresolvers import reverse
-from openslides.participant.views import (ParticipantsListPDF,
- ParticipantsPasswordsPDF)
+from openslides.participant.views import (
+ ParticipantsListPDF, ParticipantsPasswordsPDF, Overview)
urlpatterns = patterns('openslides.participant.views',
url(r'^$',
- 'get_overview',
+ Overview.as_view(),
name='user_overview',
),
diff --git a/openslides/participant/views.py b/openslides/participant/views.py
index 3fd5f6a55..7299398c2 100644
--- a/openslides/participant/views.py
+++ b/openslides/participant/views.py
@@ -43,7 +43,7 @@ from openslides.utils.template import Tab
from openslides.utils.utils import (
template, permission_required, gen_confirm_form, ajax_request, decodedict,
encodedict, delete_default_permissions, html_strong)
-from openslides.utils.views import FormView, PDFView
+from openslides.utils.views import FormView, PDFView, TemplateView
from openslides.config.models import config
@@ -54,96 +54,89 @@ from openslides.participant.forms import (
UserImportForm, GroupForm, AdminPasswordChangeForm, ConfigForm)
-@permission_required('participant.can_see_participant')
-@template('participant/overview.html')
-def get_overview(request):
+class Overview(TemplateView):
"""
- Show all users.
+ Show all participants.
"""
- try:
- sortfilter = encodedict(parse_qs(
- request.COOKIES['participant_sortfilter']))
- except KeyError:
- sortfilter = {}
+ permission_required = 'participant.can_see_participant'
+ template_name = 'participant/overview.html'
- for value in [u'gender', u'group', u'type', u'committee', u'status',
- u'sort', u'reverse']:
- if value in request.REQUEST:
- if request.REQUEST[value] == '---':
- try:
- del sortfilter[value]
- except KeyError:
- pass
- else:
- sortfilter[value] = [request.REQUEST[value]]
-
- query = User.objects
- if 'gender' in sortfilter:
- query = query.filter(
- openslidesuser__gender__iexact=sortfilter['gender'][0])
- if 'group' in sortfilter:
- query = query.filter(
- openslidesuser__name_surfix__iexact=sortfilter['group'][0])
- if 'type' in sortfilter:
- query = query.filter(
- openslidesuser__type__iexact=sortfilter['type'][0])
- if 'committee' in sortfilter:
- query = query.filter(
- openslidesuser__committee__iexact=sortfilter['committee'][0])
- if 'status' in sortfilter:
- query = query.filter(is_active=sortfilter['status'][0])
- if 'sort' in sortfilter:
- if sortfilter['sort'][0] in ['first_name', 'last_name', 'last_login']:
- query = query.order_by(sortfilter['sort'][0])
- elif (sortfilter['sort'][0] in
- ['name_surfix', 'type', 'committee', 'comment']):
- query = query.order_by(
- 'openslidesuser__%s' % sortfilter['sort'][0])
- else:
- query = query.order_by('last_name')
- if 'reverse' in sortfilter:
- query = query.reverse()
-
- # list of filtered users
- userlist = query.all()
- users = []
- for user in userlist:
+ def get_context_data(self, **kwargs):
+ context = super(Overview, self).get_context_data(**kwargs)
try:
- user.openslidesuser
- except OpenSlidesUser.DoesNotExist:
- pass
+ sortfilter = encodedict(parse_qs(
+ self.request.COOKIES['participant_sortfilter']))
+ except KeyError:
+ sortfilter = {}
+
+ for value in [u'gender', u'category', u'type', u'committee', u'status',
+ u'sort', u'reverse']:
+ if value in self.request.REQUEST:
+ if self.request.REQUEST[value] == '---':
+ try:
+ del sortfilter[value]
+ except KeyError:
+ pass
+ else:
+ sortfilter[value] = [self.request.REQUEST[value]]
+
+ query = User.objects
+ if 'gender' in sortfilter:
+ query = query.filter(
+ openslidesuser__gender__iexact=sortfilter['gender'][0])
+ if 'category' in sortfilter:
+ query = query.filter(
+ openslidesuser__category__iexact=sortfilter['category'][0])
+ if 'type' in sortfilter:
+ query = query.filter(
+ openslidesuser__type__iexact=sortfilter['type'][0])
+ if 'committee' in sortfilter:
+ query = query.filter(
+ openslidesuser__committee__iexact=sortfilter['committee'][0])
+ if 'status' in sortfilter:
+ query = query.filter(is_active=sortfilter['status'][0])
+ if 'sort' in sortfilter:
+ if sortfilter['sort'][0] in ['first_name', 'last_name', 'last_login']:
+ query = query.order_by(sortfilter['sort'][0])
+ elif (sortfilter['sort'][0] in
+ ['category', 'type', 'committee', 'comment']):
+ query = query.order_by(
+ 'openslidesuser__%s' % sortfilter['sort'][0])
else:
- users.append(user)
- # list of all existing users
- allusers = []
- for user in User.objects.all():
- try:
- user.openslidesuser
- except OpenSlidesUser.DoesNotExist:
- pass
+ query = query.order_by('last_name')
+
+ if 'reverse' in sortfilter:
+ query = query.reverse()
+
+ # list of filtered users
+ users = query.all()
+
+ # list of all existing users
+ all_users = User.objects.count()
+
+ # quotient of selected users and all users
+ if all_users > 0:
+ percent = float(len(users)) * 100 / float(all_users)
else:
- allusers.append(user)
- # quotient of selected users and all users
- if len(allusers) > 0:
- percent = float(len(users)) * 100 / float(len(allusers))
- else:
- percent = 0
- # list of all existing groups
- groups = [p['name_surfix'] for p in OpenSlidesUser.objects.values('name_surfix')
- .exclude(name_surfix='').distinct()]
- # list of all existing committees
- committees = [p['committee'] for p in OpenSlidesUser.objects.values('committee')
- .exclude(committee='').distinct()]
- return {
- 'users': users,
- 'allusers': allusers,
- 'percent': round(percent, 1),
- 'groups': groups,
- 'committees': committees,
- 'cookie': ['participant_sortfilter', urlencode(decodedict(sortfilter),
- doseq=True)],
- 'sortfilter': sortfilter,
- }
+ percent = 0
+
+ # list of all existing categories
+ categories = [p['category'] for p in OpenSlidesUser.objects.values('category')
+ .exclude(category='').distinct()]
+
+ # list of all existing committees
+ committees = [p['committee'] for p in OpenSlidesUser.objects.values('committee')
+ .exclude(committee='').distinct()]
+ context.update({
+ 'users': users,
+ 'allusers': all_users,
+ 'percent': round(percent, 1),
+ 'categories': categories,
+ 'committees': committees,
+ 'cookie': ['participant_sortfilter', urlencode(decodedict(sortfilter),
+ doseq=True)],
+ 'sortfilter': sortfilter})
+ return context
@permission_required('participant.can_manage_participant')