Example #1
0
    def get_plugin_details(obj):
        if obj.plugin:
            plugin = PluginUtils.get_plugin(config_type='staff',
                                            plugin_label=obj.plugin.app_label)
            has_settings_component = PluginUtils.has_component(
                config_type='staff',
                plugin_label=obj.plugin.app_label,
                component_name='ServerSettings')

            return {
                'label': obj.plugin.app_label,
                'id': obj.plugin.id,
                'display_name': obj.plugin.display_name,
                'has_settings_component': has_settings_component,
                'has_server_settings': True,
                'server_settings': plugin.server_settings
            }
        else:
            return None
Example #2
0
    def get_states(self, request: Request):
        del request  # unused
        plugin_instance = PluginUtils.get_plugin(
            config_type=self.config_type,
            plugin_label=self.plugin_label,
        )
        if plugin_instance and self.config_type in plugin_instance.states:
            states_data, found = plugin_instance.states[self.config_type].get_javascript()

            if found:
                return Response(data={
                    'states': states_data
                })
            else:
                LOG.error('States javascript found for plugin {}:{}'.format(self.config_type, self.plugin_label))
                return HttpResponse(status=204)
        else:
            LOG.error('States not found for plugin {}:{}'.format(self.config_type, self.plugin_label))
            return HttpResponse(status=204)