Пример #1
0
        def wrapped_f(*args):

            permission_granted = False

            tornado_handler = args[0]

            username = tornado_handler.get_current_user()

            user = Hierarchy.get_user(username)

            user_groups = Hierarchy.get_groups_of_user(
                username,
                user.current_customer
            )

            for group in user_groups:

                if self._permission in group.permissions:

                    permission_granted = True
                    break

                elif Permission.Admin in group.permissions:

                    permission_granted = True
                    break

            if permission_granted:

                f(*args)

            else:

                self._permission_denied(tornado_handler)
Пример #2
0
        def wrapped_f(*args):

            permission_granted = False

            tornado_handler = args[0]

            username = tornado_handler.get_current_user()

            user = Hierarchy.get_user(username)

            user_groups = Hierarchy.get_groups_of_user(username,
                                                       user.current_customer)

            for group in user_groups:

                if self._permission in group.permissions:

                    permission_granted = True
                    break

                elif Permission.Admin in group.permissions:

                    permission_granted = True
                    break

            if permission_granted:

                f(*args)

            else:

                self._permission_denied(tornado_handler)