コード例 #1
0
 def canView(self):
     # Permissions to view acords based on ODT definition file
     # TODO: add if is obert /restricted to ...
     estatSessio = utils.session_wf_state(self)
     roles = utils.getUserRoles(self, self.context,
                                api.user.get_current().id)
     if 'Manager' in roles:
         return True
     elif estatSessio == 'planificada' and utils.checkhasRol(
         ['OG1-Secretari', 'OG2-Editor'], roles):
         return True
     elif estatSessio == 'convocada' and utils.checkhasRol(
         ['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'],
             roles):
         return True
     elif estatSessio == 'realitzada' and utils.checkhasRol(
         ['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'],
             roles):
         return True
     elif estatSessio == 'tancada' and utils.checkhasRol(
         ['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'],
             roles):
         return True
     elif estatSessio == 'en_correccio' and utils.checkhasRol(
         ['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'],
             roles):
         return True
     else:
         raise Unauthorized
コード例 #2
0
ファイル: organgovern.py プロジェクト: UPCnet/genweb.organs
    def canView(self):
        # Permissions to view ORGANS DE GOVERN
        # Bypass if manager
        roles = utils.getUserRoles(self, self.context,
                                   api.user.get_current().id)
        if 'Manager' in roles:
            return True

        organType = self.context.organType

        # If Obert
        if organType == 'open_organ':
            return True
        # if restricted_to_members_organ
        elif organType == 'restricted_to_members_organ':
            if utils.checkhasRol(
                ['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'],
                    roles):
                return True
            else:
                raise Unauthorized
        # if restricted_to_affected_organ
        elif organType == 'restricted_to_affected_organ':
            if utils.checkhasRol([
                    'OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG4-Afectat',
                    'OG5-Convidat'
            ], roles):
                return True
            else:
                raise Unauthorized
        else:
            raise Unauthorized
コード例 #3
0
ファイル: organsfolder.py プロジェクト: UPCnet/genweb.organs
 def canView(self):
     # Permissions per veure l'estat dels organs a la taula principal
     roles = utils.getUserRoles(self, self.context, api.user.get_current().id)
     if utils.checkhasRol(['Manager', 'OG1-Secretari', 'OG2-Editor'], roles):
         return True
     else:
         return False
コード例 #4
0
ファイル: organgovern.py プロジェクト: UPCnet/genweb.organs
 def viewOrdena(self):
     roles = utils.getUserRoles(self, self.context,
                                api.user.get_current().id)
     if utils.checkhasRol(['Manager', 'OG1-Secretari', 'OG2-Editor'],
                          roles):
         value = True
     return False
コード例 #5
0
ファイル: acta.py プロジェクト: UPCnet/genweb.organs
 def viewPrintButon(self):
     roles = utils.getUserRoles(self, self.context, api.user.get_current().id)
     if 'Manager' in roles:
         return True
     if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'], roles):
         return True
     else:
         return False
コード例 #6
0
ファイル: organgovern.py プロジェクト: UPCnet/genweb.organs
 def viewExportAcords(self):
     # Només els Secretaris i Editors poden veure les excuses
     roles = utils.getUserRoles(self, self.context,
                                api.user.get_current().id)
     if utils.checkhasRol(['Manager', 'OG1-Secretari'], roles):
         return True
     else:
         return False
コード例 #7
0
ファイル: rss_custom.py プロジェクト: UPCnet/genweb.organs
    def _brains(self):
        catalog = api.portal.get_tool(name='portal_catalog')
        items = catalog(path={
            'query': '/'.join(self.context.getPhysicalPath()),
            'depth': 1
        })
        filtered_items = []
        for item in items:
            if item.portal_type in [
                    'genweb.organs.acord',
                    'genweb.organs.acta',
                    'genweb.organs.audio',
                    'genweb.organs.document',
                    'genweb.organs.file',
                    'genweb.organs.organgovern',
                    'genweb.organs.organsfolder',
                    'genweb.organs.punt',
                    'genweb.organs.sessio',
                    'genweb.organs.subpunt',
            ]:
                add = False
                tipus = item.portal_type
                organ_tipus = item.organType
                if tipus == 'genweb.organs.organsfolder':
                    add = True
                elif tipus == 'genweb.organs.sessio' or tipus == 'genweb.organs.organgovern':
                    roles = utils.getUserRoles(self, self.context,
                                               api.user.get_current().id)
                    if organ_tipus == 'open_organ':
                        add = True
                    elif organ_tipus == 'restricted_to_members_organ':
                        if utils.checkhasRol([
                                'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                                'OG5-Convidat'
                        ], roles):
                            add = True
                    elif organ_tipus == 'restricted_to_affected_organ':
                        if utils.checkhasRol([
                                'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                                'OG4-Afectat', 'OG5-Convidat'
                        ], roles):
                            add = True
                    else:
                        add = False
            else:
                # Els elements tipics de Plone/Genweb es mostren al RSS
                add = True

            if add:
                filtered_items.append(item)

        installed = packages_installed()
        if 'genweb.organs' in installed:
            return sorted(filtered_items,
                          key=itemgetter('start'),
                          reverse=True)
        else:
            return sorted(filtered_items, key=itemgetter('Date'), reverse=True)
