From 1969416e6421eeb62a0d35f13ef2ac76294f2857 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Thu, 12 Feb 2015 22:42:54 +0100 Subject: [PATCH] Implemented auth via AngularJS Also added the derective osPerms to check if the current user has permissions. Removed old Django views and urls for user. Created utils.views.APIView which should be used instead of the AjaxView. Fixes: #1470 Fixes: #1454 --- openslides/core/static/js/core.js | 19 +- openslides/core/static/templates/index.html | 41 +- openslides/core/templates/base.html | 4 +- openslides/core/views.py | 13 +- openslides/global_settings.py | 2 +- openslides/urls.py | 14 +- openslides/users/forms.py | 143 +----- openslides/users/main_menu.py | 2 +- openslides/users/models.py | 15 +- openslides/users/static/js/users/users.js | 168 ++++++- .../static/templates/users/user-list.html | 5 +- .../users/templates/users/group_detail.html | 55 --- .../users/templates/users/group_form.html | 39 -- .../users/templates/users/group_list.html | 72 --- openslides/users/templates/users/login.html | 59 --- .../users/templates/users/user_detail.html | 92 ---- .../users/templates/users/user_form.html | 49 -- .../templates/users/user_form_multiple.html | 28 -- .../users/templates/users/user_list.html | 158 ------- openslides/users/urls.py | 78 +--- openslides/users/views.py | 424 ++++-------------- openslides/users/widgets.py | 1 - openslides/utils/views.py | 48 +- tests/integration/users/test_views.py | 89 ++++ tests/old/config/test_config.py | 8 - tests/old/mediafile/tests.py | 14 - tests/unit/users/test_models.py | 45 +- tests/unit/utils/test_views.py | 15 + 28 files changed, 470 insertions(+), 1230 deletions(-) delete mode 100644 openslides/users/templates/users/group_detail.html delete mode 100644 openslides/users/templates/users/group_form.html delete mode 100644 openslides/users/templates/users/group_list.html delete mode 100644 openslides/users/templates/users/login.html delete mode 100644 openslides/users/templates/users/user_detail.html delete mode 100644 openslides/users/templates/users/user_form.html delete mode 100644 openslides/users/templates/users/user_form_multiple.html delete mode 100644 openslides/users/templates/users/user_list.html create mode 100644 tests/integration/users/test_views.py diff --git a/openslides/core/static/js/core.js b/openslides/core/static/js/core.js index 2f60f596f..6b9b3990b 100644 --- a/openslides/core/static/js/core.js +++ b/openslides/core/static/js/core.js @@ -3,8 +3,6 @@ angular.module('OpenSlidesApp.core', []) .config(function($stateProvider) { // Use stateProvider.decorator to give default values to our states $stateProvider.decorator('views', function(state, parent) { - - var result = {}, views = parent(state); @@ -69,12 +67,9 @@ angular.module('OpenSlidesApp.core', []) }); }) -.config(function($stateProvider, $urlRouterProvider, $locationProvider) { +.config(function($stateProvider, $locationProvider) { // Core urls - $urlRouterProvider.otherwise('/'); - - $stateProvider - .state('dashboard', { + $stateProvider.state('dashboard', { url: '/', templateUrl: 'static/templates/dashboard.html' }); @@ -119,16 +114,6 @@ angular.module('OpenSlidesApp.core', []) }); }) -.run(function($rootScope, i18n) { - // Puts the gettext methods into each scope. - // Uses the methods that are known by xgettext by default. - methods = ['gettext', 'dgettext', 'dcgettext', 'ngettext', 'dngettext', - 'pgettext', 'dpgettext']; - _.forEach(methods, function(method) { - $rootScope[method] = _.bind(i18n[method], i18n); - }); -}) - .run(function($rootScope, Config) { // Puts the config object into each scope. // TODO: maybe rootscope.config has to set before findAll() is finished diff --git a/openslides/core/static/templates/index.html b/openslides/core/static/templates/index.html index 02e161343..10ae6ee69 100644 --- a/openslides/core/static/templates/index.html +++ b/openslides/core/static/templates/index.html @@ -22,14 +22,13 @@ {{ config('event_name') }} - {% block loginbutton %} - - {% block loginbutton %} + {% block loginbutton %}