Пример #1
0
    def command(self):
        self._load_config()
        cmd = self.args[0]
        if cmd == "import":
            from ckanext.ngds.importer.importer import BulkUploader

            bulkLoader = BulkUploader()
            bulkLoader.execute_bulk_upload()
        elif cmd == "doc-index":
            from ckanext.ngds.ngdsui.misc.helpers import process_resource_docs_to_index

            process_resource_docs_to_index()
        elif cmd == "compile_client_scripts":
            from ckanext.ngds.lib.compile_client_scripts.script_compiler import ScriptCompiler
            import ckanext.ngds.ngdsui as uimodule

            print ScriptCompiler
            uipath = os.path.dirname(os.path.abspath(uimodule.__file__))
            sc = ScriptCompiler(uipath)
            sc.compile_less()
            sc.minify_js()

        elif cmd == "create_ngds_org":
            from ckanext.ngds.lib.customize.customize import Customize
            cust = Customize()
            cust.customize()
        else:
            print "Command %s not recognized" % cmd
Пример #2
0
 def test_loadclientconfig(self):
     client_config_path = os.path.abspath(
         os.path.join(os.path.dirname(__file__), "testdata",
                      "ckanclient.cfg"))
     bulkuploader = BulkUploader(client_config=client_config_path)
     assert_equals(bulkuploader.url, 'http://localhost:5000/api')
     assert_equals(bulkuploader.api_key,
                   '5364e36d-0bd0-43af-be38-452149466950')
Пример #3
0
        Executes a bulk upload job. This function can only be triggered by an admin via the bulk upload page.
        """
        context = {
            'model': model,
            'session': model.Session,
            'user': c.user or c.author
        }

        try:
            check_access('execute_bulkupload', context, None)
        except NotAuthorized, error:
            abort(401, error.__str__())

        from ckanext.ngds.importer.importer import BulkUploader

        bulkLoader = BulkUploader()
        bulkLoader.execute_bulk_upload()

        h.flash_notice(toolkit._(
            'Initiated Bulk Upload process and it is running in the background.'
        ),
                       allow_html=True)
        url = h.url_for(
            controller=
            'ckanext.ngds.ngdsui.controllers.contribute:ContributeController',
            action='bulkupload_list')
        redirect(url)

    @jsonify
    def validate_resource(self):
        """
Пример #4
0
 def test_loadclientconfig_3(self):
     client_config_path = os.path.abspath(
         os.path.join(os.path.dirname(__file__), "testdata",
                      "ckanclient_without_host.cfg"))
     bulkuploader = BulkUploader(client_config=client_config_path)
Пример #5
0
        return render('contribute/bulkupload_list.html')

    def execute_bulkupload(self):
        """
        Executes a bulk upload job. This function can only be triggered by an admin via the bulk upload page.
        """
        context = {'model': model, 'session': model.Session, 'user': c.user or c.author}

        try:
            check_access('execute_bulkupload', context, None)
        except NotAuthorized, error:
            abort(401, error.__str__())

        from ckanext.ngds.importer.importer import BulkUploader

        bulkLoader = BulkUploader()
        bulkLoader.execute_bulk_upload()

        h.flash_notice(toolkit._('Initiated Bulk Upload process and it is running in the background.'), allow_html=True)
        url = h.url_for(controller='ckanext.ngds.ngdsui.controllers.contribute:ContributeController',
                        action='bulkupload_list')
        redirect(url)

    @jsonify
    def validate_resource(self):
        """
        Validate a resource to ensure that it conforms to NGDS standards. For ex: if a resource specifies that it conforms to a content model, that validation occurs here.
        """
        data = clean_dict(unflatten(tuplize_dict(parse_params(
            request.params))))