Skip to content

Commit

Permalink
Merge branch 'master' into 2939-orgs
Browse files Browse the repository at this point in the history
Conflicts:
	ckan/lib/helpers.py

    trivial merge new functions in org branch and
    dashboard_activity_stream() has offset param added
  • Loading branch information
tobes committed Dec 12, 2012
2 parents cdc8ee8 + 67a6121 commit 15eb468
Show file tree
Hide file tree
Showing 19 changed files with 389 additions and 46 deletions.
6 changes: 6 additions & 0 deletions ckan/config/deployment.ini_tmpl
Expand Up @@ -236,6 +236,12 @@ ckan.feeds.author_link =
#ofs.aws_secret_access_key = ....


# Activity Streams
#
# Default maximum number of activities to show in an activity stream.
# ckan.activity_list_limit = 31


# DEBUGGING

# ckan.debug_supress_header This option can be set to suppress the debug
Expand Down
5 changes: 5 additions & 0 deletions ckan/config/routing.py
Expand Up @@ -191,11 +191,13 @@ def make_map():
'activity',
'followers',
'follow',
'activity',
'unfollow',
'delete',
'api_data',
]))
)
m.connect('/dataset/activity/{id}/{offset}', action='activity')
m.connect('/dataset/{id}.{format}', action='read')
m.connect('/dataset/{id}', action='read')
m.connect('/dataset/{id}/resource/{resource_id}',
Expand Down Expand Up @@ -243,6 +245,7 @@ def make_map():
'activity',
]))
)
m.connect('group_activity', '/group/activity/{id}/{offset}', action='activity'),
m.connect('group_read', '/group/{id}', action='read')

# organizations these basically end up being the same as groups
Expand Down Expand Up @@ -279,7 +282,9 @@ def make_map():
m.connect('/user/edit', action='edit')
# Note: openid users have slashes in their ids, so need the wildcard
# in the route.
m.connect('/user/activity/{id}/{offset}', action='activity')
m.connect('/user/activity/{id}', action='activity')
m.connect('/dashboard/{offset}', action='dashboard')
m.connect('/dashboard', action='dashboard')
m.connect('/user/follow/{id}', action='follow')
m.connect('/user/unfollow/{id}', action='unfollow')
Expand Down
4 changes: 2 additions & 2 deletions ckan/controllers/group.py
Expand Up @@ -606,7 +606,7 @@ def history(self, id):
return feed.writeString('utf-8')
return render(self._history_template(c.group_dict['type']))

def activity(self, id):
def activity(self, id, offset=0):
'''Render this group's public activity stream page.'''

context = {'model': model, 'session': model.Session,
Expand All @@ -627,7 +627,7 @@ def activity(self, id):
# template context for the group/read.html template to retrieve later.
c.group_activity_stream = \
get_action('group_activity_list_html')(context,
{'id': c.group_dict['id']})
{'id': c.group_dict['id'], 'offset': offset})

return render('group/activity_stream.html')

Expand Down
5 changes: 0 additions & 5 deletions ckan/controllers/home.py
Expand Up @@ -104,11 +104,6 @@ def index(self):
if msg:
h.flash_notice(msg, allow_html=True)

@property
def recently_changed_packages_activity_stream():
return ckan.logic.action.get.recently_changed_packages_activity_list_html(context, {})
c.recently_changed_packages_activity_stream = recently_changed_packages_activity_stream

# START OF DIRTYNESS
def get_group(id):
def _get_group_type(id):
Expand Down
6 changes: 6 additions & 0 deletions ckan/controllers/package.py
Expand Up @@ -29,6 +29,7 @@
import ckan.rating
import ckan.misc
import ckan.lib.accept as accept
import ckan.plugins as plugins
from home import CACHE_PARAMETERS

from ckan.lib.plugins import lookup_package_plugin
Expand Down Expand Up @@ -239,10 +240,15 @@ def pager_url(q=None, page=None):
for facet in c.search_facets.keys():
limit = int(request.params.get('_%s_limit' % facet, 10))
c.search_facets_limits[facet] = limit

