diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e9876d1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +.ropeproject +node_modules +bower_components + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +sdist/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Sphinx documentation +docs/_build/ \ No newline at end of file diff --git a/ckanext/relation/controller.py b/ckanext/relation/controller.py index 7b23be0..4cae8ef 100644 --- a/ckanext/relation/controller.py +++ b/ckanext/relation/controller.py @@ -2,8 +2,8 @@ import ckan.plugins as p from ckan.lib.base import BaseController import ckan.lib.helpers as h -from ckan.common import OrderedDict, _, json, request, c, g, response, config -from urllib import urlencode +from ckan.common import OrderedDict, _, json, request, common, c, g, response, config +from urllib.parse import urlencode import cgi from paste.deploy.converters import asbool import ckan.logic as logic @@ -16,9 +16,10 @@ log = logging.getLogger(__name__) -render = base.render -abort = base.abort +#render = base.render +#abort = base.abort #redirect = base.redirect + redirect = h.redirect_to NotFound = logic.NotFound NotAuthorized = logic.NotAuthorized @@ -46,19 +47,19 @@ def _resource_form(self, package_type): def finalrel(self, id, data=None, errors=None): if request.method == "POST": pass - c.link = str("/dataset/relationship/edit/" + id) + link = str("/dataset/relationship/edit/" + id) return render("package/new_data_relation.html", extra_vars={"package_id": id}) def new_relation(self, id): - c.link = str("/dataset/relationship/edit/" + id) + link = str("/dataset/relationship/edit/" + id) if request.method == "POST": save_action = request.params.get("save") print("new data dictionary !!!!!!!!!!!!!!!!") context = { "model": model, "session": model.Session, - "user": c.user or c.author, - "auth_user_obj": c.userobj, + "user": c.user or author, + "auth_user_obj": userobj, } # Remove button in the edit page @@ -111,7 +112,7 @@ def new_relation(self, id): if save_action == "go-metadata": # XXX race condition if another user edits/deletes - h.redirect_to(controller="package", action="read", id=id) + h.redirect_to('package.read', id=id) redirect("/dataset/relationship/edit/" + id) @@ -145,13 +146,13 @@ def new_resource_ext(self, id, data=None, errors=None, error_summary=None): context = { "model": model, "session": model.Session, - "user": c.user or c.author, - "auth_user_obj": c.userobj, + "user": user or author, + "auth_user_obj": userobj, } # see if we have any data that we are trying to save data_provided = False - for key, value in data.iteritems(): + for key, value in data.items(): if ( value or isinstance(value, cgi.FieldStorage) ) and key != "resource_type": @@ -178,7 +179,7 @@ def new_resource_ext(self, id, data=None, errors=None, error_summary=None): if save_action == "go-dataset": # go to final stage of adddataset - redirect(h.url_for(controller="package", action="edit", id=id)) + redirect(h.url_for('package.edit', id=id)) # see if we have added any resources try: data_dict = get_action("package_show")(context, {"id": id}) @@ -211,7 +212,7 @@ def new_resource_ext(self, id, data=None, errors=None, error_summary=None): dict(context, allow_state_change=True), dict(data_dict, state="active"), ) - redirect(h.url_for(controller="package", action="read", id=id)) + redirect(h.url_for('package.read', id=id)) data["package_id"] = id try: @@ -220,7 +221,7 @@ def new_resource_ext(self, id, data=None, errors=None, error_summary=None): get_action("resource_update")(context, data) else: get_action("resource_create")(context, data) - except ValidationError, e: + except ValidationError as e: errors = e.error_dict error_summary = e.error_summary return self.new_resource_ext(id, data, errors, error_summary) @@ -236,7 +237,7 @@ def new_resource_ext(self, id, data=None, errors=None, error_summary=None): dict(data_dict, state="active"), ) h.flash_notice(_("Dataset has been deleted.")) - h.redirect_to(controller="package", action="read", id=id) + h.redirect_to('package.read', id=id) elif save_action == "go-datadict": data_dict = get_action("package_show")(context, {"id": id}) @@ -252,19 +253,19 @@ def new_resource_ext(self, id, data=None, errors=None, error_summary=None): # redirect(h.url_for(controller='package', action='finaldict', id=id)) elif save_action == "go-dataset": # go to first stage of add dataset - h.redirect_to(controller="package", action="edit", id=id) + h.redirect_to('package.edit', id=id) elif save_action == "go-dataset-complete": # go to first stage of add dataset - h.redirect_to(controller="package", action="read", id=id) + h.redirect_to('package.edit', id=id) else: # add more resources - h.redirect_to(controller="package", action="new_resource", id=id) + h.redirect_to('package.new_resource', id=id) # get resources for sidebar context = { "model": model, "session": model.Session, - "user": c.user or c.author, - "auth_user_obj": c.userobj, + "user": user or author, + "auth_user_obj": userobj, } try: pkg_dict = get_action("package_show")(context, {"id": id}) @@ -298,7 +299,7 @@ def new_resource_ext(self, id, data=None, errors=None, error_summary=None): """ def delete_ext(self, id): - # c.linkResource = str("/dataset/edit/" + id) + # linkResource = str("/dataset/edit/" + id) print("here is delete ext") if "cancel" in request.params: @@ -354,7 +355,7 @@ def new_resource_ext(self, id, data=None, errors=None, error_summary=None): def edit_relation(self, id, data=None, errors=None): try: - c.link = str("/dataset/relationship/new_relationship/" + id) + link = str("/dataset/relationship/new_relationship/" + id) """context = { "model": model, "session": model.Session, @@ -366,9 +367,9 @@ def edit_relation(self, id, data=None, errors=None): c.pkg_dict = get_action("package_show")({ "model": model, "session": model.Session, - "user": c.user or c.author, + "user": user or author, "for_view": True, - "auth_user_obj": c.userobj, + "auth_user_obj": userobj, "use_cache": False, }, {"id": id}) # c.pkg = context["package"] @@ -383,15 +384,15 @@ def relation(self, id): context = { "model": model, "session": model.Session, - "user": c.user or c.author, + "user": user or author, "for_view": True, - "auth_user_obj": c.userobj, + "auth_user_obj": userobj, "use_cache": False, } data_dict = {"id": id} try: c.pkg_dict = get_action("package_show")(context, data_dict) - dataset_type = c.pkg_dict["type"] or "dataset" + dataset_type = pkg_dict["type"] or "dataset" except NotFound: abort(404, _("Dataset not found")) except NotAuthorized: diff --git a/ckanext/relation/flask_plugin.py b/ckanext/relation/flask_plugin.py new file mode 100644 index 0000000..d6cd772 --- /dev/null +++ b/ckanext/relation/flask_plugin.py @@ -0,0 +1,11 @@ +import ckan.plugins as p +import ckanext.relation.views as views + + +class MixinPlugin(p.SingletonPlugin): + p.implements(p.IBlueprint) + + # IBlueprint + + def get_blueprint(self): + return views.get_blueprints() diff --git a/ckanext/relation/helpers.py b/ckanext/relation/helpers.py new file mode 100644 index 0000000..e08f23e --- /dev/null +++ b/ckanext/relation/helpers.py @@ -0,0 +1,200 @@ +import ckan.plugins.toolkit as tk + + +def outgoing_relationship(id): + """Return true if the dataset has any relationship, false otherwise.""" + type = ["depends_on", "child_of" ,"links_to"] + for i in type: + try: + relationship = tk.get_action("package_relationships_list")(data_dict={"id": id, "rel": i}) + rel = bool(relationship) + break + except: + rel = 0 + return rel + + +def has_relationship(id): + """Return true if the dataset has any relationship, false otherwise.""" + relationship = tk.get_action("package_relationships_list")( + data_dict={"id": id} + ) + if relationship: + rel = bool(relationship) + else: + rel = 0 + return rel + + +def rel_id_list(rel_list): + """Return a list of already added datasets with relationships""" + + rel_ids = [] + for i in range(0, len(rel_list)): + rel_id = rel_list[i]["id"] + rel_ids.append(rel_id) + return rel_ids + + +def package_all(q): + """Return a list of all datasets searched for with value 'q'.""" + + query = q.get('q') + datasets = tk.get_action("package_search")( + {}, data_dict={"q": query, "include_private": True} + ) + + result = datasets["results"] + results = [] + for res in result: + results.append(res) + return results + + +def get_child_package(id): + """ Returns a list of packages that are the subjects of child_of relationships.""" + + relationships = [] + try: + relationships = tk.get_action("package_relationships_list")( + data_dict={"id": id, "rel": "parent_of"} + ) + except Exception as e: + return {} + + children = [] + if relationships: + for rel in relationships: + try: + access = tk.check_access( + "package_show", + context={"user": tk.c.user}, + data_dict={"id": rel["object"]}, + ) + child = tk.get_action("package_show")( + data_dict={"id": rel["object"]} + ) + children.append(child) + except: + pass + return children + + +def get_parent_package(id): + """ Returns a list of packages that are the subjects of parent_of relationships.""" + + relationships = [] + try: + relationships = tk.get_action("package_relationships_list")( + data_dict={"id": id, "rel": "child_of"} + ) + except Exception as e: + return {} + + parents = [] + if relationships: + for rel in relationships: + parent = tk.get_action("package_show")(data_dict={"id": rel["object"]}) + parents.append(parent) + return parents + + +def get_dependency_package(id): + """ Returns a list of packages that are the subjects of dependency_of relationships.""" + + relationships = [] + try: + relationships = tk.get_action("package_relationships_list")( + data_dict={"id": id, "rel": "depends_on"} + ) + except Exception as e: + return {} + + dependencies = [] + if relationships: + for rel in relationships: + dependency = tk.get_action("package_show")( + data_dict={"id": rel["object"]} + ) + dependencies.append(dependency) + return dependencies + + +def get_depend_package(id): + """ Returns a list of packages that are the subjects of depends_on relationships.""" + + relationships = [] + try: + relationships = tk.get_action("package_relationships_list")( + data_dict={"id": id, "rel": "dependency_of"} + ) + except Exception as e: + return {} + + depend = [] + if relationships: + for rel in relationships: + try: + access = tk.check_access( + "package_show", + context={"user": tk.c.user}, + data_dict={"id": rel["object"]}, + ) + dep = tk.get_action("package_show")( + data_dict={"id": rel["object"]} + ) + depend.append(dep) + except: + pass + return depend + + +def get_linked_package(id): + """ Returns a list of packages that are the subjects of linked_from relationships.""" + + relationships = [] + try: + relationships = tk.get_action("package_relationships_list")( + data_dict={"id": id, "rel": "links_to"} + ) + except Exception as e: + return {} + + linked = [] + if relationships: + for rel in relationships: + lnk = tk.get_action("package_show")( + data_dict={"id": rel["object"]} + ) + linked.append(lnk) + + return linked + + +def get_links_package(id): + """ Returns a list of packages that are the subjects of links_to relationships.""" + + relationships = [] + try: + relationships = tk.get_action("package_relationships_list")( + data_dict={"id": id, "rel": "linked_from"} + ) + except Exception as e: + return {} + + links = [] + if relationships: + for rel in relationships: + try: + tk.check_access( + "package_show", + context={"user": tk.c.user}, + data_dict={"id": rel["object"]}, + ) + link = tk.get_action("package_show")( + data_dict={"id": rel["object"]} + ) + links.append(link) + except: + pass + return links diff --git a/ckanext/relation/plugin.py b/ckanext/relation/plugin.py index 410cbd3..fc7842e 100644 --- a/ckanext/relation/plugin.py +++ b/ckanext/relation/plugin.py @@ -1,226 +1,31 @@ import os -import sys -import ckan as ckan -import ckan.plugins as p -from ckan.common import c, request -import ckan.model as model import logging -from ckan.lib.plugins import DefaultTranslation - -log = logging.getLogger(__name__) - -HERE = os.path.abspath(os.path.dirname(__file__)) -I18N_DIR = os.path.join(HERE, "i18n") - -def outgoing_relationship(id): - """Return true if the dataset has any relationship, false otherwise.""" - type = ["depends_on", "child_of" ,"links_to"] - for i in type: - try: - relationship = p.toolkit.get_action("package_relationships_list")(data_dict={"id": id, "rel": i}) - rel = bool(relationship) - break - except: - rel = 0 - return rel - -def has_relationship(id): - """Return true if the dataset has any relationship, false otherwise.""" - - relationship = p.toolkit.get_action("package_relationships_list")( - data_dict={"id": id} - ) - if relationship: - rel = bool(relationship) - else: - rel = 0 - return rel - - -def rel_id_list(rel_list): - """Return a list of already added datasets with relationships""" - - rel_ids = [] - for i in range(0, len(rel_list)): - rel_id = rel_list[i]["id"] - rel_ids.append(rel_id) - return rel_ids - - -def package_all(q): - """Return a list of all datasets searched for with value 'q'.""" - - query = (q.dict_of_lists())["q"][0] - datasets = p.toolkit.get_action("package_search")( - {}, data_dict={"q": query, "include_private": True} - ) - - result = datasets["results"] - results = [] - for res in result: - results.append(res) - return results - - -def get_child_package(id): - """ Returns a list of packages that are the subjects of child_of relationships.""" - - relationships = [] - try: - relationships = p.toolkit.get_action("package_relationships_list")( - data_dict={"id": id, "rel": "parent_of"} - ) - except Exception, e: - return {} - - children = [] - if relationships: - for rel in relationships: - try: - access = p.toolkit.check_access( - "package_show", - context={"user": c.user}, - data_dict={"id": rel["object"]}, - ) - child = p.toolkit.get_action("package_show")( - data_dict={"id": rel["object"]} - ) - children.append(child) - except: - pass - return children - - -def get_parent_package(id): - """ Returns a list of packages that are the subjects of parent_of relationships.""" - - relationships = [] - try: - relationships = p.toolkit.get_action("package_relationships_list")( - data_dict={"id": id, "rel": "child_of"} - ) - except Exception, e: - return {} - - parents = [] - if relationships: - for rel in relationships: - parent = p.toolkit.get_action("package_show")(data_dict={"id": rel["object"]}) - parents.append(parent) - return parents - - -def get_dependency_package(id): - """ Returns a list of packages that are the subjects of dependency_of relationships.""" - - relationships = [] - try: - relationships = p.toolkit.get_action("package_relationships_list")( - data_dict={"id": id, "rel": "depends_on"} - ) - except Exception, e: - return {} - - dependencies = [] - if relationships: - for rel in relationships: - dependency = p.toolkit.get_action("package_show")( - data_dict={"id": rel["object"]} - ) - dependencies.append(dependency) - return dependencies - -def get_depend_package(id): - """ Returns a list of packages that are the subjects of depends_on relationships.""" - - relationships = [] - try: - relationships = p.toolkit.get_action("package_relationships_list")( - data_dict={"id": id, "rel": "dependency_of"} - ) - except Exception, e: - return {} - - depend = [] - if relationships: - for rel in relationships: - try: - access = p.toolkit.check_access( - "package_show", - context={"user": c.user}, - data_dict={"id": rel["object"]}, - ) - dep = p.toolkit.get_action("package_show")( - data_dict={"id": rel["object"]} - ) - depend.append(dep) - except: - pass - return depend - - -def get_linked_package(id): - """ Returns a list of packages that are the subjects of linked_from relationships.""" - - relationships = [] - try: - relationships = p.toolkit.get_action("package_relationships_list")( - data_dict={"id": id, "rel": "links_to"} - ) - except Exception, e: - return {} - - linked = [] - if relationships: - for rel in relationships: - lnk = p.toolkit.get_action("package_show")( - data_dict={"id": rel["object"]} - ) - linked.append(lnk) +import ckan.plugins as p +from ckan.common import config, request - return linked +import ckanext.relation.helpers as h +if p.toolkit.check_ckan_version(min_version='2.9.0'): + from ckanext.relation.flask_plugin import MixinPlugin +else: + from ckanext.relation.pylons_plugin import MixinPlugin -def get_links_package(id): - """ Returns a list of packages that are the subjects of links_to relationships.""" - relationships = [] - try: - relationships = p.toolkit.get_action("package_relationships_list")( - data_dict={"id": id, "rel": "linked_from"} - ) - except Exception, e: - return {} +log = logging.getLogger(__name__) - links = [] - if relationships: - for rel in relationships: - try: - access = p.toolkit.check_access( - "package_show", - context={"user": c.user}, - data_dict={"id": rel["object"]}, - ) - link = p.toolkit.get_action("package_show")( - data_dict={"id": rel["object"]} - ) - links.append(link) - except: - pass - return links +HERE = os.path.abspath(os.path.dirname(__file__)) +I18N_DIR = os.path.join(HERE, "i18n") -class RelationPlugin(p.SingletonPlugin): +class RelationPlugin(MixinPlugin, p.SingletonPlugin): """ Plugin for creating, deleting and viewing relationships """ - p.implements(p.IConfigurer) p.implements(p.ITranslation) p.implements(p.IConfigurable) p.implements(p.ITemplateHelpers) - p.implements(p.IRoutes, inherit=True) package_link = "/dataset/" @@ -231,12 +36,12 @@ def configure(self, config): if site_url is not None: RelationPlugin.package_link = site_url + "/dataset/" - def update_config(self, config): + def update_config(self, _config): # add our templates - p.toolkit.add_template_directory(config, "templates") - p.toolkit.add_public_directory(config, "public") - p.toolkit.add_resource("fanstatic", "relation") + p.toolkit.add_template_directory(_config, "templates") + p.toolkit.add_public_directory(_config, "public") + p.toolkit.add_resource("resources", "relation") def get_helpers(self): """Register the functions above as template helper functions. @@ -244,119 +49,19 @@ def get_helpers(self): # Template helper function names should begin with the name of the # extension they belong to, to avoid clashing with functions from # other extensions. - print("something1") return { - "rel_get_child_package": get_child_package, - "rel_get_parent_package": get_parent_package, - "rel_get_dependency_package": get_dependency_package, - "rel_get_depend_package": get_depend_package, - "rel_get_links_package": get_links_package, - "rel_get_linked_package": get_linked_package, - "package_all": package_all, - "rel_id_list": rel_id_list, - "has_relationship": has_relationship, - "outgoing_relationship": outgoing_relationship, + "rel_get_child_package": h.get_child_package, + "rel_get_parent_package": h.get_parent_package, + "rel_get_dependency_package": h.get_dependency_package, + "rel_get_depend_package": h.get_depend_package, + "rel_get_links_package": h.get_links_package, + "rel_get_linked_package": h.get_linked_package, + "package_all": h.package_all, + "rel_id_list": h.rel_id_list, + "has_relationship": h.has_relationship, + "outgoing_relationship": h.outgoing_relationship, } - def before_map(self, map): - - map.connect( - "temp", - "/demp/demo", - controller="ckanext.relation.controller:RelationController", - action="index", - ) - - map.connect( - "data_relation_add", # name of path route - "/dataset/relationship/add/{id}", # url to map path to - controller="ckanext.relation.controller:RelationController", # controller - action="finalrel", # controller action (method) - ) - - map.connect( - "/dataset/new_resource/{id}", - controller="ckanext.relation.controller:RelationController", - action="new_resource_ext", - ) - - # map.connect('delete_ext', '/dataset/edit/{id}',controller='ckanext.relation.controller:RelationController', action='delete_ext') - # print('here8') - - map.connect( - "dataset_edit_relation", - "/dataset/relationship/edit/{id}", - controller="ckanext.relation.controller:RelationController", - action="edit_relation", - ckan_icon="edit", - ) - - map.connect( - "data dict button", - "/dataset/relationship/new_relationship/{id}", - controller="ckanext.relation.controller:RelationController", - action="new_relation", - ) - - map.connect( - "relation", - "/dataset/relationship/{id}", - controller="ckanext.relation.controller:RelationController", - action="relation", - ckan_icon="link", - ) - return map - - def after_map(self, map): - - map.connect( - "temp", - "/demp/demo", - controller="ckanext.relation.controller:RelationController", - action="index", - ) - - map.connect( - "data_relation_add", - "/dataset/relationship/add/{id}", - controller="ckanext.relation.controller:RelationController", - action="finalrel", - ) - - map.connect( - "/dataset/new_resource/{id}", - controller="ckanext.relation.controller:RelationController", - action="new_resource_ext", - ) - - # map.connect('delete_ext','/dataset/edit/{id}',controller='ckanext.relation.controller:RelationController', action='delete_ext') - # print('here8') - - map.connect( - "dataset_edit_relation", - "/dataset/relationship/edit/{id}", - controller="ckanext.relation.controller:RelationController", - action="edit_relation", - ckan_icon="edit", - ) - - map.connect( - "data dict button", - "/dataset/relationship/new_relationship/{id}", - controller="ckanext.relation.controller:RelationController", - action="new_relation", - ) - - map.connect( - "relation", - "/dataset/relationship/{id}", - controller="ckanext.relation.controller:RelationController", - action="relation", - ckan_icon="link", - ) - - return map - # def i18n_directory(self): # '''Change the directory of the *.mo translation files # The default implementation assumes the plugin is @@ -387,4 +92,4 @@ def i18n_domain(self): This implementation assumes the gettext domain is ckanext-{extension name}, hence your pot, po and mo files should be named ckanext-{extension name}.mo''' - return 'ckanext-{name}'.format(name=self.name) \ No newline at end of file + return 'ckanext-{name}'.format(name=self.name) diff --git a/ckanext/relation/pylons_plugin.py b/ckanext/relation/pylons_plugin.py new file mode 100644 index 0000000..b8cac80 --- /dev/null +++ b/ckanext/relation/pylons_plugin.py @@ -0,0 +1,106 @@ +import ckan.plugins as p + + +class MixinPlugin(p.SingletonPlugin): + p.implements(p.IRoutes, inherit=True) + + # IRoutes + + def before_map(self, map): + + map.connect( + "temp", + "/demp/demo", + controller="ckanext.relation.controller:RelationController", + action="index", + ) + + map.connect( + "data_relation_add", # name of path route + "/dataset/relationship/add/{id}", # url to map path to + controller="ckanext.relation.controller:RelationController", # controller + action="finalrel", # controller action (method) + ) + + map.connect( + "/dataset/new_resource/{id}", + controller="ckanext.relation.controller:RelationController", + action="new_resource_ext", + ) + + # map.connect('delete_ext', '/dataset/edit/{id}',controller='ckanext.relation.controller:RelationController', action='delete_ext') + # print('here8') + + map.connect( + "dataset_edit_relation", + "/dataset/relationship/edit/{id}", + controller="ckanext.relation.controller:RelationController", + action="edit_relation", + ckan_icon="edit", + ) + + map.connect( + "data dict button", + "/dataset/relationship/new_relationship/{id}", + controller="ckanext.relation.controller:RelationController", + action="new_relation", + ) + + map.connect( + "relation", + "/dataset/relationship/{id}", + controller="ckanext.relation.controller:RelationController", + action="relation", + ckan_icon="link", + ) + return map + + def after_map(self, map): + + map.connect( + "temp", + "/demp/demo", + controller="ckanext.relation.controller:RelationController", + action="index", + ) + + map.connect( + "data_relation_add", + "/dataset/relationship/add/{id}", + controller="ckanext.relation.controller:RelationController", + action="finalrel", + ) + + map.connect( + "/dataset/new_resource/{id}", + controller="ckanext.relation.controller:RelationController", + action="new_resource_ext", + ) + + # map.connect('delete_ext','/dataset/edit/{id}',controller='ckanext.relation.controller:RelationController', action='delete_ext') + # print('here8') + + map.connect( + "dataset_edit_relation", + "/dataset/relationship/edit/{id}", + controller="ckanext.relation.controller:RelationController", + action="edit_relation", + ckan_icon="edit", + ) + + map.connect( + "data dict button", + "/dataset/relationship/new_relationship/{id}", + controller="ckanext.relation.controller:RelationController", + action="new_relation", + ) + + map.connect( + "relation", + "/dataset/relationship/{id}", + controller="ckanext.relation.controller:RelationController", + action="relation", + ckan_icon="link", + ) + + return map diff --git a/ckanext/relation/fanstatic/group_label.css b/ckanext/relation/resources/css/group_label.css similarity index 100% rename from ckanext/relation/fanstatic/group_label.css rename to ckanext/relation/resources/css/group_label.css diff --git a/ckanext/relation/fanstatic/style.css b/ckanext/relation/resources/css/style.css similarity index 100% rename from ckanext/relation/fanstatic/style.css rename to ckanext/relation/resources/css/style.css diff --git a/ckanext/relation/fanstatic/js/cytoscape.min.js b/ckanext/relation/resources/js/cytoscape.min.js similarity index 100% rename from ckanext/relation/fanstatic/js/cytoscape.min.js rename to ckanext/relation/resources/js/cytoscape.min.js diff --git a/ckanext/relation/resources/resource.config b/ckanext/relation/resources/resource.config new file mode 100644 index 0000000..0b48950 --- /dev/null +++ b/ckanext/relation/resources/resource.config @@ -0,0 +1,8 @@ +#[groups] + +#main_js = +# js/cytoscape.min.js + +#main_css = +# css/group_label.css +# css/style.css diff --git a/ckanext/relation/resources/webassets.yml b/ckanext/relation/resources/webassets.yml new file mode 100644 index 0000000..54ab573 --- /dev/null +++ b/ckanext/relation/resources/webassets.yml @@ -0,0 +1,9 @@ +main_css: +# filters: cssrewrite + contents: + - css/group_label.css + - css/style.css + +main_js: + contents: + - js/cytoscape.min.js diff --git a/ckanext/relation/templates/package/edit_base.html b/ckanext/relation/templates/package/edit_base.html index 4c02e58..7de134e 100644 --- a/ckanext/relation/templates/package/edit_base.html +++ b/ckanext/relation/templates/package/edit_base.html @@ -1,7 +1,7 @@ {% ckan_extends %} +{% set pkg = c.pkg %} {% block content_primary_nav %} {{ super() }} - {{ h.build_nav_icon('dataset_edit_relation', _('Edit Relationship'), id=pkg.name) }} + {{ h.build_nav_icon('relation.edit_relation', _('Edit Relationship'), id=pkg.name) }} {% endblock %} - diff --git a/ckanext/relation/templates/package/edit_data_relation.html b/ckanext/relation/templates/package/edit_data_relation.html index b9647ba..88bb26b 100644 --- a/ckanext/relation/templates/package/edit_data_relation.html +++ b/ckanext/relation/templates/package/edit_data_relation.html @@ -1,4 +1,4 @@ -{%extends "package/edit_base.html" %} +{% extends "package/edit_base.html" %} {% set logged_in = true if c.userobj else false %} {% set res = c.resource %} diff --git a/ckanext/relation/templates/package/read.html b/ckanext/relation/templates/package/read.html index 479539c..d05dd41 100644 --- a/ckanext/relation/templates/package/read.html +++ b/ckanext/relation/templates/package/read.html @@ -19,7 +19,7 @@ {{ super() }} {% if h.has_relationship(pkg.id) %} - {% set url = app_globals.site_url + "/dataset/relationship/" + pkg.name %} + {% set url = h.url_for("relation.relations", id=pkg.name) %}