コード例 #8
0
ファイル: organgovern.py プロジェクト: UPCnet/genweb.organs
 def viewActes(self):
     """ Si es Manager/Secretari/Editor/Membre show actas
         Affectat i altres NO veuen MAI les ACTES """
     roles = utils.getUserRoles(self, self.context,
                                api.user.get_current().id)
     if utils.checkhasRol([
             'Manager', 'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
             'OG5-Convidat'
     ], roles):
         return True
     else:
         return False
コード例 #9
0
 def canModify(self):
     review_state = api.content.get_state(self.context)
     value = False
     roles = utils.getUserRoles(self, self.context,
                                api.user.get_current().id)
     if review_state in [
             'planificada', 'convocada', 'realitzada', 'en_correccio'
     ] and 'OG1-Secretari' in roles:
         value = True
     if review_state in ['planificada', 'convocada', 'realitzada'
                         ] and 'OG2-Editor' in roles:
         value = True
     return value or 'Manager' in roles
コード例 #10
0
ファイル: permissions.py プロジェクト: UPCnet/genweb.organs
def canViewPunt(self, item):
    # Permissions to view PUNTS
    self.context = item
    roles = utils.getUserRoles(self, self.context, api.user.get_current().id)
    if 'Manager' in roles:
        return True

    estatSessio = utils.session_wf_state(self)
    organ_tipus = self.context.organType

    if organ_tipus == 'open_organ':
        if estatSessio == 'planificada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'], roles):
            return True
        elif estatSessio == 'convocada':
            return True
        elif estatSessio == 'realitzada':
            return True
        elif estatSessio == 'tancada':
            return True
        elif estatSessio == 'en_correccio':
            return True
        else:
            return False

    if organ_tipus == 'restricted_to_members_organ':
        if estatSessio == 'planificada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'], roles):
            return True
        elif estatSessio == 'convocada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'], roles):
            return True
        elif estatSessio == 'realitzada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'], roles):
            return True
        elif estatSessio == 'tancada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'], roles):
            return True
        elif estatSessio == 'en_correccio' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'], roles):
            return True
        else:
            return False

    if organ_tipus == 'restricted_to_affected_organ':
        if estatSessio == 'planificada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'], roles):
            return True
        elif estatSessio == 'convocada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'], roles):
            return True
        elif estatSessio == 'realitzada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG4-Afectat', 'OG5-Convidat'], roles):
            return True
        elif estatSessio == 'tancada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG4-Afectat', 'OG5-Convidat'], roles):
            return True
        elif estatSessio == 'en_correccio' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG4-Afectat', 'OG5-Convidat'], roles):
            return True
        else:
            return False
コード例 #11
0
 def canViewVotacionsInside(self):
     roles = utils.getUserRoles(self, self.context,
                                api.user.get_current().id)
     estatSessio = utils.session_wf_state(self)
     if estatSessio == 'planificada' and utils.checkhasRol(
         ['OG1-Secretari', 'OG2-Editor'], roles):
         return True
     elif estatSessio in [
             'convocada', 'realitzada', 'tancada', 'en_correccio'
     ] and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre'],
                             roles):
         return True
     else:
         return False
