Skip to content
Snippets Groups Projects
Select Git revision
  • cbd6057fdda03f4e7c63e08cb55ce0d9957637f0
  • main default protected
  • release
  • OZG-7856_schadcode_scanner
  • ci-pipeline
  • OZG-7526-signatur-nicht-uebernommen
  • OZG-6223-zip-download-bug
  • OZG-7367-tooltip-extension
  • OZG-7023-OZG-6956-E2E-externe-Stellen
  • OZG-6238-npm-durch-pnpm-ersetzen
  • release-admin
  • release-info
  • OZG-6700-admin-feature-toggle
  • E2E-Updates
  • OZG-7047-tooltips
  • OZG-6957-e2e-fachstellen-oe-daten
  • OZG-7006-ZuarbeitAnfragen
  • temp_OZG-7027
  • unit-tests-hotfix
  • OZG-6731-POC-keycloakResourceService-with-multiple-stateResources
  • e2e-add-zufi-version
  • 2.26.0
  • 2.25.0
  • 2.24.2
  • 2.24.1
  • 2.24.0
  • 2.23.0
  • 2.22.0
  • 2.21.0
  • 2.20.0
  • 2.21.0-SNAPSHOT
  • 2.19.0
  • 2.18.0
  • 2.17.1
  • 1.3.0
  • release-admin-1.3.0
  • release-info-1.3.0
  • 2.17.0
  • 2.16.0
  • 2.15.0
  • release-admin-1.1.0
41 results

environment.model.ts

Blame
  • plugin.py 1.78 KiB
    import os 
    
    
    #from ckan
    import ckan.plugins as plugins
    
    #pdf_to_thumbnail 
    import thumbnail 
    import action as thumbnail_action
    import helpers as thumbnail_helpers
    
    import logging
    log = logging.getLogger(__name__)
    
    
    class ThumbnailPlugin(plugins.SingletonPlugin):
        plugins.implements(plugins.IResourceController, inherit=True)
        plugins.implements(plugins.IConfigurer, inherit=True)
        plugins.implements(plugins.IActions, inherit=True)
        plugins.implements(plugins.ITemplateHelpers)
    
    
    #IResourceController
        def after_create(self, context, resource):        
            _, size, filename = thumbnail.create_thumbnail(context, resource)
            thumbnail.write_thumbnail_into_package(context, resource, size, filename)
            
        def after_update(self, context, resource):
            thumbnail.check_and_create_thumbnail_after_update(context, resource)
                    
        def after_delete(self, context, resources):
            thumbnail.create_thumbnail_for_last_resource(context, resources)
                
    #IConfigurer 
    
        def update_config(self, config_):
            storage_path = config_.get('ckan.storage_path')
            public_dir = os.path.join(storage_path, 'thumbnail')
            if config_.get('extra_public_paths'):
                config_['extra_public_paths'] += ',' + public_dir
            else:
                config_['extra_public_paths'] = public_dir
    
    #IActions
    
        def get_actions(self):
            return {'package_delete': thumbnail_action.before_package_delete,
                    'package_update': thumbnail_action.before_package_update 
                    }
    
    #ITemplateHelpers
    
        def get_helpers(self):
            
            return {
                    'thumbnail_namespace':thumbnail_helpers.thumbnail_namespace,
                    'thumbail_get_download_link':thumbnail_helpers.get_download_link_for_thumbnail
                    }