diff --git a/ckan/config/routing.py b/ckan/config/routing.py
index 4f92b715991..baa95de71cb 100644
--- a/ckan/config/routing.py
+++ b/ckan/config/routing.py
@@ -194,17 +194,6 @@ def make_map():
map.redirect('/package', '/dataset')
map.redirect('/package/{url:.*}', '/dataset/{url}')
- with SubMapper(map, controller='related') as m:
- m.connect('related_new', '/dataset/{id}/related/new', action='new')
- m.connect('related_edit', '/dataset/{id}/related/edit/{related_id}',
- action='edit')
- m.connect('related_delete', '/dataset/{id}/related/delete/{related_id}',
- action='delete')
- m.connect('related_list', '/dataset/{id}/related', action='list',
- ckan_icon='picture')
- m.connect('related_read', '/related/{id}', action='read')
- m.connect('related_dashboard', '/related', action='dashboard')
-
with SubMapper(map, controller='package') as m:
m.connect('search', '/dataset', action='search',
highlight_actions='index search')
diff --git a/ckan/controllers/related.py b/ckan/controllers/related.py
deleted file mode 100644
index af0a0f7c492..00000000000
--- a/ckan/controllers/related.py
+++ /dev/null
@@ -1,238 +0,0 @@
-import urllib
-
-import ckan.model as model
-import ckan.logic as logic
-import ckan.lib.base as base
-import ckan.lib.helpers as h
-import ckan.lib.navl.dictization_functions as df
-
-from ckan.common import _, c
-
-
-abort = base.abort
-_get_action = logic.get_action
-
-
-class RelatedController(base.BaseController):
-
- def new(self, id):
- return self._edit_or_new(id, None, False)
-
- def edit(self, id, related_id):
- return self._edit_or_new(id, related_id, True)
-
- def dashboard(self):
- """ List all related items regardless of dataset """
- context = {'model': model, 'session': model.Session,
- 'user': c.user or c.author, 'auth_user_obj': c.userobj,
- 'for_view': True}
- data_dict = {
- 'type_filter': base.request.params.get('type', ''),
- 'sort': base.request.params.get('sort', ''),
- 'featured': base.request.params.get('featured', '')
- }
-
- params_nopage = [(k, v) for k, v in base.request.params.items()
- if k != 'page']
-
- page = self._get_page_number(base.request.params)
-
- # Update ordering in the context
- related_list = logic.get_action('related_list')(context, data_dict)
-
- def search_url(params):
- url = h.url_for(controller='related', action='dashboard')
- params = [(k, v.encode('utf-8')
- if isinstance(v, basestring) else str(v))
- for k, v in params]
- return url + u'?' + urllib.urlencode(params)
-
- def pager_url(q=None, page=None):
- params = list(params_nopage)
- params.append(('page', page))
- return search_url(params)
-
- c.page = h.Page(
- collection=related_list,
- page=page,
- url=pager_url,
- item_count=len(related_list),
- items_per_page=9
- )
-
- c.filters = dict(params_nopage)
-
- c.type_options = self._type_options()
- c.sort_options = (
- {'value': '', 'text': _('Most viewed')},
- {'value': 'view_count_desc', 'text': _('Most Viewed')},
- {'value': 'view_count_asc', 'text': _('Least Viewed')},
- {'value': 'created_desc', 'text': _('Newest')},
- {'value': 'created_asc', 'text': _('Oldest')}
- )
-
- return base.render("related/dashboard.html")
-
- def read(self, id):
- context = {'model': model, 'session': model.Session,
- 'user': c.user or c.author,
- 'auth_user_obj': c.userobj,
- 'for_view': True}
- data_dict = {'id': id}
-
- try:
- logic.check_access('related_show', context, data_dict)
- except logic.NotAuthorized:
- base.abort(401, _('Not authorized to see this page'))
-
- related = model.Session.query(model.Related) \
- .filter(model.Related.id == id).first()
- if not related:
- base.abort(404, _('The requested related item was not found'))
-
- related.view_count = model.Related.view_count + 1
-
- model.Session.add(related)
- model.Session.commit()
-
- base.redirect(related.url)
-
- def list(self, id):
- """ List all related items for a specific dataset """
- context = {'model': model, 'session': model.Session,
- 'user': c.user or c.author,
- 'auth_user_obj': c.userobj,
- 'for_view': True}
- data_dict = {'id': id}
-
- try:
- logic.check_access('package_show', context, data_dict)
- except logic.NotFound:
- base.abort(404, base._('Dataset not found'))
- except logic.NotAuthorized:
- base.abort(401, base._('Not authorized to see this page'))
-
- try:
- c.pkg_dict = logic.get_action('package_show')(context, data_dict)
- c.related_list = logic.get_action('related_list')(context,
- data_dict)
- c.pkg = context['package']
- c.resources_json = h.json.dumps(c.pkg_dict.get('resources', []))
- except logic.NotFound:
- base.abort(404, base._('Dataset not found'))
- except logic.NotAuthorized:
- base.abort(401, base._('Unauthorized to read package %s') % id)
-
- return base.render("package/related_list.html")
-
- def _edit_or_new(self, id, related_id, is_edit):
- """
- Edit and New were too similar and so I've put the code together
- and try and do as much up front as possible.
- """
- context = {'model': model, 'session': model.Session,
- 'user': c.user or c.author, 'auth_user_obj': c.userobj,
- 'for_view': True}
- data_dict = {}
-
- if is_edit:
- tpl = 'related/edit.html'
- auth_name = 'related_update'
- auth_dict = {'id': related_id}
- action_name = 'related_update'
-
- try:
- related = logic.get_action('related_show')(
- context, {'id': related_id})
- except logic.NotFound:
- base.abort(404, _('Related item not found'))
- else:
- tpl = 'related/new.html'
- auth_name = 'related_create'
- auth_dict = {}
- action_name = 'related_create'
-
- try:
- logic.check_access(auth_name, context, auth_dict)
- except logic.NotAuthorized:
- base.abort(401, base._('Not authorized'))
-
- try:
- c.pkg_dict = logic.get_action('package_show')(context, {'id': id})
- except logic.NotFound:
- base.abort(404, _('Package not found'))
-
- data, errors, error_summary = {}, {}, {}
-
- if base.request.method == "POST":
- try:
- data = logic.clean_dict(
- df.unflatten(
- logic.tuplize_dict(
- logic.parse_params(base.request.params))))
-
- if is_edit:
- data['id'] = related_id
- else:
- data['dataset_id'] = id
- data['owner_id'] = c.userobj.id
-
- related = logic.get_action(action_name)(context, data)
-
- if not is_edit:
- h.flash_success(_("Related item was successfully created"))
- else:
- h.flash_success(_("Related item was successfully updated"))
-
- h.redirect_to(
- controller='related', action='list', id=c.pkg_dict['name'])
- except df.DataError:
- base.abort(400, _(u'Integrity Error'))
- except logic.ValidationError, e:
- errors = e.error_dict
- error_summary = e.error_summary
- else:
- if is_edit:
- data = related
-
- c.types = self._type_options()
-
- c.pkg_id = id
- vars = {'data': data, 'errors': errors, 'error_summary': error_summary}
- c.form = base.render("related/edit_form.html", extra_vars=vars)
- return base.render(tpl)
-
- def delete(self, id, related_id):
- if 'cancel' in base.request.params:
- h.redirect_to(controller='related', action='edit',
- id=id, related_id=related_id)
-
- context = {'model': model, 'session': model.Session,
- 'user': c.user or c.author, 'auth_user_obj': c.userobj}
-
- try:
- if base.request.method == 'POST':
- logic.get_action('related_delete')(context, {'id': related_id})
- h.flash_notice(_('Related item has been deleted.'))
- h.redirect_to(controller='package', action='read', id=id)
- c.related_dict = logic.get_action('related_show')(
- context, {'id': related_id})
- c.pkg_id = id
- except logic.NotAuthorized:
- base.abort(401, _('Unauthorized to delete related item %s') % '')
- except logic.NotFound:
- base.abort(404, _('Related item not found'))
- return base.render('related/confirm_delete.html')
-
- def _type_options(self):
- '''
- A tuple of options for the different related types for use in
- the form.select() template macro.
- '''
- return ({"text": _("API"), "value": "api"},
- {"text": _("Application"), "value": "application"},
- {"text": _("Idea"), "value": "idea"},
- {"text": _("News Article"), "value": "news_article"},
- {"text": _("Paper"), "value": "paper"},
- {"text": _("Post"), "value": "post"},
- {"text": _("Visualization"), "value": "visualization"})
diff --git a/ckan/public/base/test/index.html b/ckan/public/base/test/index.html
index 26938e23249..bdadaa48622 100644
--- a/ckan/public/base/test/index.html
+++ b/ckan/public/base/test/index.html
@@ -48,7 +48,6 @@
-
@@ -64,7 +63,6 @@
-
diff --git a/ckan/templates/ajax_snippets/related-item.html b/ckan/templates/ajax_snippets/related-item.html
deleted file mode 100644
index 6ba788d92c8..00000000000
--- a/ckan/templates/ajax_snippets/related-item.html
+++ /dev/null
@@ -1,2 +0,0 @@
-{# Used by the related-item.spec.js file #}
-{% snippet 'related/snippets/related_item.html', related={'title': 'Test', 'url': 'http://example.com', 'type': 'application'}, position=1 %}
diff --git a/ckan/templates/home/snippets/stats.html b/ckan/templates/home/snippets/stats.html
index 123047aa041..1ca8f410d63 100644
--- a/ckan/templates/home/snippets/stats.html
+++ b/ckan/templates/home/snippets/stats.html
@@ -23,12 +23,6 @@
{{ _('{0} statistics').format(g.site_title) }}
{{ _('group') if stats.group_count == 1 else _('groups') }}
-
-
- {{ h.SI_number_span(stats.related_count) }}
- {{ _('related item') if stats.related_count == 1 else _('related items') }}
-
-
{% endblock %}
diff --git a/ckan/templates/package/read_base.html b/ckan/templates/package/read_base.html
index e4a966b090a..4e959da5bb8 100644
--- a/ckan/templates/package/read_base.html
+++ b/ckan/templates/package/read_base.html
@@ -19,7 +19,6 @@
{{ h.build_nav_icon('dataset_read', _('Dataset'), id=pkg.name) }}
{{ h.build_nav_icon('dataset_groups', _('Groups'), id=pkg.name) }}
{{ h.build_nav_icon('dataset_activity', _('Activity Stream'), id=pkg.name) }}
- {{ h.build_nav_icon('related_list', _('Related'), id=pkg.name) }}
{% endblock %}
{% block primary_content_inner %}
diff --git a/ckan/templates/related/base_form_page.html b/ckan/templates/related/base_form_page.html
deleted file mode 100644
index cc788a741fb..00000000000
--- a/ckan/templates/related/base_form_page.html
+++ /dev/null
@@ -1,32 +0,0 @@
-{% extends "page.html" %}
-
-{% block breadcrumb_content %}
- {{ h.nav_link(_('Datasets'), controller='package', action='search') }}
- {{ h.truncate(c.pkg_dict.title or c.pkg_dict.name, 60) }}
- {% block breadcrumb_item %}{% endblock %}
-{% endblock %}
-
-{% block primary_content %}
-
-
-
{% block page_heading %}{{ _('Related Form') }}{% endblock %}
- {{ c.form | safe }}
-
-
-{% endblock %}
-
-{% block secondary_content %}
-
- {{ _('What are related items?') }}
-
- {% trans %}
-
Related Media is any app, article, visualisation or idea related to
- this dataset.
-
-
For example, it could be a custom visualisation, pictograph
- or bar chart, an app using all or part of the data or even a news story
- that references this dataset.
- {% endtrans %}
-
-
-{% endblock %}
diff --git a/ckan/templates/related/confirm_delete.html b/ckan/templates/related/confirm_delete.html
deleted file mode 100644
index e8ad09b70cd..00000000000
--- a/ckan/templates/related/confirm_delete.html
+++ /dev/null
@@ -1,21 +0,0 @@
-{% extends "page.html" %}
-
-{% block subtitle %}{{ _("Confirm Delete") }}{% endblock %}
-
-{% block maintag %}{% endblock %}
-
-{% block main_content %}
-
-
- {% block form %}
-
{{ _('Are you sure you want to delete related item - {name}?').format(name=c.related_dict.title) }}
-
-
-
- {% endblock %}
-
-
-{% endblock %}
diff --git a/ckan/templates/related/dashboard.html b/ckan/templates/related/dashboard.html
deleted file mode 100644
index 841abe99d8b..00000000000
--- a/ckan/templates/related/dashboard.html
+++ /dev/null
@@ -1,94 +0,0 @@
-{% extends "page.html" %}
-
-{% set page = c.page %}
-{% set item_count = c.page.item_count %}
-
-{% block subtitle %}{{ _('Apps & Ideas') }}{% endblock %}
-
-{% block breadcrumb_content %}
-
{{ _('Apps & Ideas') }}
-{% endblock %}
-
-{% block primary_content %}
-
-
-
- {% block page_heading %}{{ _('Apps & Ideas') }}{% endblock %}
-
-
- {% block related_items %}
- {% if item_count %}
- {% trans first=page.first_item, last=page.last_item, item_count=item_count %}
-
Showing items {{ first }} - {{ last }} of {{ item_count }} related items found
- {% endtrans %}
- {% elif c.filters.type %}
- {% trans item_count=item_count %}
-
{{ item_count }} related items found
- {% endtrans %}
- {% else %}
-
{{ _('There have been no apps submitted yet.') }}
- {% endif %}
- {% endblock %}
-
- {% block related_list %}
- {% if page.items %}
- {% snippet "related/snippets/related_list.html", related_items=page.items %}
- {% endif %}
- {% endblock %}
-
-
- {% block page_pagination %}
- {{ page.pager() }}
- {% endblock %}
-
-{% endblock %}
-
-{% block secondary_content %}
-
- {{ _('What are applications?') }}
-
- {% trans %}
- These are applications built with the datasets as well as ideas for
- things that could be done with them.
- {% endtrans %}
-
-
-
-
- {{ _('Filter Results') }}
-
-
-{% endblock %}
diff --git a/ckan/templates/related/edit.html b/ckan/templates/related/edit.html
deleted file mode 100644
index 26c1e49b701..00000000000
--- a/ckan/templates/related/edit.html
+++ /dev/null
@@ -1,8 +0,0 @@
-{% extends "related/base_form_page.html" %}
-
-{% block subtitle %}{{ _('Edit related item') }}{% endblock %}
-
-{# TODO: pass the same context in here so we can create links #}
-{% block breadcrumb_item %}{{ h.nav_link(_('Edit Related'), controller='related', action='edit', id=c.id, related_id="") }}{% endblock %}
-
-{% block page_heading %}{{ _('Edit Related Item') }}{% endblock %}
diff --git a/ckan/templates/related/edit_form.html b/ckan/templates/related/edit_form.html
deleted file mode 100644
index 92cb16696e8..00000000000
--- a/ckan/templates/related/edit_form.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% extends "related/snippets/related_form.html" %}
-
-{% block button_text %}
- {% if data.id %}
- {{ _('Update') }}
- {% else %}
- {{ _('Create') }}
- {% endif %}
-{% endblock %}
-
-{% block delete_button %}
- {% if data.id %}
- {{ super() }}
- {% endif %}
-{% endblock %}
diff --git a/ckan/templates/related/new.html b/ckan/templates/related/new.html
deleted file mode 100644
index 7fb3ce90633..00000000000
--- a/ckan/templates/related/new.html
+++ /dev/null
@@ -1,7 +0,0 @@
-{% extends "related/base_form_page.html" %}
-
-{% block subtitle %}{{ _('Create a related item') }}{% endblock %}
-
-{% block breadcrumb_item %}{{ h.nav_link(_('Create Related'), controller='related', action='new', id=c.id) }}{% endblock %}
-
-{% block page_heading %}{{ _('Create Related Item') }}{% endblock %}
diff --git a/ckan/templates/related/snippets/related_form.html b/ckan/templates/related/snippets/related_form.html
deleted file mode 100644
index 23ab88c1c84..00000000000
--- a/ckan/templates/related/snippets/related_form.html
+++ /dev/null
@@ -1,35 +0,0 @@
-{% import 'macros/form.html' as form %}
-
-
diff --git a/ckan/templates/related/snippets/related_item.html b/ckan/templates/related/snippets/related_item.html
deleted file mode 100644
index 2053f7c0406..00000000000
--- a/ckan/templates/related/snippets/related_item.html
+++ /dev/null
@@ -1,41 +0,0 @@
-{#
-Displays a single related item.
-
-related - The related item dict.
-pkg_id - The id of the owner package. If present the edit button will be
- displayed.
-
-Example:
-
-
-
-#}
-{% set placeholder_map = {
-'application': h.url_for_static('/base/images/placeholder-application.png')
-} %}
-{% set tooltip = _('Go to {related_item_type}').format(related_item_type=related.type|replace('_', ' ')|title) %}
-
-
-
- {% if related.description %}
- {{ h.render_markdown(related.description) }}
- {% endif %}
-
- {{ tooltip }}
-
- {%- if related.type == 'application' -%}
- app
- {%- elif related.type == 'visualization' -%}
- viz
- {%- else -%}
- {{ related.type | replace('news_', '') }}
- {%- endif -%}
-
-
- {% if pkg_id %}
- {{ h.nav_link(_('Edit'), controller='related', action='edit', id=pkg_id, related_id=related.id, class_='btn btn-primary btn-small media-edit') }}
- {% endif %}
-
-{% if position is divisibleby 3 %}
-
-{% endif %}
diff --git a/ckan/templates/related/snippets/related_list.html b/ckan/templates/related/snippets/related_list.html
deleted file mode 100644
index 7256ba97dc3..00000000000
--- a/ckan/templates/related/snippets/related_list.html
+++ /dev/null
@@ -1,18 +0,0 @@
-{#
-Renders a list of related item elements
-
-related_items - A list of related items.
-pkg_id - A package id for the items used to determine if the edit button
- should be displayed.
-
-Example:
-
-
- {% snippet "related/snippets/related_list.html", related_items=c.pkg.related, pkg_id=c.pkg.name %}
-
-#}
-
diff --git a/ckan/tests/legacy/functional/test_related.py b/ckan/tests/legacy/functional/test_related.py
index bb67323520f..aa636a8957d 100644
--- a/ckan/tests/legacy/functional/test_related.py
+++ b/ckan/tests/legacy/functional/test_related.py
@@ -10,57 +10,6 @@
import ckan.tests.legacy.functional.api.base as apibase
-class TestRelatedUI(base.FunctionalTestCase):
- @classmethod
- def setup_class(self):
- model.Session.remove()
- tests.CreateTestData.create()
-
- @classmethod
- def teardown_class(self):
- model.repo.rebuild_db()
-
- def test_related_new(self):
- offset = h.url_for(controller='related',
- action='new', id='warandpeace')
- res = self.app.get(offset, status=200,
- extra_environ={"REMOTE_USER": "testsysadmin"})
- assert 'URL' in res, "URL missing in response text"
- assert 'Title' in res, "Title missing in response text"
-
- data = {
- "title": "testing_create",
- "url": u"http://ckan.org/feed/",
- }
- res = self.app.post(offset, params=data,
- status=[200,302],
- extra_environ={"REMOTE_USER": "testsysadmin"})
-
- def test_related_new_missing(self):
- offset = h.url_for(controller='related',
- action='new', id='non-existent dataset')
- res = self.app.get(offset, status=404,
- extra_environ={"REMOTE_USER": "testsysadmin"})
-
- def test_related_new_fail(self):
- offset = h.url_for(controller='related',
- action='new', id='warandpeace')
- print '@@@@', offset
- res = self.app.get(offset, status=200,
- extra_environ={"REMOTE_USER": "testsysadmin"})
- assert 'URL' in res, "URL missing in response text"
- assert 'Title' in res, "Title missing in response text"
-
- data = {
- "title": "testing_create",
- }
- res = self.app.post(offset, params=data,
- status=[200,302],
- extra_environ={"REMOTE_USER": "testsysadmin"})
- assert 'error' in res, res
-
-
-
class TestRelated:
@classmethod
@@ -357,7 +306,7 @@ def test_update_related_item_check_owner_status(self):
}
user = model.User.by_name('tester')
admin = model.User.by_name('testsysadmin')
-
+
#create related item
context = dict(model=model, user=user.name, session=model.Session)
data_dict = dict(title="testing_create",description="description",