コード例 #12
0
ファイル: votacio_acord.py プロジェクト: UPCnet/genweb.organs
    def canView(self):
        # Permissions to view VOTACIOACORD
        # If manager Show all
        roles = utils.getUserRoles(self, self.context,
                                   api.user.get_current().id)
        if 'Manager' in roles:
            return True

        estatSessio = utils.session_wf_state(self)

        if estatSessio == 'planificada' and utils.checkhasRol(
            ['OG1-Secretari', 'OG2-Editor'], roles):
            return True
        elif estatSessio in [
                'convocada', 'realitzada', 'tancada', 'en_correccio'
        ] and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre'],
                                roles):
            return True
        else:
            raise Unauthorized
コード例 #13
0
    def canView(self):
        # Permissions to view audio
        roles = utils.getUserRoles(self, self.context, api.user.get_current().id)
        if 'Manager' in roles:
            return True

        estatSessio = utils.session_wf_state(self)
        organ_tipus = self.context.organType

        if estatSessio == 'planificada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'], roles):
            return True
        elif estatSessio == 'convocada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'], roles):
            return True
        elif estatSessio == 'realitzada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'], roles):
            return True
        elif organ_tipus == 'open_organ' and estatSessio == 'tancada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG4-Afectat', 'OG5-Convidat'], roles):
            return True
        elif organ_tipus != 'open_organ' and estatSessio == 'tancada' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'], roles):
            return True
        elif estatSessio == 'en_correccio' and utils.checkhasRol(['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'], roles):
            return True
        else:
            raise Unauthorized
