<gh_stars>0
from app.plugins.models import PluginRegistry
from app.management.models import SettingsGroup, Setting
from ..schemas import PluginSchema


class SettingsManager():
    def __init__(self):
        self.plugin_registry_schmea = PluginSchema()

    def determine_active_settings(self, slug, plugin):
        slug = slug if slug else 'general'
        if plugin is not None:
            pluggin_data = PluginRegistry.query.filter_by(name=plugin
                                                          ).first_or_404()
            settings = self.plugin_registry_schmea.dump(pluggin_data)

        elif slug is not None:
            group_obj = SettingsGroup.query.filter_by(key=slug).first_or_404()
            settings = Setting.get_settings(group_obj)

        return settings

from app.plugins.models import PluginRegistry
from app.management.models import SettingsGroup, Setting
from ..schemas import PluginSchema


class SettingsManager():
    def __init__(self):
        self.plugin_registry_schmea = PluginSchema()

    def determine_active_settings(self, slug, plugin):
        slug = slug if slug else 'general'
        if plugin is not None:
            pluggin_data = PluginRegistry.query.filter_by(name=plugin
                                                          ).first_or_404()
            settings = self.plugin_registry_schmea.dump(pluggin_data)

        elif slug is not None:
            group_obj = SettingsGroup.query.filter_by(key=slug).first_or_404()
            settings = Setting.get_settings(group_obj)

        return settings