Beispiel #1
0
 def setUp(self, middleware=lambda: None):
     setup_database()
     create_database()
     load_plugins()
     middleware()
     for plugin in Plugin.select():
         plugin.activated = 'yes'
     with open(file='/tmp/config.yaml', mode='w+') as outfile:
         dump(self.config, outfile, default_flow_style=False)
     self.ictv_app = get_app('/tmp/config.yaml')
     print(self.ictv_app)
     self.testApp = TestApp(self.ictv_app.wsgifunc())
Beispiel #2
0
 def instantiate_plugins(self, app):
     """
         Iterates over the plugins present in the plugin directory and instantiate each of them.
         :param app: The ICTV Core web.py app
     """
     # two alternatives : select activated plugins and then query on PluginChannel to get the channel number
     # or                 select all channels and add mapping if its plugin is activated.
     Plugin.update_plugins(self.list_plugins())  # Updates plugins database
     plugins = [p for p in Plugin.select() if p.channels]  # PluginChannel.select().throughTo.plugin.distinct() is not working a.t.m., see https://github.com/sqlobject/sqlobject/issues/137
     for p in plugins:
         if p.activated == 'yes':
             self.instantiate_plugin(app, p)
         elif p.activated == 'no':
             self.missing_dependencies[p.name] = self.get_plugin_missing_dependencies(p.name)
Beispiel #3
0
    def render_page(self, current_user=None, users=None):
        if current_user is None:
            current_user = User.get(self.session['user']['id'])
        if UserPermissions.channel_administrator in current_user.highest_permission_level:
            users = User.select()

        channels = list(Channel.get_visible_channels_of(current_user))

        plugin_channels = []
        bundles = []

        for channel in channels:
            if type(channel) is PluginChannel:
                plugin_channels.append(channel)
            elif type(channel) is ChannelBundle:
                bundles.append(channel)

        return self.renderer.channels(
            plugin_channels=plugin_channels,
            bundles=bundles,
            current_user=current_user,
            users=users,
            activated_plugins=Plugin.selectBy(activated='yes'),
            found_plugins=Plugin.select(NOT(Plugin.q.activated == 'notfound')))