コード例 #14
0
def getFileOrgans(self):
    if not self.fieldname:
        info = IPrimaryFieldInfo(self.context, None)
        if info is None:
            # Ensure that we have at least a filedname
            raise NotFound(self, '', self.request)
        self.fieldname = info.fieldname
        file = info.value
    else:
        context = getattr(self.context, 'aq_explicit', self.context)
        file = guarded_getattr(context, self.fieldname, None)

    if file is None:
        raise NotFound(self, self.fieldname, self.request)
    # GENWEB ORGANS CODE ADDED
    # Antes de retornar el fichero comprobamos los estados de la sesion
    # para ver si lo debemos mostrar o no
    # Check if genweb.organs installed...

    from Products.CMFCore.utils import getToolByName
    qi = getToolByName(self.context, 'portal_quickinstaller')
    prods = qi.listInstalledProducts()
    installed = False

    if 'genweb.organs' in [prod['id'] for prod in prods]:
        installed = True
    if not installed:
        # Standard functionallity.
        return file
    elif self.context.portal_type == 'File':
        # If package is installed but thit is not an organ type
        # then only is an standeard file, we have to show it.
        return file
    else:
        #
        #  WARNING: Organs functionallity
        #
        from plone import api
        from genweb.organs import utils

        roles = utils.getUserRoles(self, self.context,
                                   api.user.get_current().id)
        if 'Manager' in roles:
            return file

        if self.context.aq_parent.aq_parent.portal_type == 'genweb.organs.sessio':
            # first level
            estatSessio = api.content.get_state(
                obj=self.context.aq_parent.aq_parent)
        elif self.context.portal_type == 'genweb.organs.acta':
            estatSessio = api.content.get_state(obj=self.context.aq_parent)
        else:
            # second level
            estatSessio = api.content.get_state(
                obj=self.context.aq_parent.aq_parent.aq_parent)
        # Get Organ Type here
        organ_tipus = self.context.organType
        if organ_tipus == 'open_organ':
            if estatSessio == 'planificada':
                if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'], roles):
                    return file
                else:
                    raise Unauthorized
            if estatSessio == 'convocada':
                if self.context.portal_type in [
                        'genweb.organs.acta', 'genweb.organs.audio',
                        'genweb.organs.annex'
                ]:
                    if utils.checkhasRol([
                            'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                            'OG5-Convidat'
                    ], roles):
                        return file
                    else:
                        raise Unauthorized
                else:
                    if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'],
                                         roles):
                        return file
                    elif utils.checkhasRol(
                        ['OG3-Membre', 'OG4-Afectat', 'OG5-Convidat'], roles):
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'hiddenfile':
                                return file
                            else:
                                raise Unauthorized
                        else:
                            return file
                    else:
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'visiblefile':
                                return file
                            else:
                                raise Unauthorized
                        elif (self.context.hiddenfile):
                            raise Unauthorized
                        elif (self.context.visiblefile):
                            return file
                        else:
                            raise Unauthorized
            if estatSessio == 'realitzada':
                if self.context.portal_type in [
                        'genweb.organs.acta', 'genweb.organs.audio',
                        'genweb.organs.annex'
                ]:
                    if utils.checkhasRol([
                            'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                            'OG5-Convidat'
                    ], roles):
                        return file
                    else:
                        raise Unauthorized
                else:
                    if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'],
                                         roles):
                        return file
                    elif utils.checkhasRol(
                        ['OG3-Membre', 'OG4-Afectat', 'OG5-Convidat'], roles):
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'hiddenfile':
                                return file
                            else:
                                raise Unauthorized
                        else:
                            return file
                    else:
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'visiblefile':
                                return file
                            else:
                                raise Unauthorized
                        elif (self.context.hiddenfile):
                            raise Unauthorized
                        elif (self.context.visiblefile):
                            return file
                        else:
                            raise Unauthorized
            if estatSessio == 'tancada':
                if self.context.portal_type in [
                        'genweb.organs.acta', 'genweb.organs.audio',
                        'genweb.organs.annex'
                ]:
                    if utils.checkhasRol([
                            'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                            'OG4-Afectat', 'OG5-Convidat'
                    ], roles):
                        return file
                    else:
                        raise Unauthorized
                else:
                    if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'],
                                         roles):
                        return file
                    elif utils.checkhasRol(
                        ['OG3-Membre', 'OG4-Afectat', 'OG5-Convidat'], roles):
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'hiddenfile':
                                return file
                            else:
                                raise Unauthorized
                        else:
                            return file
                    else:
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'visiblefile':
                                return file
                            else:
                                raise Unauthorized
                        elif (self.context.hiddenfile):
                            raise Unauthorized
                        elif (self.context.visiblefile):
                            return file
                        else:
                            raise Unauthorized
            if estatSessio == 'en_correccio':
                if self.context.portal_type in [
                        'genweb.organs.acta', 'genweb.organs.audio',
                        'genweb.organs.annex'
                ]:
                    if utils.checkhasRol([
                            'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                            'OG5-Convidat'
                    ], roles):
                        return file
                    else:
                        raise Unauthorized
                else:
                    if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'],
                                         roles):
                        return file
                    elif utils.checkhasRol(
                        ['OG3-Membre', 'OG4-Afectat', 'OG5-Convidat'], roles):
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'hiddenfile':
                                return file
                            else:
                                raise Unauthorized
                        else:
                            return file
                    else:
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'visiblefile':
                                return file
                            else:
                                raise Unauthorized
                        elif (self.context.hiddenfile):
                            raise Unauthorized
                        elif (self.context.visiblefile):
                            return file
                        else:
                            raise Unauthorized

        elif organ_tipus == 'restricted_to_members_organ':
            if estatSessio == 'planificada':
                if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'], roles):
                    return file
                else:
                    raise Unauthorized
            if estatSessio == 'convocada':
                if self.context.portal_type in [
                        'genweb.organs.acta', 'genweb.organs.audio',
                        'genweb.organs.annex'
                ]:
                    if utils.checkhasRol([
                            'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                            'OG5-Convidat'
                    ], roles):
                        return file
                    else:
                        raise Unauthorized
                else:
                    if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'],
                                         roles):
                        return file
                    elif utils.checkhasRol(['OG3-Membre', 'OG5-Convidat'],
                                           roles):
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'hiddenfile':
                                return file
                            else:
                                raise Unauthorized
                        else:
                            return file
                    else:
                        raise Unauthorized
            if (estatSessio == 'realitzada' or estatSessio == 'tancada'
                    or estatSessio == 'en_correccio'):
                if self.context.portal_type in [
                        'genweb.organs.acta', 'genweb.organs.audio',
                        'genweb.organs.annex'
                ]:
                    if utils.checkhasRol([
                            'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                            'OG5-Convidat'
                    ], roles):
                        return file
                    else:
                        raise Unauthorized
                else:
                    if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'],
                                         roles):
                        return file
                    elif utils.checkhasRol(['OG3-Membre', 'OG5-Convidat'],
                                           roles):
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'hiddenfile':
                                return file
                            else:
                                raise Unauthorized
                        else:
                            return file
                    elif 'OG4-Afectat' in roles:
                        raise Unauthorized
                    else:
                        raise Unauthorized

        elif organ_tipus == 'restricted_to_affected_organ':
            if estatSessio == 'planificada':
                if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'], roles):
                    return file
                else:
                    raise Unauthorized
            if estatSessio == 'convocada':
                if self.context.portal_type in [
                        'genweb.organs.acta', 'genweb.organs.audio',
                        'genweb.organs.annex'
                ]:
                    if utils.checkhasRol([
                            'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                            'OG5-Convidat'
                    ], roles):
                        return file
                    else:
                        raise Unauthorized
                else:
                    if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'],
                                         roles):
                        return file
                    elif utils.checkhasRol(['OG3-Membre', 'OG5-Convidat'],
                                           roles):
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'hiddenfile':
                                return file
                            else:
                                raise Unauthorized
                        else:
                            return file
                    else:
                        raise Unauthorized
            if (estatSessio == 'realitzada' or estatSessio == 'tancada'
                    or estatSessio == 'en_correccio'):
                if self.context.portal_type in [
                        'genweb.organs.acta', 'genweb.organs.audio',
                        'genweb.organs.annex'
                ]:
                    if utils.checkhasRol([
                            'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                            'OG5-Convidat'
                    ], roles):
                        return file
                    else:
                        raise Unauthorized
                else:
                    if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'],
                                         roles):
                        return file
                    elif utils.checkhasRol(['OG3-Membre', 'OG5-Convidat'],
                                           roles):
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'hiddenfile':
                                return file
                            else:
                                raise Unauthorized
                        else:
                            return file
                    elif 'OG4-Afectat' in roles:
                        if (self.context.visiblefile
                                and self.context.hiddenfile):
                            if self.fieldname == 'visiblefile':
                                return file
                            else:
                                raise Unauthorized
                        if (self.context.hiddenfile):
                            raise Unauthorized
                        if (self.context.visiblefile):
                            return file
                    else:
                        raise Unauthorized
