okfn/ckan — pull request #192 by seanh (2012-12-02 15:39:52+00:00)
Title: Make recently_changed_packages_activity_stream a helper

@tobes Could you review this please? Unless I missed something
`recently_changed_packages_activity_stream` was not working at all the way it was done. Either way, this is probably better.

Assuming you're happy with this, then perhaps other activity streams (dataset pages, group pages, user profile pages) should be moved to helper functions as well. I could also add tests for the helper functions, but they are just trivial wrappers of logic action functions.

* * *

`recently_changed_packages_activity_stream` was an `@property` of the
`HomeController`, but it wasn't working, accessing the property just
printed out a property object e.g. `` not
the HTML string as desired.

I think this is because the `@property` was declared inside a method, and
properties only work at class-level.

The `@property` cannot simply be moved to class level because it uses
`context`, a param of the `index()` method it was defined in.

Instead move `recently_changed_packages_activity_stream` into `helpers.py`,
where any template (not just the front page) can access it like this:

{{ h.recently_changed_packages_activity_stream() }}

`dashboard_activity_stream` is already done the same way (but other
activity streams are not).

This means any existing `home/index.html` templates that were accessing
`recently_changed_packages_activity_stream` as an attribute of the
template context itself, will no longer work. However, apparently they
weren't working anyway.