Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

vigigraph / vigigraph / controllers / root.py @ 56b77667

History | View | Annotate | Download (1.93 KB)

1
# -*- coding: utf-8 -*-
2
# vim:set expandtab tabstop=4 shiftwidth=4:
3
# Copyright (C) 2006-2020 CS-SI
4
# License: GNU GPL v2 <http://www.gnu.org/licenses/gpl-2.0.html>
5

    
6
"""Vigigraph Controller"""
7

    
8
# pylint: disable-msg=W0613
9
# W0613: Unused argument : les arguments des contrôleurs sont les composants
10
#        de la query-string de l'URL
11

    
12
import gettext
13
import os.path
14
import logging
15

    
16
from tg import expose, require, config, response
17
from tg.i18n import lazy_ugettext as l_, get_lang
18
from tg.predicates import Any, All, not_anonymous, has_permission, in_group
19
from pkg_resources import resource_filename
20

    
21
from vigilo.turbogears.controllers.auth import AuthController
22
from vigilo.turbogears.controllers.custom import CustomController
23
from vigilo.turbogears.controllers.error import ErrorController
24
from vigilo.turbogears.controllers.proxy import ProxyController
25
from vigilo.turbogears.controllers.i18n import I18nController
26
from vigilo.turbogears.controllers.api.root import ApiRootController
27

    
28
from vigigraph.controllers.rpc import RpcController
29

    
30
__all__ = ['RootController']
31

    
32
LOGGER = logging.getLogger(__name__)
33

    
34
# pylint: disable-msg=R0201
35
class RootController(AuthController, I18nController):
36
    """
37
    The root controller for the vigigraph application.
38
    """
39
    error = ErrorController()
40
    rpc = RpcController()
41
    nagios = ProxyController('nagios', '/nagios/',
42
        not_anonymous(l_('You need to be authenticated')))
43
    vigirrd = ProxyController('vigirrd', '/vigirrd/',
44
        not_anonymous(l_('You need to be authenticated')))
45
    api = ApiRootController()
46
    custom = CustomController()
47

    
48
    @expose('index.html')
49
    @require(All(
50
        not_anonymous(msg=l_("You need to be authenticated")),
51
        Any(
52
            config.is_manager,
53
            has_permission('vigigraph-access',
54
                msg=l_("You don't have access to VigiGraph")),
55
        )
56
    ))
57
    def index(self):
58
        """Handle the front-page."""
59
        return dict(page='index')