コード例 #15
0
    def canView(self):
        # Permissions to view ACORDS. Poden estar a 1 i 2 nivells
        # If manager Show all
        roles = utils.getUserRoles(self, self.context,
                                   api.user.get_current().id)
        if 'Manager' in roles:
            return True

        estatSessio = utils.session_wf_state(self)
        organ_tipus = self.context.organType

        if organ_tipus == 'open_organ':
            if estatSessio == 'planificada' and utils.checkhasRol(
                ['OG1-Secretari', 'OG2-Editor'], roles):
                return True
            elif estatSessio == 'convocada':
                return True
            elif estatSessio == 'realitzada':
                return True
            elif estatSessio == 'tancada':
                return True
            elif estatSessio == 'en_correccio':
                return True
            else:
                raise Unauthorized

        if organ_tipus == 'restricted_to_members_organ':
            if estatSessio == 'planificada' and utils.checkhasRol(
                ['OG1-Secretari', 'OG2-Editor'], roles):
                return True
            elif estatSessio == 'convocada' and utils.checkhasRol(
                ['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'],
                    roles):
                return True
            elif estatSessio == 'realitzada' and utils.checkhasRol(
                ['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'],
                    roles):
                return True
            elif estatSessio == 'tancada' and utils.checkhasRol(
                ['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'],
                    roles):
                return True
            elif estatSessio == 'en_correccio' and utils.checkhasRol(
                ['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'],
                    roles):
                return True
            else:
                raise Unauthorized

        if organ_tipus == 'restricted_to_affected_organ':
            if estatSessio == 'planificada' and utils.checkhasRol(
                ['OG1-Secretari', 'OG2-Editor'], roles):
                return True
            elif estatSessio == 'convocada' and utils.checkhasRol(
                ['OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG5-Convidat'],
                    roles):
                return True
            elif estatSessio == 'realitzada' and utils.checkhasRol([
                    'OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG4-Afectat',
                    'OG5-Convidat'
            ], roles):
                return True
            elif estatSessio == 'tancada' and utils.checkhasRol([
                    'OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG4-Afectat',
                    'OG5-Convidat'
            ], roles):
                return True
            elif estatSessio == 'en_correccio' and utils.checkhasRol([
                    'OG1-Secretari', 'OG2-Editor', 'OG3-Membre', 'OG4-Afectat',
                    'OG5-Convidat'
            ], roles):
                return True
            else:
                raise Unauthorized
