How to use the cartoview.apps_handler.config.CartoviewApp function in cartoview

To help you get started, we’ve selected a few cartoview examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cartologic / cartoview / cartoview / app_manager / installer.py View on Github external
def add_carto_app(self):
        if not CartoviewApp.objects.app_exists(self.name):
            CartoviewApp({
                'name': self.name,
                'active': True,
                'order': self.get_app_order(),
                'pending': True
            })
            CartoviewApp.save()
        else:
            carto_app = CartoviewApp.objects.get(self.name)
            carto_app.pending = True
            carto_app.commit()
            CartoviewApp.save()
github cartologic / cartoview / cartoview / app_manager / installer.py View on Github external
def completely_remove(self):
        self.delete_app()
        self.delete_app_tables()
        self.delete_app_dir()
        CartoviewApp.objects.pop(self.name, None)
        CartoviewApp.save()
github cartologic / cartoview / cartoview / app_manager / management / commands / load_current_apps.py View on Github external
def handle(self, *args, **options):
        carto_apps = CartoviewApp.objects.get_active_apps().values()
        user = Profile.objects.filter(is_superuser=True).first()
        for carto_app in carto_apps:
            app_name = carto_app.name
            query = App.objects.filter(name=app_name)
            if query.count() == 0:
                try:
                    # ensure that the folder is python module
                    importlib.import_module(app_name)
                    app = App(
                        title=app_name,
                        name=app_name,
                        status="Alpha",
                        license=None,
                        version='1.0.0',
                        installed_by=user,
                        store=None,
github cartologic / cartoview / cartoview / app_manager / settings.py View on Github external
def load_apps(APPS_DIR):
    with lock:
        from cartoview.apps_handler.utils import create_apps_dir
        from cartoview.apps_handler.config import CartoviewApp
        global CARTOVIEW_APPS
        global APPS_SETTINGS
        create_apps_dir(APPS_DIR)
        if APPS_DIR not in sys.path:
            sys.path.append(APPS_DIR)
        logger.info("Loading Cartoview Apps.....")
        CartoviewApp.load(apps_dir=APPS_DIR)
        for app in CartoviewApp.objects.values():
            try:
                logger.info("Check if {} Healthy.\n".format(app.name))
                # ensure that the folder is python module
                app_module = importlib.import_module(app.name)
                app_dir = os.path.dirname(app_module.__file__)
                app_settings_file = os.path.join(app_dir, 'settings.py')
                libs_dir = os.path.join(app_dir, 'libs')
                if os.path.exists(app_settings_file):
                    # By doing this instead of import, app/settings.py can
                    # refer to local variables from settings.py without
                    # circular imports.
                    app_settings_file = os.path.realpath(app_settings_file)
                    APPS_SETTINGS += (app_settings_file, )
                if os.path.exists(libs_dir) and libs_dir not in sys.path:
                    logger.info(
                        "Install {} libs folder to the system.\n".format(
github cartologic / cartoview / cartoview / apps_handler / config.py View on Github external
def from_json(self, data):
        def cartoview_app_dict(name, data):
            d = {'name': name}
            d.update(data)
            return d

        try:
            apps = json.loads(data)
            self._app_data = {
                k: CartoviewApp(cartoview_app_dict(k, v))
                for k, v in apps.items()
            }
            self.__sort_apps()
            return self._app_data
        except BaseException:
            return AppsDict()