Merge pull request #2049 from emanuelschuetze/fix2028

Catch 404 errors in resolve promise if user has not all required permissions
This commit is contained in:
Norman Jäckel 2016-03-20 20:48:58 +01:00
commit 5af25351fa
11 changed files with 48 additions and 19 deletions

View File

@ -41,10 +41,18 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
.state('agenda.item.detail', { .state('agenda.item.detail', {
resolve: { resolve: {
item: function(Agenda, $stateParams) { item: function(Agenda, $stateParams) {
return Agenda.find($stateParams.id); return Agenda.find($stateParams.id).catch(
function () {
return null;
}
);
}, },
users: function(User) { users: function(User) {
return User.findAll(); return User.findAll().catch(
function () {
return null;
}
);
}, },
tags: function(Tag) { tags: function(Tag) {
return Tag.findAll(); return Tag.findAll();

View File

@ -1,4 +1,4 @@
<div class="header"> <div ng-if="item" class="header">
<div class="title"> <div class="title">
<div class="submenu"> <div class="submenu">
<a ui-sref="agenda.item.list" class="btn btn-sm btn-default"> <a ui-sref="agenda.item.list" class="btn btn-sm btn-default">
@ -34,7 +34,7 @@
</div> </div>
</div> </div>
<div class="details listOfSpeakers"> <div ng-if="item" class="details listOfSpeakers">
<div class="pull-right"> <div class="pull-right">
<span os-perms="agenda.can_manage"> <span os-perms="agenda.can_manage">
<button ng-if="item.speaker_list_closed" ng-click="closeList(false)" <button ng-if="item.speaker_list_closed" ng-click="closeList(false)"

View File

@ -37,7 +37,11 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
return Assignment.findAll(); return Assignment.findAll();
}, },
items: function(Agenda) { items: function(Agenda) {
return Agenda.findAll(); return Agenda.findAll().catch(
function () {
return null;
}
);
}, },
phases: function(Assignment) { phases: function(Assignment) {
return Assignment.getPhases(); return Assignment.getPhases();

View File

@ -73,6 +73,7 @@ angular.module('OpenSlidesApp.core.site', [
'img_class': 'home', 'img_class': 'home',
'title': gettext('Home'), 'title': gettext('Home'),
'weight': 100, 'weight': 100,
'perm': 'core.can_see_frontpage',
}); });
mainMenuProvider.register({ mainMenuProvider.register({

View File

@ -1,7 +1,9 @@
<div class="header"> <div os-perms="core.can_see_frontpage" class="header">
<div class="title"> <div class="title">
<h1>{{ config('general_event_welcome_title') }}</h1> <h1>{{ config('general_event_welcome_title') }}</h1>
</div> </div>
</div> </div>
<div class="details" ng-bind-html="config('general_event_welcome_text')"></div> <div os-perms="core.can_see_frontpage" class="details"
ng-bind-html="config('general_event_welcome_text')">
</div>

View File

@ -37,7 +37,11 @@ angular.module('OpenSlidesApp.mediafiles.site', ['ngFileUpload', 'OpenSlidesApp.
return Mediafile.findAll(); return Mediafile.findAll();
}, },
users: function(User) { users: function(User) {
return User.findAll(); return User.findAll().catch(
function () {
return null;
}
);
}, },
} }
}); });

View File

@ -39,7 +39,6 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
Motion.loadRelations(motion, 'agenda_item'); Motion.loadRelations(motion, 'agenda_item');
}); });
}); });
}, },
categories: function(Category) { categories: function(Category) {
return Category.findAll(); return Category.findAll();
@ -48,7 +47,11 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
return Tag.findAll(); return Tag.findAll();
}, },
users: function(User) { users: function(User) {
return User.findAll(); return User.findAll().catch(
function () {
return null;
}
);
}, },
workflows: function(Workflow) { workflows: function(Workflow) {
return Workflow.findAll(); return Workflow.findAll();
@ -58,18 +61,24 @@ angular.module('OpenSlidesApp.motions.site', ['OpenSlidesApp.motions'])
.state('motions.motion.detail', { .state('motions.motion.detail', {
resolve: { resolve: {
motion: function(Motion, $stateParams) { motion: function(Motion, $stateParams) {
return Motion.find($stateParams.id).then(function(motion) { return Motion.find($stateParams.id);
return Motion.loadRelations(motion, 'agenda_item');
});
}, },
categories: function(Category) { categories: function(Category) {
return Category.findAll(); return Category.findAll();
}, },
users: function(User) { users: function(User) {
return User.findAll(); return User.findAll().catch(
function () {
return null;
}
);
}, },
mediafiles: function(Mediafile) { mediafiles: function(Mediafile) {
return Mediafile.findAll(); return Mediafile.findAll().catch(
function () {
return null;
}
);
}, },
tags: function(Tag) { tags: function(Tag) {
return Tag.findAll(); return Tag.findAll();

View File

@ -28,7 +28,7 @@
<i class="fa fa-pencil"></i> <i class="fa fa-pencil"></i>
</a> </a>
</div> </div>
<h1>{{ motion.getTitle() }}</h1> <h1>{{ motion.agenda_item.getTitle() || motion.getTitle() }}</h1>
<h2> <h2>
<translate>Motion</translate> {{ motion.identifier }} <translate>Motion</translate> {{ motion.identifier }}
<span ng-if="motion.versions.length > 1" >| Version {{ motion.getVersion(version).version_number }}</span> <span ng-if="motion.versions.length > 1" >| Version {{ motion.getVersion(version).version_number }}</span>

View File

@ -62,7 +62,7 @@
<!-- Title --> <!-- Title -->
<div id="title"> <div id="title">
<h1>{{ motion.getTitle() }}</h1> <h1>{{ motion.agenda_item.getTitle() || motion.getTitle() }}</h1>
<h2> <h2>
<translate>Motion</translate> {{ motion.identifier }} <translate>Motion</translate> {{ motion.identifier }}
<span ng-if="motion.versions.length > 1" >| Version {{ motion.getVersion().version_number }}</span> <span ng-if="motion.versions.length > 1" >| Version {{ motion.getVersion().version_number }}</span>

View File

@ -383,6 +383,7 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
User.bindAll({}, $scope, 'users'); User.bindAll({}, $scope, 'users');
Group.bindAll({where: {id: {'>': 2}}}, $scope, 'groups'); Group.bindAll({where: {id: {'>': 2}}}, $scope, 'groups');
$scope.alert = {}; $scope.alert = {};
$scope.groupFilter = undefined;
// setup table sorting // setup table sorting
$scope.sortColumn = 'first_name'; //TODO: sort by first OR last name $scope.sortColumn = 'first_name'; //TODO: sort by first OR last name
@ -973,7 +974,7 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
gettext('Can manage motions'); gettext('Can manage motions');
// users // users
gettext('Can see names of users'); gettext('Can see names of users');
gettext('Can see extra data of users'); gettext('Can see extra data of users (e.g. present and comment)');
gettext('Can manage users'); gettext('Can manage users');
} }
]); ]);

View File

@ -69,7 +69,7 @@
<div class="col-sm-6 text-right form-inline"> <div class="col-sm-6 text-right form-inline">
<!-- group filter --> <!-- group filter -->
<select ng-model="groupFilter" class="form-control" id="groupFilter"> <select ng-model="groupFilter" class="form-control" id="groupFilter">
<option value="" translate>--- Select group ---</option> <option ng-click="groupFilter = undefined" value="" translate>--- Select group ---</option>
<option ng-repeat="group in groups" value="{{ group.id }}">{{ group.name | translate }}</option> <option ng-repeat="group in groups" value="{{ group.id }}">{{ group.name | translate }}</option>
</select> </select>
<!-- isPresent filter --> <!-- isPresent filter -->