How to use the cartoview.app_manager.models.App.objects.filter 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 / apps_helper.py View on Github external
def installed_apps():
    from .models import App
    apps = App.objects.filter(is_suspended=False).order_by('order')
    return apps
github cartologic / cartoview / cartoview / app_manager / views.py View on Github external
def installed_apps():
    from .models import App
    apps = App.objects.filter().order_by('order')
    return apps
github cartologic / cartoview / cartoview / app_manager / views.py View on Github external
def move_down(request, app_id):
    app = App.objects.get(id=app_id)
    next_app = App.objects.get(
        order=App.objects.filter(
            order__gt=app.order).aggregate(Min('order'))['order__min'])
    order = app.order
    app.order = next_app.order
    next_app.order = order
    app.save()
    next_app.save()
    return HttpResponse(
        json.dumps({
            "success": True
        }), content_type="application/json")
github cartologic / cartoview / cartoview / api / views / app_manager.py View on Github external
def install(self, request):
        data = request.data
        app_name = data.get("app_name", None)
        store_id = data.get("store_id", None)
        version = data.get("app_version", None)
        if not app_name or not store_id or not version:
            return Response({"details": "invalid data"}, status=400)
        qs = App.objects.filter(name=app_name)
        if qs.count() > 0:
            permitted = request.user.has_perm("install_app", qs.first())
            if not permitted:
                return Response({"details":
                                 "You don't have permission to install <> app".
                                 format(app_name)}, status=403)
            if parse_version(version) <= parse_version(qs.first().version):
                return Response({"details": "app already installed"},
                                status=400)

        try:
            installer = AppInstaller(
                app_name, store_id, version, user=request.user)
            installer.install()
        except BaseException as e:
            if isinstance(e, AppAlreadyInstalledException):
github cartologic / cartoview / cartoview / app_manager / views.py View on Github external
def move_up(request, app_id):
    app = App.objects.get(id=app_id)
    prev_app = App.objects.get(
        order=App.objects.filter(
            order__lt=app.order).aggregate(Max('order'))['order__max'])
    order = app.order
    app.order = prev_app.order
    prev_app.order = order
    app.save()
    prev_app.save()
    return HttpResponse(
        json.dumps({
            "success": True
        }), content_type="application/json")
github cartologic / cartoview / cartoview / app_manager / management / commands / install_app.py View on Github external
def handle(self, *args, **options):
        app_name = options.get('name')
        app_version = options.get('app_version')
        store = AppStore.objects.get(is_default=True)
        q = App.objects.filter(name=app_name)
        try:
            if q.count() == 0 or (q.first() and
                                  compare_version(q.first().version,
                                                  app_version)):
                installer = AppInstaller(app_name, store.id, app_version)
                installer.install()
        except Exception as ex:
            logger.error(ex.message)
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