How to use the cartoview.app_manager.models.AppInstance 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 / admin.py View on Github external
installer.uninstall()
        except Exception as e:
            return HttpResponseServerError(e.message)


uninstall_selected.short_description = "Uninstall Selected Apps"


@admin.register(App)
class AppAdmin(admin.ModelAdmin):
    ordering = ('order',)
    actions = [uninstall_selected]


admin.site.register(AppType)
admin.site.register(AppInstance)
admin.site.register(AppStore)
github cartologic / cartoview / cartoview / app_manager / models.py View on Github external
@receiver(post_delete, sender=AppInstance)
def invalidate_appinstance_cache(sender, instance, **kwargs):
    cache.delete("appinstances")
github cartologic / cartoview / cartoview / app_manager / utils.py View on Github external
def resolve_appinstance(request,
                        appinstanceid,
                        permission='base.change_resourcebase',
                        msg=_PERMISSION_MSG_GENERIC,
                        **kwargs):
    """
    Resolve the document by the provided primary key
    and check the optional permission.
    """
    return resolve_object(
        request,
        AppInstance, {'pk': appinstanceid},
        permission=permission,
        permission_msg=msg,
        **kwargs)
github cartologic / cartoview / cartoview / app_manager / rest.py View on Github external
class AppInstanceResource(CommonModelApi):
    launch_app_url = fields.CharField(null=True, blank=True)
    edit_url = fields.CharField(null=True, blank=True)
    app = fields.ForeignKey(AppResource, 'app', full=True, null=True)
    map = fields.ForeignKey(MapResource, 'related_map', full=True, null=True)
    owner = fields.ForeignKey(
        ProfileResource, 'owner', full=True, null=True, blank=True)
    keywords = fields.ListField(null=True, blank=True)

    class Meta(CommonMetaApi):
        filtering = CommonMetaApi.filtering
        always_return_data = True
        filtering.update({'app': ALL_WITH_RELATIONS, 'featured': ALL})
        queryset = AppInstance.objects.distinct().order_by('-date')
        if settings.RESOURCE_PUBLISHING:
            queryset = queryset.filter(is_published=True)
        resource_name = 'appinstances'
        allowed_methods = ['get', 'post', 'put']
        excludes = ['csw_anytext', 'metadata_xml']
        authorization = GeoNodeAuthorization()

    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)
        ]
github cartologic / cartoview / cartoview / app_manager / views.py View on Github external
def save_instance(self, instance_id, owner, title, config, abstract,
                      map_id):
        if instance_id is None:
            instance_obj = AppInstance()
            instance_obj.app = App.objects.get(name=self.app_name)
            instance_obj.owner = owner
        else:
            instance_obj = AppInstance.objects.get(pk=instance_id)

        instance_obj.title = title
        instance_obj.config = config
        instance_obj.abstract = abstract
        instance_obj.map_id = map_id
        instance_obj.save()
        return instance_obj
github cartologic / cartoview / cartoview / basic / geonode_map_application / models.py View on Github external
from geonode.maps.models import Map as GeonodeMap
from cartoview.app_manager.models import AppInstance
import json

class BaseMapApp(AppInstance):
    geonode_map = models.ForeignKey(GeonodeMap, related_name="'%(app_label)s_%(class)s'")
    map_config = models.TextField(null=True, blank=True)

    @property
    def config_obj(self):
        try:
            return json.loads(self.map_config)
        except:
            return {}

    class Meta(AppInstance.Meta):
        abstract = True
github cartologic / cartoview / cartoview / app_manager / utils.py View on Github external
def create_thumbnail(self):
        instance = self.instance
        if not isinstance(instance, AppInstance):
            return
        instance_map = getattr(instance, 'related_map', instance.map)
        if instance_map:
            instance.thumbnail_url = instance_map.get_thumbnail_url()
            instance.save()