# Facet titles
c.facet_titles = {'groups': _('Groups'),
'tags': _('Tags'),
'res_format': _('Formats'),
'license': _('Licence'), }
for plugin in plugins.PluginImplementations(plugins.IPackageController):
c.facet_titles = plugin.update_facet_titles(c.facet_titles)


maintain.deprecate_context_item(
'facets',
Expand Down
10 changes: 5 additions & 5 deletions ckan/controllers/user.py
Expand Up @@ -477,7 +477,7 @@ def followers(self, id=None):
c.followers = f(context, {'id': c.user_dict['id']})
return render('user/followers.html')

def activity(self, id):
def activity(self, id, offset=0):
'''Render this user's public activity stream page.'''

context = {'model': model, 'session': model.Session,
Expand All @@ -491,17 +491,17 @@ def activity(self, id):
self._setup_template_variables(context, data_dict)

c.user_activity_stream = get_action('user_activity_list_html')(
context, {'id': c.user_dict['id']})
context, {'id': c.user_dict['id'], 'offset': offset})

return render('user/activity_stream.html')

def dashboard(self, id=None):
def dashboard(self, id=None, offset=0):
context = {'model': model, 'session': model.Session,
'user': c.user or c.author, 'for_view': True}
data_dict = {'id': id, 'user_obj': c.userobj}
data_dict = {'id': id, 'user_obj': c.userobj, 'offset': offset}
self._setup_template_variables(context, data_dict)

c.dashboard_activity_stream = h.dashboard_activity_stream(id)
c.dashboard_activity_stream = h.dashboard_activity_stream(id, offset)

# Mark the user's new activities as old whenever they view their
# dashboard page.
Expand Down
16 changes: 13 additions & 3 deletions ckan/lib/activity_streams.py
Expand Up @@ -207,9 +207,18 @@ def activity_stream_string_new_related_item():
# A list of activity types that may have details
activity_stream_actions_with_detail = ['changed package']

def activity_list_to_html(context, activity_stream):
'''Return the given activity stream as a snippet of HTML.'''
def activity_list_to_html(context, activity_stream, extra_vars):
'''Return the given activity stream as a snippet of HTML.
:param activity_stream: the activity stream to render
:type activity_stream: list of activity dictionaries
:param extra_vars: extra variables to pass to the activity stream items
template when rendering it
:type extra_vars: dictionary
:rtype: HTML-formatted string
'''
activity_list = [] # These are the activity stream messages.
for activity in activity_stream:
detail = None
Expand Down Expand Up @@ -256,5 +265,6 @@ def activity_list_to_html(context, activity_stream):
'data': data,
'timestamp': activity['timestamp'],
'is_new': activity.get('is_new', False)})
extra_vars['activities'] = activity_list
return literal(base.render('activity_streams/activity_stream_items.html',
extra_vars={'activities': activity_list}))
extra_vars=extra_vars))
13 changes: 11 additions & 2 deletions ckan/lib/helpers.py
Expand Up @@ -1209,7 +1209,7 @@ def user_in_org_or_group(group_id):
return len(query.all()) != 0


def dashboard_activity_stream(user_id):
def dashboard_activity_stream(user_id, offset=0):
'''Return the dashboard activity stream of the given user.
:param user_id: the id of the user
Expand All @@ -1222,7 +1222,15 @@ def dashboard_activity_stream(user_id):
import ckan.logic as logic
context = {'model': model, 'session': model.Session, 'user': c.user}
return logic.get_action('dashboard_activity_list_html')(context,
{'id': user_id})
{'id': user_id,
'offset': offset})


def recently_changed_packages_activity_stream():
import ckan.logic as logic
context = {'model': model, 'session': model.Session, 'user': c.user}
return logic.get_action('recently_changed_packages_activity_list_html')(
context, {})


def escape_js(str_to_escape):
Expand Down Expand Up @@ -1418,6 +1426,7 @@ def resource_preview(resource, pkg_id):
'organizations_available',
'user_in_org_or_group',
'dashboard_activity_stream',
'recently_changed_packages_activity_stream',
'escape_js',
'get_pkg_dict_extra',
'get_request_param',
Expand Down

0 comments on commit 15eb468

Please sign in to comment.