From 3f0f98dc240232592aeac589f6838d66ea59bc08 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Tue, 21 Nov 2017 10:32:31 +0100 Subject: [PATCH] Added presence view --- CHANGELOG | 1 + openslides/users/config_variables.py | 9 +++ openslides/users/static/js/users/site.js | 57 +++++++++++++++++-- .../static/templates/users/user-list.html | 6 ++ .../static/templates/users/user-presence.html | 31 ++++++++++ 5 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 openslides/users/static/templates/users/user-presence.html diff --git a/CHANGELOG b/CHANGELOG index 25fd3784b..832980b61 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -66,6 +66,7 @@ Users: - Added option to enable updating the last_login field in the database. The default is now disabled [#3400]. - Hide password in change password view [#3417]. +- Added a change presence view [#3496]. Core: - No reload on logoff. OpenSlides is now a full single page diff --git a/openslides/users/config_variables.py b/openslides/users/config_variables.py index c0648e471..09322fb56 100644 --- a/openslides/users/config_variables.py +++ b/openslides/users/config_variables.py @@ -21,6 +21,15 @@ def get_config_variables(): group='Participants', subgroup='General') + yield ConfigVariable( + name='users_enable_presence_view', + default_value=False, + input_type='boolean', + label='Enable participant presence view', + weight=511, + group='Participants', + subgroup='General') + # PDF yield ConfigVariable( diff --git a/openslides/users/static/js/users/site.js b/openslides/users/static/js/users/site.js index fd11d271c..9ceb5bcab 100644 --- a/openslides/users/static/js/users/site.js +++ b/openslides/users/static/js/users/site.js @@ -76,6 +76,10 @@ angular.module('OpenSlidesApp.users.site', [ url: '/import', controller: 'UserImportCtrl', }) + .state('users.user.presence', { + url: '/presence', + controller: 'UserPresenceCtrl', + }) // groups .state('users.group', { url: '/groups', @@ -432,7 +436,7 @@ angular.module('OpenSlidesApp.users.site', [ function (gettextCatalog, Editor, Mediafile) { return { // ngDialog for user form - getDialog: function (user) { + getDialog: function () { return { template: 'static/templates/users/profile-password-form.html', controller: 'UserProfileCtrl', @@ -474,7 +478,7 @@ angular.module('OpenSlidesApp.users.site', [ function (gettextCatalog) { return { // ngDialog for user form - getDialog: function (user) { + getDialog: function () { return { template: 'static/templates/users/profile-password-form.html', controller: 'UserPasswordCtrl', @@ -536,8 +540,9 @@ angular.module('OpenSlidesApp.users.site', [ 'gettext', 'UserPdfExport', 'ErrorMessage', - function($scope, $state, $http, $q, ngDialog, UserForm, User, Group, PasswordGenerator, Projector, ProjectionDefault, - Config, gettextCatalog, UserCsvExport, osTableFilter, osTableSort, gettext, UserPdfExport, ErrorMessage) { + function($scope, $state, $http, $q, ngDialog, UserForm, User, Group, PasswordGenerator, + Projector, ProjectionDefault, Config, gettextCatalog, UserCsvExport, osTableFilter, + osTableSort, gettext, UserPdfExport, ErrorMessage) { $scope.$watch(function () { return User.lastModified(); }, function () { @@ -962,6 +967,49 @@ angular.module('OpenSlidesApp.users.site', [ } ]) +.controller('UserPresenceCtrl', [ + '$scope', + 'User', + 'gettextCatalog', + 'ErrorMessage', + function ($scope, User, gettextCatalog, ErrorMessage) { + $scope.alert = {}; + $('#userNumber').focus(); + + $scope.changeState = function () { + if (!$scope.number) { + return; + } + var enteredNumber = $scope.number.trim(); + var user = _.find(User.getAll(), function (user) { + return user.number === enteredNumber; + }); + if (user) { + user.is_present = !user.is_present; + User.save(user).then(function (success) { + var messageText = user.full_name + ' ' + gettextCatalog.getString('is now') + ' '; + messageText += gettextCatalog.getString(user.is_present ? 'present' : 'not present') + '.'; + $scope.alert = { + msg: messageText, + show: true, + type: 'success', + }; + $scope.number = ''; + }, function (error) { + $scope.alert = ErrorMessage.forAlert(error); + }); + } else { + $scope.alert = { + msg: gettextCatalog.getString('Cannot find the participant with the participant number') + ' "' + enteredNumber + '".', + show: true, + type: 'danger', + }; + } + $('#userNumber').focus(); + }; + } +]) + .controller('UserImportCtrl', [ '$scope', '$http', @@ -1653,6 +1701,7 @@ angular.module('OpenSlidesApp.users.site', [ // config strings in users/config_variables.py gettext('General'); gettext('Sort name of participants by'); + gettext('Enable participant presence view'); gettext('Participants'); gettext('Given name'); gettext('Surname'); diff --git a/openslides/users/static/templates/users/user-list.html b/openslides/users/static/templates/users/user-list.html index 2ee3d2f9c..ad4804c8c 100644 --- a/openslides/users/static/templates/users/user-list.html +++ b/openslides/users/static/templates/users/user-list.html @@ -5,6 +5,12 @@ New + + + + Presence + + Groups diff --git a/openslides/users/static/templates/users/user-presence.html b/openslides/users/static/templates/users/user-presence.html new file mode 100644 index 000000000..1eeeac341 --- /dev/null +++ b/openslides/users/static/templates/users/user-presence.html @@ -0,0 +1,31 @@ +
+ +
+ +
+ +
+ {{ alert.msg }} +
+ +
+
+
+ + +
+ +
+
+