示例#1
0
    def check_perms(self, obj, perm_type):
        from core.plugins.loader import plugins
        default_scope = [Scope(ZonePerm("user", "current"), BlockPerm("plugin", "current"))]

        plugin = obj.plugin

        plugin_cls = plugins[plugin.hashkey]
        plugin_model_cls = None
        for m in plugin_cls.models:
            if not hasattr(obj, "plugin_model") or obj.plugin_model is None:
                return False
            if m.plugin_model_proxy.hashkey == obj.plugin_model.hashkey:
                plugin_model_cls = m

        if plugin_model_cls is None:
            raise InvalidModelException()

        perms = getattr(plugin_model_cls, "perms")
        if not isinstance(perms, list):
            perms = default_scope

        if perm_type == "view":
            return self.check_view_perms(perms, obj)
        elif perm_type == "update":
            return self.check_update_perms(perms, obj)
        elif perm_type == "delete":
            return self.check_delete_perms(perms, obj)

        return False
示例#2
0
class MoodModel(PluginDataModel):
    metric_proxy = MetricProxy(name="mood")
    source_proxy = SourceProxy(name="self")
    perms = [
        Scope(ZonePerm("user", current=True), BlockPerm("plugin",
                                                        current=True))
    ]

    score = IntegerField()
示例#3
0
class SettingsModel(PluginDataModel):
    metric_proxy = MetricProxy(name="settings")
    source_proxy = SourceProxy(name="self")
    perms = [
        Scope(ZonePerm("user", current=True), BlockPerm("plugin",
                                                        current=True))
    ]

    your_name = Field()
示例#4
0
class DataModel(PluginDataModel):
    metric_proxy = MetricProxy(name="data")
    source_proxy = SourceProxy(name="self")
    perms = [
        Scope(ZonePerm("user", current=True), BlockPerm("plugin",
                                                        current=True))
    ]

    number = Field()
    text = Field()
示例#5
0
class Checkins(PluginDataModel):
    metric_proxy = MetricProxy(name="checkins")
    source_proxy = SourceProxy(name="foursquare")
    perms = [Scope(ZonePerm("user", current=True), BlockPerm("plugin", all=True))]

    type = Field()
    source = Field()
    venue = Field()
    location = DictField()
    latitude = Field()
    longitude = Field()
    visit_count = FloatField()
    date = DateTimeField
示例#6
0
class NewsFeed(PluginDataModel):
    metric_proxy = MetricProxy(name="newsfeed")
    source_proxy = SourceProxy(name="facebook")
    perms = [
        Scope(ZonePerm("user", current=True), BlockPerm("plugin", all=True))
    ]

    date = DateTimeField()
    update_time = DateTimeField()
    from_id = Field()
    from_name = Field()
    story = Field()
    type = Field()
    likes = ListField()
    comments = ListField()
    message = Field()
    name = Field()
    shares = IntegerField()
    picture = Field()
示例#7
0
class TestLoosePermissions(PluginDataModel):
    metric_proxy = MetricProxy(name="test2")
    source_proxy = SourceProxy(name="test2")
    perms = [Scope(ZonePerm("user", all=True), BlockPerm("plugin", all=True))]