diff options
-rw-r--r-- | archaeological_files/models.py | 1 | ||||
-rw-r--r-- | archaeological_finds/models.py | 1 | ||||
-rw-r--r-- | archaeological_operations/models.py | 1 | ||||
-rw-r--r-- | ishtar_common/ishtar_menu.py | 44 | ||||
-rw-r--r-- | ishtar_common/menus.py | 31 | ||||
-rw-r--r-- | ishtar_common/models.py | 2 |
6 files changed, 53 insertions, 27 deletions
diff --git a/archaeological_files/models.py b/archaeological_files/models.py index 90f60fe64..c3d950d3e 100644 --- a/archaeological_files/models.py +++ b/archaeological_files/models.py @@ -21,6 +21,7 @@ import datetime from django.conf import settings from django.contrib.gis.db import models +from django.db.models import Q, Count, Sum from django.utils.translation import ugettext_lazy as _, ugettext from ishtar_common.models import GeneralType, BaseHistorizedItem, \ diff --git a/archaeological_finds/models.py b/archaeological_finds/models.py index c61e22e68..eeb293934 100644 --- a/archaeological_finds/models.py +++ b/archaeological_finds/models.py @@ -19,6 +19,7 @@ from django.conf import settings from django.contrib.gis.db import models +from django.db.models import Max from django.utils.translation import ugettext_lazy as _, ugettext from ishtar_common.models import GeneralType, BaseHistorizedItem, \ diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 9b3631114..2c008ef9b 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -19,6 +19,7 @@ from django.conf import settings from django.contrib.gis.db import models +from django.db.models import Q, Count, Sum, Max, Avg from django.db.models.signals import post_save from django.utils.translation import ugettext_lazy as _, ugettext diff --git a/ishtar_common/ishtar_menu.py b/ishtar_common/ishtar_menu.py new file mode 100644 index 000000000..1c198ad91 --- /dev/null +++ b/ishtar_common/ishtar_menu.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2010-2012 É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 Affero 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 Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# See the file COPYING for details. + +from django.utils.translation import ugettext_lazy as _ + +from archaeological_operations.models import Operation +from ishtar_common.menu_base import SectionItem, MenuItem + +import models + +MENU_SECTIONS = [ + (10, SectionItem('administration', _(u"Administration"), + childs=[SectionItem('person', _(u"Person"), + childs=[ + MenuItem('person_creation', _(u"Creation"), + model=models.Person, + access_controls=['add_person', 'add_own_person']), + MenuItem('person_modification', _(u"Modification"), + model=models.Person, + access_controls=['change_person', 'change_own_person']), + ]), + MenuItem('account_management', _(u"Account management"), + model=models.IshtarUser, + access_controls=['add_ishtaruser',]), + ]) + ) +] + diff --git a/ishtar_common/menus.py b/ishtar_common/menus.py index 3737846b9..008220373 100644 --- a/ishtar_common/menus.py +++ b/ishtar_common/menus.py @@ -27,50 +27,29 @@ from django.utils.translation import ugettext_lazy as _ from menu_base import SectionItem, MenuItem import models -_extra_menus = [( - 10, - [ - SectionItem('administration', _(u"Administration"), - childs=[SectionItem('person', _(u"Person"), - childs=[ - MenuItem('person_creation', _(u"Creation"), - model=models.Person, - access_controls=['add_person', 'add_own_person']), - MenuItem('person_modification', _(u"Modification"), - model=models.Person, - access_controls=['change_person', 'change_own_person']), - ]), - MenuItem('account_management', _(u"Account management"), - model=models.IshtarUser, - access_controls=['add_ishtaruser',]), - ]) - ] -)] - +_extra_menus = [] # collect menu from INSTALLED_APPS for app in settings.INSTALLED_APPS: - print app - if app == 'ishtar_common': - continue mod = __import__(app, fromlist=['ishtar_menu']) if hasattr(mod, 'ishtar_menu'): menu = getattr(mod, 'ishtar_menu') _extra_menus += menu.MENU_SECTIONS - # sort __section_items = [menu for order, menu in sorted(_extra_menus, key=lambda x:x[0])] - +print __section_items # regroup menus _section_items, __keys = [], [] -for section_item in _section_items: +for section_item in __section_items: + print section_item if section_item.idx not in __keys: __keys.append(section_item.idx) _section_items.append(section_item) continue _section_items[_section_items.index(section_item.idx)].childs.append( section_item.childs) +print _section_items """ SectionItem('dashboard', _(u"Dashboard"), childs=[ diff --git a/ishtar_common/models.py b/ishtar_common/models.py index b4bf2cd57..9b6f94907 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -29,7 +29,7 @@ from django.utils.translation import ugettext_lazy as _, ugettext from django.utils.safestring import SafeUnicode, mark_safe from django.core.urlresolvers import reverse, NoReverseMatch from django.db.utils import DatabaseError -from django.db.models import Q, Max, Count, Sum, Avg +from django.db.models import Q, Max, Count from django.db.models.signals import post_save from django.contrib.auth.models import User |