Repository: ckan/ckan

Issue:
`dataset_read` legacy route missing
### CKAN Version if known (or site URL)
master

### Please describe the expected behaviour
There is a alias for the `dataset_read` legacy route in CKAN 2.8+, I guess it's missing in [LEGACY_ROUTE_NAMES](https://github.com/ckan/ckan/blob/f3a9c0d99e0bbd404052f49a1ec36a208af634c5/ckan/lib/helpers.py#L68-L74).

### Please describe the actual behaviour
When running the tests on my CKAN extension against the current master, it fails with the following error:

```
File "/home/travis/build/opendatazurich/ckanext-stadtzh-theme/ckan/ckan/lib/helpers.py", line 938, in _make_menu_item
    raise Exception('menu item `%s` cannot be found' % menu_item)
Exception: menu item `dataset_read` cannot be found
```

See previous issues https://github.com/ckan/ckan/issues/4346 and https://github.com/ckan/ckan/issues/4066

### What steps can be taken to reproduce the issue? 

Create a menu navigation to a dataset detail page, e.g.

https://github.com/ckan/ckan/blob/406be328f3af0c07a8e811b2f395cf6bc2cb13ee/ckan/templates/package/read_base.html#L18-L22



Discussion:
I propose to create unit tests for **all** routes we still want to support, otherwise I will have to open issues forever.
Alternatively we could change `_make_menu_item()` in master to handle these cases better. The current implementation looks like this:

https://github.com/ckan/ckan/blob/7aa42d2ab146a601f0ceefedb376f0f2400a5f01/ckan/lib/helpers.py#L935-L938

Maybe it would be better to call `url_for` instead of checking against `config['routes.named_routes']`

Resolving patch:
diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py
--- a/ckan/lib/helpers.py
+++ b/ckan/lib/helpers.py
@@ -69,8 +69,17 @@
     'home': 'home.index',
     'about': 'home.about',
     'search': 'dataset.search',
+    'dataset_read': 'dataset.read',
+    'dataset_activity': 'dataset.activity',
+    'dataset_groups': 'dataset.groups',
     'group_index': 'group.index',
-    'organizations_index': 'organization.index'
+    'group_about': 'group.about',
+    'group_read': 'group.read',
+    'group_activity': 'group.activity',
+    'organizations_index': 'organization.index',
+    'organization_activity': 'organization.activity',
+    'organization_read': 'organization.read',
+    'organization_about': 'organization.about',
 }
 
 


Test patch:
diff --git a/ckan/tests/lib/test_helpers.py b/ckan/tests/lib/test_helpers.py
--- a/ckan/tests/lib/test_helpers.py
+++ b/ckan/tests/lib/test_helpers.py
@@ -563,6 +563,51 @@ def test_legacy_pylon_routes(self):
             '<li><a href="/group/">Groups</a></li>'
             '<li><a href="/about">About</a></li>'))
 
+    def test_dataset_navigation_legacy_routes(self):
+        dataset_name = 'test-dataset'
+        eq_(
+            h.build_nav_icon('dataset_read', 'Datasets', id=dataset_name),
+            '<li><a href="/dataset/test-dataset">Datasets</a></li>'
+        )
+        eq_(
+            h.build_nav_icon('dataset_groups', 'Groups', id=dataset_name),
+            '<li><a href="/dataset/groups/test-dataset">Groups</a></li>'
+        )
+        eq_(
+            h.build_nav_icon('dataset_activity', 'Activity Stream', id=dataset_name),
+            '<li><a href="/dataset/activity/test-dataset">Activity Stream</a></li>'
+        )
+
+    def test_group_navigation_legacy_routes(self):
+        group_name = 'test-group'
+        eq_(
+            h.build_nav_icon('group_read', 'Datasets', id=group_name),
+            '<li><a href="/group/test-group">Datasets</a></li>'
+        )
+        eq_(
+            h.build_nav_icon('group_activity', 'Activity Stream', id=group_name),
+            '<li><a href="/group/activity/test-group">Activity Stream</a></li>'
+        )
+        eq_(
+            h.build_nav_icon('group_about', 'About', id=group_name),
+            '<li><a href="/group/about/test-group">About</a></li>'
+        )
+
+    def test_organization_navigation_legacy_routes(self):
+        org_name = 'test-org'
+        eq_(
+            h.build_nav_icon('organization_read', 'Datasets', id=org_name),
+            '<li><a href="/organization/test-org">Datasets</a></li>'
+        )
+        eq_(
+            h.build_nav_icon('organization_activity', 'Activity Stream', id=org_name),
+            '<li><a href="/organization/activity/test-org">Activity Stream</a></li>'
+        )
+        eq_(
+            h.build_nav_icon('organization_about', 'About', id=org_name),
+            '<li><a href="/organization/about/test-org">About</a></li>'
+        )
+
 
 class TestHelperException(helpers.FunctionalTestBase):