From 4b9767b09ee818b011c9aa448b880cad0e19d8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Thu, 30 Jun 2016 13:06:23 +0200 Subject: [PATCH 1/3] Added new user field is_committee and new default group Committees. --- CHANGELOG | 3 +++ .../migrations/0002_user_is_committee.py | 20 +++++++++++++++++++ openslides/users/models.py | 3 +++ openslides/users/serializers.py | 2 ++ openslides/users/signals.py | 15 +++++++++++--- openslides/users/static/js/users/site.js | 19 ++++++++++++++---- .../static/templates/users/user-import.html | 6 +++++- 7 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 openslides/users/migrations/0002_user_is_committee.py diff --git a/CHANGELOG b/CHANGELOG index a061132aa..5fe6c749e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -18,6 +18,9 @@ Core: Motions: - Added origin field. +Users: +- Added field is_committee and new default group Committees. + Other: - Removed config cache to support multiple threads or processes. - Fixed bug, that the last change of a config value was not send via autoupdate. diff --git a/openslides/users/migrations/0002_user_is_committee.py b/openslides/users/migrations/0002_user_is_committee.py new file mode 100644 index 000000000..288b82010 --- /dev/null +++ b/openslides/users/migrations/0002_user_is_committee.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-06-30 12:41 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='is_committee', + field=models.BooleanField(default=False), + ), + ] diff --git a/openslides/users/models.py b/openslides/users/models.py index 3fdb3295c..d81ee67b3 100644 --- a/openslides/users/models.py +++ b/openslides/users/models.py @@ -143,6 +143,9 @@ class User(RESTModelMixin, PermissionsMixin, AbstractBaseUser): is_present = models.BooleanField( default=False) + is_committee = models.BooleanField( + default=False) + objects = UserManager() class Meta: diff --git a/openslides/users/serializers.py b/openslides/users/serializers.py index 22c5b4dce..269d2ce56 100644 --- a/openslides/users/serializers.py +++ b/openslides/users/serializers.py @@ -20,6 +20,7 @@ USERSHORTSERIALIZER_FIELDS = ( 'structure_level', 'about_me', 'groups', + 'is_committee', ) @@ -62,6 +63,7 @@ class UserFullSerializer(ModelSerializer): 'groups', 'default_password', 'is_active', + 'is_committee', ) def validate(self, data): diff --git a/openslides/users/signals.py b/openslides/users/signals.py index 8192fa28e..52486fbe3 100644 --- a/openslides/users/signals.py +++ b/openslides/users/signals.py @@ -6,12 +6,13 @@ from .models import Group, User def create_builtin_groups_and_admin(**kwargs): """ - Creates the builtin groups: Anonymous, Registered, Delegates and Staff. + Creates the builtin groups: Anonymous, Registered, Delegates, Staff and + Committees. Creates the builtin user: admin. """ - # Check whether the group pks 1 to 4 are free - if Group.objects.filter(pk__in=range(1, 5)).exists(): + # Check whether the group pk's 1 to 5 are free. + if Group.objects.filter(pk__in=range(1, 6)).exists(): # Do completely nothing if there are already some of our groups in the database. return @@ -104,5 +105,13 @@ def create_builtin_groups_and_admin(**kwargs): group_staff.permissions.add( permission_dict['users.can_see_name']) + # Committees (pk 5) + committees_permissions = ( + permission_dict['mediafiles.can_upload'], + permission_dict['motions.can_create'], + permission_dict['motions.can_support'], ) + group_committee = Group.objects.create(name='Committees', pk=5) + group_committee.permissions.add(*committees_permissions) + # Create or reset admin user User.objects.create_or_reset_admin_user() diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js index a817aa949..33ec7c037 100644 --- a/openslides/users/static/js/users/site.js +++ b/openslides/users/static/js/users/site.js @@ -386,6 +386,16 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) 'active. Unselect this instead of deleting the account.') }, defaultValue: true + }, + { + key: 'is_committee', + type: 'checkbox', + templateOptions: { + label: gettextCatalog.getString('Is a committee'), + description: gettextCatalog.getString( + 'Designates whether this user should be treated as a committee.') + }, + defaultValue: false }]; } }; @@ -801,11 +811,12 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) var element = document.getElementById('downloadLink'); var csvRows = [ // column header line - ['title', 'first_name', 'last_name', 'structure_level', 'groups', 'comment', 'is_active'], + ['title', 'first_name', 'last_name', 'structure_level', 'groups', 'comment', 'is_active', 'is_committee'], // example entries - ['Dr.', 'Max', 'Mustermann', 'Berlin', '"3,4"', 'xyz', '1'], - ['', 'John', 'Doe', 'Washington', '3', 'abc', '1'], - ['', 'Fred', 'Bloggs', 'London', '', '', ''], + ['Dr.', 'Max', 'Mustermann', 'Berlin', '"3,4"', 'xyz', '1', ''], + ['', 'John', 'Doe', 'Washington', '3', 'abc', '1', ''], + ['', 'Fred', 'Bloggs', 'London', '', '', '', ''], + ['', '', 'Executive Board', '', '5', '', '', '1'], ]; var csvString = csvRows.join("%0A"); diff --git a/openslides/users/static/templates/users/user-import.html b/openslides/users/static/templates/users/user-import.html index 33cf78d55..835e6d617 100644 --- a/openslides/users/static/templates/users/user-import.html +++ b/openslides/users/static/templates/users/user-import.html @@ -68,10 +68,11 @@

Please note: