How to use the cartoview.app_manager.models.App 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 / models.py View on Github external
def set_app_order(sender, instance, **kwargs):
    # check if another app have the same order
    count = App.objects.filter(order=instance.order).count()
    # set app correct order
    if instance.order == 0 or count > 1:
        max_order = App.objects.aggregate(
            Max("order"))["order__max"]
        if max_order:
            instance.order = max_order+1
        else:
            instance.order = 1
github cartologic / cartoview / cartoview / app_manager / admin.py View on Github external
# -*- coding: utf-8 -*-
from django.contrib import admin
from .models import App, AppStore, AppType, AppInstance
from guardian.admin import GuardedModelAdmin
# Register your models here.


@admin.register(App)
class AppModelAdmin(GuardedModelAdmin):
    pass


@admin.register(AppStore)
class AppStoreModelAdmin(admin.ModelAdmin):
    pass


@admin.register(AppType)
class AppTypeModelAdmin(admin.ModelAdmin):
    pass


@admin.register(AppInstance)
class AppInstanceModelAdmin(admin.ModelAdmin):
github cartologic / cartoview / cartoview / app_manager / installer.py View on Github external
def remove_unwanted(info):
    dictionary = info.__dict__.get('_data', {}) if info else {}
    app_fields = [
        str(field.name)
        for field in sorted(App._meta.fields + App._meta.many_to_many)
    ]
    app_fields.append("type")
    clean_data = {
        k: v
        for k, v in dictionary.items() if str(k) in app_fields
    }
    return clean_data
github cartologic / cartoview / cartoview / app_manager / installer.py View on Github external
def delete_app(self):
        try:
            app = App.objects.get(name=self.name)
            app.delete()
        except App.DoesNotExist:
            pass
github cartologic / cartoview / cartoview / app_manager / rest.py View on Github external
active = bundle.obj.config.active
        return active

    def dehydrate_pending(self, bundle):
        app = bundle.obj
        cartoview_app = CartoviewApp.objects.get(app.name)
        return cartoview_app.pending

    def dehydrate_categories(self, bundle):
        return [category.name for category in bundle.obj.category.all()]

    def dehydrate_app_instance_count(self, bundle):
        return bundle.obj.appinstance_set.all().count()

    class Meta():
        queryset = App.objects.all().order_by('order')
        filtering = {
            "id": ALL,
            "name": ALL,
            "title": ALL,
            "store": ALL_WITH_RELATIONS,
            "single_instance": ALL
        }
        can_edit = True

    def _build_url_exp(self, view, single=False):
        name = view + "_app"
        if single:
            exp = r"^(?P%s)/(?P\w[\w/-]*)/%s%s$" % (
                self._meta.resource_name,
                view,
                trailing_slash(),
github cartologic / cartoview / cartoview / app_manager / installer.py View on Github external
def remove_unwanted(cls, info):
        dictionary = info.__dict__.get('_data', {})
        app_fields = [
            str(field.name)
            for field in sorted(App._meta.fields + App._meta.many_to_many)
        ]
        app_fields.append("type")
        clean_data = {
            k: v
            for k, v in dictionary.items() if str(k) in app_fields
        }
        return clean_data