diff options
Diffstat (limited to 'ishtar/furnitures/menus.py')
| -rw-r--r-- | ishtar/furnitures/menus.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/ishtar/furnitures/menus.py b/ishtar/furnitures/menus.py new file mode 100644 index 000000000..5a2446f79 --- /dev/null +++ b/ishtar/furnitures/menus.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2010 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# See the file COPYING for details. + +""" +Menus +""" + +from django.utils.translation import ugettext_lazy as _ + +class SectionItem: + def __init__(self, idx, label, childs=[]): + self.idx = idx + self.label = label + self.childs = childs + self.available = False + +class MenuItem: + def __init__(self, idx, label, groups=[]): + self.idx = idx + self.label = label + self.groups = groups + self.available = False + + def is_available(self, user): + return True + +class Menu: + def __init__(self, user): + self.user = user + self.initialized = False + self.childs = [ + SectionItem('file_management', _(u"File management"), + childs=[ + MenuItem('file_creation', _(u"File creation"), + groups=['administrator']), + MenuItem('file_modification', _(u"File modification"), + groups=['administrator']), + MenuItem('file_deletion', _(u"File deletion"), + groups=['administrator']), + ]), +] + + def init(self): + if self.initialized: + return + for main_menu in self.childs: + main_menu.available = False + for child in main_menu.childs: + child.available = child.is_available(self.user) + if child.available: + main_menu.available = True + self.initialized = True + + |
