Merge pull request #1612 from ostcar/motion_tag_save

Reload config after login
This commit is contained in:
Oskar Hahn 2015-09-05 11:32:52 +02:00
commit 948e776d33
2 changed files with 90 additions and 61 deletions

View File

@ -74,22 +74,33 @@ angular.module('OpenSlidesApp.core', [
}); });
}]) }])
.run(['$rootScope', 'Config', 'Projector', function($rootScope, Config, Projector) { .factory('loadGlobalData', [
// Puts the config object into each scope. '$rootScope',
Config.findAll().then(function() { 'Config',
$rootScope.config = function(key) { 'Projector',
try { function ($rootScope, Config, Projector) {
return Config.get(key).value; return function () {
} // Puts the config object into each scope.
catch(err) { Config.findAll().then(function() {
console.log("Unkown config key: " + key); $rootScope.config = function(key) {
return '' try {
} return Config.get(key).value;
} }
}); catch(err) {
console.log("Unkown config key: " + key);
return ''
}
}
});
// Loads all projector data // Loads all projector data
Projector.findAll(); Projector.findAll();
}
}
])
.run(['loadGlobalData', function(loadGlobalData) {
loadGlobalData();
}]) }])
.factory('jsDataModel', ['$http', 'Projector', function($http, Projector) { .factory('jsDataModel', ['$http', 'Projector', function($http, Projector) {
@ -433,31 +444,39 @@ angular.module('OpenSlidesApp.core.site', [
} }
}) })
.controller('LoginFormModalCtrl', function ($scope, $modalInstance, $http, operator) { .controller('LoginFormModalCtrl', [
$scope.login = function () { '$scope',
$http.post( '$modalInstance',
'/users/login/', '$http',
{'username': $scope.username, 'password': $scope.password} 'operator',
).success(function(data) { 'loadGlobalData',
if (data.success) { function ($scope, $modalInstance, $http, operator, loadGlobalData) {
operator.setUser(data.user_id); $scope.login = function () {
$scope.loginFailed = false; $http.post(
$modalInstance.close(); '/users/login/',
} else { {'username': $scope.username, 'password': $scope.password}
$scope.loginFailed = true; ).success(function(data) {
} if (data.success) {
}); operator.setUser(data.user_id);
}; loadGlobalData();
$scope.guest = function () { $scope.loginFailed = false;
$modalInstance.dismiss('cancel'); $modalInstance.close();
}; } else {
$scope.cancel = function () { $scope.loginFailed = true;
$modalInstance.dismiss('cancel'); }
}; });
}) };
$scope.guest = function () {
$modalInstance.dismiss('cancel');
};
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
}
])
// Version Controller // Version Controller
.controller('VersionCtrl', function($scope, $http) { .controller('VersionCtrl', function ($scope, $http) {
$http.get('/core/version/').success(function(data) { $http.get('/core/version/').success(function(data) {
$scope.core_version = data.openslides_version; $scope.core_version = data.openslides_version;
$scope.plugins = data.plugins; $scope.plugins = data.plugins;

View File

@ -248,31 +248,41 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
}; };
}) })
.controller('MotionUpdateCtrl', .controller('MotionUpdateCtrl', [
function($scope, $state, $http, Motion, Agenda, User, Category, Workflow, Tag, Mediafile, motion) { '$scope',
Agenda.bindAll({}, $scope, 'items'); '$state',
User.bindAll({}, $scope, 'users'); '$http',
Category.bindAll({}, $scope, 'categories'); 'Motion',
Workflow.bindAll({}, $scope, 'workflows'); 'Agenda',
Tag.bindAll({}, $scope, 'tags'); 'User',
Mediafile.bindAll({}, $scope, 'mediafiles'); 'Category',
'Workflow',
'Tag',
'Mediafile',
'motion',
function ($scope, $state, $http, Motion, Agenda, User, Category, Workflow, Tag, Mediafile, motion) {
Agenda.bindAll({}, $scope, 'items');
User.bindAll({}, $scope, 'users');
Category.bindAll({}, $scope, 'categories');
Workflow.bindAll({}, $scope, 'workflows');
Tag.bindAll({}, $scope, 'tags');
Mediafile.bindAll({}, $scope, 'mediafiles');
$scope.motion = motion; $scope.motion = motion;
// get latest version for edit // get latest version for edit
$scope.motion.title = $scope.motion.getTitle(-1); $scope.motion.title = $scope.motion.getTitle(-1);
$scope.motion.text = $scope.motion.getText(-1); $scope.motion.text = $scope.motion.getText(-1);
$scope.motion.reason = $scope.motion.getReason(-1); $scope.motion.reason = $scope.motion.getReason(-1);
$scope.save = function (motion) { $scope.save = function (motion) {
motion.tags = []; // TODO: REST API should do it! (Bug in Django REST framework) Motion.save(motion).then(
motion.attachments = []; // TODO: REST API should do it! (Bug in Django REST framework) function(success) {
Motion.save(motion).then( $state.go('motions.motion.list');
function(success) { }
$state.go('motions.motion.list'); );
} };
); }
}; ])
})
.controller('MotionCSVImportCtrl', function($scope, Motion) { .controller('MotionCSVImportCtrl', function($scope, Motion) {
// TODO // TODO