Skip to content

Commit

Permalink
Activities are now just templates. Removes all _html 'helpers'.
Browse files Browse the repository at this point in the history
  • Loading branch information
TkTech committed Apr 19, 2017
1 parent c44c0ef commit cf9b198
Show file tree
Hide file tree
Showing 33 changed files with 386 additions and 437 deletions.
25 changes: 13 additions & 12 deletions ckan/controllers/group.py
Expand Up @@ -817,18 +817,19 @@ def activity(self, id, offset=0):
except (NotFound, NotAuthorized):
abort(404, _('Group not found'))

try:
# Add the group's activity stream (already rendered to HTML) to the
# template context for the group/read.html
# template to retrieve later.
c.group_activity_stream = self._action('group_activity_list_html')(
context, {'id': c.group_dict['id'], 'offset': offset})

except ValidationError as error:
base.abort(400)

return render(self._activity_template(group_type),
extra_vars={'group_type': group_type})
return render(
self._activity_template(group_type),
extra_vars={
'group_type': group_type,
'activity_stream': get_action('organization_activity_list')(
context,
{
'id': c.group_dict['id'],
'offset': offset
}
)
}
)

def follow(self, id):
'''Start following this group.'''
Expand Down
18 changes: 12 additions & 6 deletions ckan/controllers/package.py
Expand Up @@ -1277,18 +1277,24 @@ def activity(self, id):
data_dict = {'id': id}
try:
c.pkg_dict = get_action('package_show')(context, data_dict)
c.pkg = context['package']
c.package_activity_stream = get_action(
'package_activity_list_html')(
context, {'id': c.pkg_dict['id']})
dataset_type = c.pkg_dict['type'] or 'dataset'
except NotFound:
abort(404, _('Dataset not found'))
except NotAuthorized:
abort(403, _('Unauthorized to read dataset %s') % id)

return render('package/activity.html',
{'dataset_type': dataset_type})
return render(
'package/activity.html',
extra_vars={
'dataset_type': dataset_type,
'activity_stream': get_action('package_activity_list')(
context,
{
'id': id
}
)
}
)

def resource_embedded_dataviewer(self, id, resource_id,
width=500, height=500):
Expand Down
38 changes: 27 additions & 11 deletions ckan/controllers/user.py
Expand Up @@ -595,13 +595,18 @@ def activity(self, id, offset=0):

self._setup_template_variables(context, data_dict)

try:
c.user_activity_stream = get_action('user_activity_list_html')(
context, {'id': c.user_dict['id'], 'offset': offset})
except ValidationError:
base.abort(400)

return render('user/activity_stream.html')
return render(
'user/activity_stream.html',
extra_vars={
'activity_stream': get_action('user_activity_list')(
context,
{
'id': id,
'offset': offset
}
)
}
)

def _get_dashboard_context(self, filter_type=None, filter_id=None, q=None):
'''Return a dict needed by the dashboard view to determine context.'''
Expand Down Expand Up @@ -668,18 +673,29 @@ def dashboard(self, id=None, offset=0):
filter_id = request.params.get('name', u'')

c.followee_list = get_action('followee_list')(
context, {'id': c.userobj.id, 'q': q})
context,
{
'id': c.userobj.id,
'q': q
}
)

c.dashboard_activity_stream_context = self._get_dashboard_context(
filter_type, filter_id, q)
c.dashboard_activity_stream = h.dashboard_activity_stream(
filter_type,
filter_id,
q
)
dashboard_activity_stream = h.dashboard_activity_stream(
c.userobj.id, filter_type, filter_id, offset
)

# Mark the user's new activities as old whenever they view their
# dashboard page.
get_action('dashboard_mark_activities_old')(context, {})

return render('user/dashboard.html')
return render('user/dashboard.html', extra_vars={
'activity_stream': dashboard_activity_stream
})

def dashboard_datasets(self):
context = {'for_view': True, 'user': c.user,
Expand Down
256 changes: 0 additions & 256 deletions ckan/lib/activity_streams.py

This file was deleted.

0 comments on commit cf9b198

Please sign in to comment.