コード例 #1
0
ファイル: Modifiers.py プロジェクト: SmartTeleMax/qps
    def permissions(self):
        from qps.qUtils import interpolateString as render
        item = self.item
        permissions = dict(self.defaultPermissions)
        for name, template in self.params.get('templates', []):
            value = getattr(item, name)
            if value:
                group, perm = template
                group = render(group, {'name': name, 'value': value})
                permissions[group] = perm

        for name, template in self.params.get('collectionTemplates', []):
            for value in getattr(item, name):
                if value:
                    group, perm = template
                    group = render(group, {'name': name, 'value': value})
                    permissions[group] = perm

        return permissions.items()
コード例 #2
0
ファイル: qModifiers.py プロジェクト: SmartTeleMax/qps
        def groups(self):
            from qps.qUtils import interpolateString as render

            item = self.item
            groups = self.defaultGroups
            for name, template in self.params.get("templates", []):
                value = getattr(item, name)
                if type(template) in (list, tuple):
                    templateTrue, templateFalse = template
                else:
                    templateTrue, templateFalse = (template, None)
                if value and templateTrue:
                    groups.append(render(templateTrue, {"name": name, "value": value}))
                elif templateFalse:
                    groups.append(render(templateFalse, {"name": name, "value": value}))

            for name, template in self.params.get("collectionTemplates", []):
                for value in getattr(item, name):
                    if value:
                        groups.append(render(template, {"name": name, "value": value}))

            return groups