diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index 517716099..312fc7f89 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -7,7 +7,7 @@ from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models, transaction from django.utils.translation import ugettext as _ -from django.utils.translation import ugettext_lazy, ugettext_noop +from django.utils.translation import ugettext_lazy from openslides.core.config import config from openslides.core.projector import Countdown @@ -266,9 +266,9 @@ class Item(RESTModelMixin, models.Model): class Meta: default_permissions = () permissions = ( - ('can_see', ugettext_noop("Can see agenda")), - ('can_manage', ugettext_noop("Can manage agenda")), - ('can_see_hidden_items', ugettext_noop("Can see hidden items and time scheduling of agenda"))) + ('can_see', 'Can see agenda'), + ('can_manage', 'Can manage agenda'), + ('can_see_hidden_items', 'Can see hidden items and time scheduling of agenda')) unique_together = ('content_type', 'object_id') def __str__(self): @@ -392,7 +392,7 @@ class Speaker(RESTModelMixin, models.Model): class Meta: default_permissions = () permissions = ( - ('can_be_speaker', ugettext_noop('Can put oneself on the list of speakers')), + ('can_be_speaker', 'Can put oneself on the list of speakers'), ) def __str__(self): diff --git a/openslides/assignments/models.py b/openslides/assignments/models.py index b4e56e74e..4b448f2a8 100644 --- a/openslides/assignments/models.py +++ b/openslides/assignments/models.py @@ -109,10 +109,10 @@ class Assignment(RESTModelMixin, models.Model): class Meta: default_permissions = () permissions = ( - ('can_see', ugettext_noop('Can see elections')), - ('can_nominate_other', ugettext_noop('Can nominate another participant')), - ('can_nominate_self', ugettext_noop('Can nominate oneself')), - ('can_manage', ugettext_noop('Can manage elections')), + ('can_see', 'Can see elections'), + ('can_nominate_other', 'Can nominate another participant'), + ('can_nominate_self', 'Can nominate oneself'), + ('can_manage', 'Can manage elections'), ) ordering = ('title', ) verbose_name = ugettext_noop('Election') diff --git a/openslides/assignments/static/js/assignments/base.js b/openslides/assignments/static/js/assignments/base.js index bcd83a9d1..da843f9a8 100644 --- a/openslides/assignments/static/js/assignments/base.js +++ b/openslides/assignments/static/js/assignments/base.js @@ -73,8 +73,7 @@ angular.module('OpenSlidesApp.assignments', []) 'AssignmentPoll', 'jsDataModel', 'gettext', - 'gettextCatalog', - function ($http, DS, AssignmentRelatedUser, AssignmentPoll, jsDataModel, gettext, gettextCatalog) { + function ($http, DS, AssignmentRelatedUser, AssignmentPoll, jsDataModel, gettext) { var name = 'assignments/assignment'; var phases; return DS.defineResource({ diff --git a/openslides/core/models.py b/openslides/core/models.py index 53098c144..e1c129994 100644 --- a/openslides/core/models.py +++ b/openslides/core/models.py @@ -2,7 +2,6 @@ from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.core.urlresolvers import reverse from django.db import models -from django.utils.translation import ugettext_noop from jsonfield import JSONField from openslides.mediafiles.models import Mediafile @@ -64,9 +63,9 @@ class Projector(RESTModelMixin, models.Model): """ default_permissions = () permissions = ( - ('can_see_projector', ugettext_noop('Can see the projector')), - ('can_manage_projector', ugettext_noop('Can manage the projector')), - ('can_see_frontpage', ugettext_noop('Can see the front page'))) + ('can_see_projector', 'Can see the projector'), + ('can_manage_projector', 'Can manage the projector'), + ('can_see_frontpage', 'Can see the front page'),) @property def elements(self): @@ -184,7 +183,7 @@ class Tag(RESTModelMixin, models.Model): ordering = ('name',) default_permissions = () permissions = ( - ('can_manage_tags', ugettext_noop('Can manage tags')),) + ('can_manage_tags', 'Can manage tags'),) def __str__(self): return self.name @@ -204,7 +203,7 @@ class ConfigStore(models.Model): class Meta: default_permissions = () permissions = ( - ('can_manage_config', ugettext_noop('Can manage configuration')),) + ('can_manage_config', 'Can manage configuration'),) def get_root_rest_url(self): """ @@ -230,7 +229,7 @@ class ChatMessage(RESTModelMixin, models.Model): class Meta: default_permissions = () permissions = ( - ('can_use_chat', ugettext_noop('Can use the chat')),) + ('can_use_chat', 'Can use the chat'),) def __str__(self): return 'Message {}'.format(self.timestamp) diff --git a/openslides/mediafiles/models.py b/openslides/mediafiles/models.py index 485319279..d387bdb19 100644 --- a/openslides/mediafiles/models.py +++ b/openslides/mediafiles/models.py @@ -1,7 +1,6 @@ from django.conf import settings from django.db import models from django.utils.translation import ugettext as _ -from django.utils.translation import ugettext_noop from openslides.utils.search import user_name_helper @@ -38,9 +37,9 @@ class Mediafile(RESTModelMixin, models.Model): ordering = ['title'] default_permissions = () permissions = ( - ('can_see', ugettext_noop('Can see the list of files')), - ('can_upload', ugettext_noop('Can upload files')), - ('can_manage', ugettext_noop('Can manage files')),) + ('can_see', 'Can see the list of files'), + ('can_upload', 'Can upload files'), + ('can_manage', 'Can manage files')) def __str__(self): """ diff --git a/openslides/motions/models.py b/openslides/motions/models.py index 6ba4c16f6..29c357dc9 100644 --- a/openslides/motions/models.py +++ b/openslides/motions/models.py @@ -115,10 +115,10 @@ class Motion(RESTModelMixin, models.Model): class Meta: default_permissions = () permissions = ( - ('can_see', ugettext_noop('Can see motions')), - ('can_create', ugettext_noop('Can create motions')), - ('can_support', ugettext_noop('Can support motions')), - ('can_manage', ugettext_noop('Can manage motions')), + ('can_see', 'Can see motions'), + ('can_create', 'Can create motions'), + ('can_support', 'Can support motions'), + ('can_manage', 'Can manage motions'), ) ordering = ('identifier', ) verbose_name = ugettext_noop('Motion') diff --git a/openslides/motions/static/js/motions/base.js b/openslides/motions/static/js/motions/base.js index 3e6671916..6ed8e28a1 100644 --- a/openslides/motions/static/js/motions/base.js +++ b/openslides/motions/static/js/motions/base.js @@ -161,10 +161,9 @@ angular.module('OpenSlidesApp.motions', ['OpenSlidesApp.users']) 'MotionPoll', 'jsDataModel', 'gettext', - 'gettextCatalog', 'operator', 'Config', - function(DS, MotionPoll, jsDataModel, gettext, gettextCatalog, operator, Config) { + function(DS, MotionPoll, jsDataModel, gettext, operator, Config) { var name = 'motions/motion'; return DS.defineResource({ name: name, diff --git a/openslides/users/models.py b/openslides/users/models.py index fa00eede8..dc0ddd529 100644 --- a/openslides/users/models.py +++ b/openslides/users/models.py @@ -8,7 +8,6 @@ from django.contrib.auth.models import ( PermissionsMixin, ) from django.db import models -from django.utils.translation import ugettext_noop from openslides.utils.search import user_name_helper @@ -146,9 +145,9 @@ class User(RESTModelMixin, PermissionsMixin, AbstractBaseUser): class Meta: default_permissions = () permissions = ( - ('can_see_name', ugettext_noop('Can see names of users')), - ('can_see_extra_data', ugettext_noop('Can see extra data of users')), - ('can_manage', ugettext_noop('Can manage users')), + ('can_see_name', 'Can see names of users'), + ('can_see_extra_data', 'Can see extra data of users'), + ('can_manage', 'Can manage users'), ) ordering = ('last_name', 'first_name', 'username', ) diff --git a/openslides/users/static/js/users/base.js b/openslides/users/static/js/users/base.js index 6e82a054b..82430abb4 100644 --- a/openslides/users/static/js/users/base.js +++ b/openslides/users/static/js/users/base.js @@ -148,10 +148,22 @@ angular.module('OpenSlidesApp.users', []) ]) .factory('Group', [ + '$http', 'DS', - function(DS) { + function($http, DS) { + var permissions; return DS.defineResource({ name: 'users/group', + permissions: permissions, + getPermissions: function() { + if (!this.permissions) { + this.permissions = $http({ 'method': 'OPTIONS', 'url': '/rest/users/group/' }) + .then(function(result) { + return result.data.actions.POST.permissions.choices; + }); + } + return this.permissions; + } }); } ]) diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js index 71039b200..f64bd3209 100644 --- a/openslides/users/static/js/users/site.js +++ b/openslides/users/static/js/users/site.js @@ -96,8 +96,8 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) }) .state('users.group.create', { resolve: { - permissions: function($http) { - return $http({ 'method': 'OPTIONS', 'url': '/rest/users/group/' }); + permissions: function(Group) { + return Group.getPermissions(); } } }) @@ -113,8 +113,8 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) '@users.group': {} }, resolve: { - permissions: function($http) { - return $http({ 'method': 'OPTIONS', 'url': '/rest/users/group/' }); + permissions: function(Group) { + return Group.getPermissions(); } } }) @@ -762,7 +762,7 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) 'permissions', function($scope, $state, Group, permissions) { // get all permissions - $scope.permissions = permissions.data.actions.POST.permissions.choices; + $scope.permissions = permissions; $scope.group = {}; $scope.save = function (group) { Group.create(group).then( @@ -782,7 +782,7 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) 'group', function($scope, $state, Group, permissions, group) { // get all permissions - $scope.permissions = permissions.data.actions.POST.permissions.choices; + $scope.permissions = permissions; $scope.group = group; // autoupdate is not activated $scope.save = function (group) { Group.save(group).then( @@ -827,8 +827,7 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) '$http', '$stateParams', 'operator', - 'gettextCatalog', - function ($rootScope, $scope, $http, $stateParams, operator, gettextCatalog) { + function ($rootScope, $scope, $http, $stateParams, operator ) { $scope.alerts = []; // get login info-text from server @@ -872,8 +871,47 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users']) $scope.closeThisDialog(); }; } +]) + +// Mark all permission strings for translation in JavaScript. +// (see models.py of each Django app) +.config([ + 'gettext', + function (gettext) { + // agenda + gettext('Can see agenda') + gettext('Can manage agenda') + gettext('Can see hidden items and time scheduling of agenda') + gettext('Can put oneself on the list of speakers') + // assignments + gettext('Can see elections') + gettext('Can nominate another participant') + gettext('Can nominate oneself') + gettext('Can manage elections') + // core + gettext('Can see the projector') + gettext('Can manage the projector') + gettext('Can see the dashboard') + gettext('Can manage tags') + gettext('Can manage configuration') + gettext('Can use the chat') + // mediafiles + gettext('Can see the list of files') + gettext('Can upload files') + gettext('Can manage files') + // motions + gettext('Can see motions') + gettext('Can create motions') + gettext('Can support motions') + gettext('Can manage motions') + // users + gettext('Can see names of users') + gettext('Can see extra data of users') + gettext('Can manage users') + } ]); + // this is code from angular.js. Find a way to call this function from this file function getBlockNodes(nodes) { // TODO(perf): just check if all items in `nodes` are siblings and if they are return the original diff --git a/openslides/users/static/templates/users/group-form.html b/openslides/users/static/templates/users/group-form.html index 18554152e..1cb3ed56a 100644 --- a/openslides/users/static/templates/users/group-form.html +++ b/openslides/users/static/templates/users/group-form.html @@ -19,8 +19,8 @@