コード例 #16
0
ファイル: document.py プロジェクト: UPCnet/genweb.organs
    def viewDocumentPublic(self):
        """ Cuando se muestra la parte pública del documento
        """
        roles = utils.getUserRoles(self, self.context,
                                   api.user.get_current().id)
        if 'Manager' in roles:
            return True

        organ_tipus = self.context.organType

        if self.context.defaultContent and self.context.alternateContent:
            if organ_tipus == 'open_organ':
                if utils.checkhasRol(
                    ['OG3-Membre', 'OG4-Afectat', 'OG5-Convidat'], roles):
                    return False
                else:
                    return True
            elif organ_tipus == 'restricted_to_members_organ':
                if utils.checkhasRol(['OG1-Secretari', 'OG2-Editor'], roles):
                    return True
                else:
                    return False
            elif organ_tipus == 'restricted_to_affected_organ':
                if utils.checkhasRol(
                    ['OG1-Secretari', 'OG2-Editor', 'OG4-Afectat'], roles):
                    return True
                else:
                    return False
        elif self.context.alternateContent:
            if organ_tipus == 'open_organ':
                if utils.checkhasRol([
                        'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                        'OG4-Afectat', 'OG5-Convidat'
                ], roles):
                    return True
                else:
                    return False
            elif organ_tipus == 'restricted_to_members_organ':
                if utils.checkhasRol([
                        'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                        'OG5-Convidat'
                ], roles):
                    return True
                else:
                    return False
            elif organ_tipus == 'restricted_to_affected_organ':
                if utils.checkhasRol([
                        'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                        'OG5-Convidat'
                ], roles):
                    return True
                else:
                    return False
        elif self.context.defaultContent:
            if organ_tipus == 'open_organ':
                return True
            elif organ_tipus == 'restricted_to_members_organ':
                if utils.checkhasRol([
                        'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                        'OG5-Convidat'
                ], roles):
                    return True
                else:
                    return False
            elif organ_tipus == 'restricted_to_affected_organ':
                if utils.checkhasRol([
                        'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                        'OG4-Afectat', 'OG5-Convidat'
                ], roles):
                    return True
                else:
                    return False
        else:
            raise Unauthorized
コード例 #17
0
ファイル: file.py プロジェクト: UPCnet/genweb.organs
    def viewReserved(self):
        """ Cuando se muestra la parte privada del FICHERO
        """
        roles = utils.getUserRoles(self, self.context,
                                   api.user.get_current().id)
        if 'Manager' in roles:
            return True

        organ_tipus = self.context.organType

        if self.context.visiblefile and self.context.hiddenfile:
            if organ_tipus == 'open_organ':
                if utils.checkhasRol([
                        'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                        'OG4-Afectat', 'OG5-Convidat'
                ], roles):
                    return True
                else:
                    return False
            elif organ_tipus == 'restricted_to_members_organ':
                if utils.checkhasRol([
                        'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                        'OG5-Convidat'
                ], roles):
                    return True
                else:
                    return False
            elif organ_tipus == 'restricted_to_affected_organ':
                if utils.checkhasRol([
                        'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                        'OG5-Convidat'
                ], roles):
                    return True
                else:
                    return False
        elif self.context.hiddenfile:
            if organ_tipus == 'open_organ':
                if utils.checkhasRol([
                        'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                        'OG4-Afectat', 'OG5-Convidat'
                ], roles):
                    return True
                else:
                    return False
            elif organ_tipus == 'restricted_to_members_organ':
                if utils.checkhasRol([
                        'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                        'OG5-Convidat'
                ], roles):
                    return True
                else:
                    return False
            elif organ_tipus == 'restricted_to_affected_organ':
                if utils.checkhasRol([
                        'OG1-Secretari', 'OG2-Editor', 'OG3-Membre',
                        'OG5-Convidat'
                ], roles):
                    return True
                else:
                    return False
        elif self.context.visiblefile:
            if organ_tipus == 'open_organ':
                return True
        else:
            if not self.context.visiblefile and not self.context.hiddenfile:
                return None
            else:
                raise Unauthorized