Merge pull request #1912 from emanuelschuetze/fixAgenda

Check if user is allowed to see detail view link in agenda list.
This commit is contained in:
Norman Jäckel 2016-01-27 22:25:56 +01:00
commit c4281c6bc7
5 changed files with 42 additions and 3 deletions

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-01-27 21:36
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('agenda', '0002_auto_20160122_2318'),
]
operations = [
migrations.AlterField(
model_name='item',
name='weight',
field=models.IntegerField(default=10000),
),
]

View File

@ -233,7 +233,7 @@ class Item(RESTModelMixin, models.Model):
The parent item in the agenda tree.
"""
weight = models.IntegerField(default=0)
weight = models.IntegerField(default=10000)
"""
Weight to sort the item in the agenda.
"""

View File

@ -71,12 +71,13 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
'$scope',
'$http',
'$state',
'operator',
'ngDialog',
'Agenda',
'AgendaTree',
'Customslide',
'Projector',
function($scope, $http, $state, ngDialog, Agenda, AgendaTree, Customslide, Projector) {
function($scope, $http, $state, operator, ngDialog, Agenda, AgendaTree, Customslide, Projector) {
// Bind agenda tree to the scope
$scope.$watch(function () {
return Agenda.lastModified();
@ -85,6 +86,20 @@ angular.module('OpenSlidesApp.agenda.site', ['OpenSlidesApp.agenda'])
});
$scope.alert = {};
// check open permission
$scope.isAllowedToSeeOpenLink = function (item) {
var collection = item.content_object.collection;
switch (collection) {
case 'core/customslide':
return operator.hasPerms('core.can_manage_projector');
case 'motions/motion':
return operator.hasPerms('motions.can_see');
case 'assignments/assignment':
return operator.hasPerms('assignments.can_see');
default:
return false;
}
};
// open new dialog
$scope.newDialog = function () {
ngDialog.open({

View File

@ -135,9 +135,12 @@
<td ng-if="!item.quickEdit" ng-mouseover="item.hover=true" ng-mouseleave="item.hover=false"
style="padding-left: calc(8px + {{ item.parentCount }}*15px)">
<strong>
<a href="" ng-click="open(item)">
<a ng-show="isAllowedToSeeOpenLink(item)" href="" ng-click="open(item)">
{{ item.getListViewTitle() }}
</a>
<span ng-hide="isAllowedToSeeOpenLink(item)">
{{ item.getListViewTitle() }}
</span>
</strong>
<span ng-if="item.is_hidden" title="{{ 'Internal item' | translate }}"><i class="fa fa-ban"></i></span>
<div ng-if="item.comment">

View File

@ -244,6 +244,7 @@ class Numbering(TestCase):
self.client.login(username='admin', password='admin')
self.item_1 = CustomSlide.objects.create(title='test_title_thuha8eef7ohXar3eech').agenda_item
self.item_1.type = Item.AGENDA_ITEM
self.item_1.weight = 1
self.item_1.save()
self.item_2 = CustomSlide.objects.create(title='test_title_eisah7thuxa1eingaeLo').agenda_item
self.item_2.type = Item.AGENDA_ITEM