How to use the cartoview.app_manager.models.App.objects.all 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 / management / commands / update_current_apps.py View on Github external
def handle(self, *args, **options):
        # stores = AppStore.objects.filter(is_default=True)
        # store = stores.first()
        for index, app in enumerate(App.objects.all()):
            try:
                if app.store:
                    data = self.get_data_from_store(app.name, app.store.url)
                    api_obj = StoreAppResource()
                    bundle = api_obj.build_bundle(data=data)
                    app_obj = api_obj.obj_get(bundle)
                    data = app_obj
                    app_serializer = AppJson(remove_unwanted(data))
                    app = app_serializer.get_app_object(app)
                    app.save()
                    print('[%-2s] %-35s  updated' % (index + 1, app.name))
                else:
                    print('[%-2s] %-35s  Ignored because No Store Available' %
                          (index + 1, app.name))
            except Exception as ex:
                print('[%-2s] %-35s  Failed error message %-25s' %
github cartologic / cartoview / cartoview / cms / db_models / app_manager / apps_list.py View on Github external
def apps_list(self):
        apps = [app.value for app in self.apps]
        if len(apps) == 0:
            apps = App.objects.all()
        return apps
github cartologic / cartoview / cartoview / api / views / app_manager.py View on Github external
def perform_create(self, serializer):
        serializer.save(owner=self.request.user)


class BookmarkViewSet(viewsets.ModelViewSet):
    queryset = Bookmark.objects.all().distinct()
    serializer_class = BookmarkSerializer
    permission_classes = (permissions.IsAuthenticatedOrReadOnly,)

    def perform_create(self, serializer):
        serializer.save(owner=self.request.user)


class AppViewSet(viewsets.ModelViewSet):
    queryset = App.objects.all().distinct()
    serializer_class = AppSerializer
    permission_classes = (AppPermission,)
    filterset_class = AppFilter

    def perform_create(self, serializer):
        serializer.save(installed_by=self.request.user)

    @action(detail=False, methods=["post"],
            permission_classes=[AppPermission])
    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)
github cartologic / cartoview / cartoview / app_manager / rest.py View on Github external
def get_object_list(self, request):
        __inactive_apps = [
            app.id for app in App.objects.all()
            if app.config and not app.config.active
        ]
        __inactive_apps_instances = [
            instance.id for instance in AppInstance.objects.filter(
                app__id__in=__inactive_apps)
        ]
        active_app_instances = super(AppInstanceResource, self) \
            .get_object_list(
            request).exclude(
            id__in=__inactive_apps_instances)

        return active_app_instances
github cartologic / cartoview / cartoview / app_manager / views.py View on Github external
def manage_apps(request):
    from cartoview.version import get_backward_compatible, get_current_version
    from pkg_resources import parse_version
    apps = App.objects.all()
    _version = parse_version(get_current_version())._version
    release = _version.release
    version = [str(x) for x in release]
    context = {
        'apps': apps,
        'site_apps': get_apps_names(),
        'version_info': {
            'current_version': ".".join(version),
            'backward_versions': get_backward_compatible()
        }
    }
    return render(request, 'app_manager/manage.html', context)
github cartologic / cartoview / cartoview / app_manager / context_processors.py View on Github external
def cartoview_processor(request):
    permitted = get_objects_for_user(request.user,
                                     'base.view_resourcebase')
    cartoview_counters = {
        "apps": App.objects.count(),
        "app_instances": AppInstance.objects.filter(id__in=permitted).count(),
        "maps": Map.objects.filter(id__in=permitted).count(),
        "layers": Layer.objects.filter(id__in=permitted).count(),
        "users": Profile.objects.exclude(username="AnonymousUser").count(),
        "groups": Group.objects.exclude(name="anonymous").count()
    }

    defaults = {
        'apps': App.objects.all().order_by('order'),
        'CARTOVIEW_VERSION': get_version(__version__),
        'APPS_MENU': settings.APPS_MENU,
        'apps_instance_count': AppInstance.objects.all().count(),
        "cartoview_counters": cartoview_counters,
        'instances': AppInstance.objects.all().order_by('app__order')[:5]
    }
    return defaults
github cartologic / cartoview / cartoview / app_manager / installer.py View on Github external
def get_app_order(self):
        apps = App.objects.all()
        max_value = apps.aggregate(
            Max('order'))['order__max'] if apps.exists() else 0
        return max_value + 1
github cartologic / cartoview / cartoview / app_manager / installer.py View on Github external
def get_app_order(self):
        apps = App.objects.all()
        max_value = apps.aggregate(
            Max('order'))['order__max'] if apps.exists() else 0
        return max_value + 1