Skip to content

Commit

Permalink
Merge branch '256-dashboard_activity_list_error'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hammond committed Apr 17, 2013
2 parents 0955b0c + ffcc901 commit 250233e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ckan/controllers/user.py
Expand Up @@ -575,8 +575,8 @@ def dashboard(self, id=None, offset=0):
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(
id, filter_type, filter_id, offset)
c.dashboard_activity_stream = h.dashboard_activity_stream(filter_type,
filter_id, offset)

# Mark the user's new activities as old whenever they view their
# dashboard page.
Expand Down
4 changes: 2 additions & 2 deletions ckan/lib/helpers.py
Expand Up @@ -1289,7 +1289,7 @@ def user_in_org_or_group(group_id):

def dashboard_activity_stream(user_id, filter_type=None, filter_id=None,
offset=0):
'''Return the dashboard activity stream of the given user.
'''Return the dashboard activity stream of the current user.
:param user_id: the id of the user
:type user_id: string
Expand Down Expand Up @@ -1317,7 +1317,7 @@ def dashboard_activity_stream(user_id, filter_type=None, filter_id=None,
return action_function(context, {'id': filter_id, 'offset': offset})
else:
return logic.get_action('dashboard_activity_list_html')(
context, {'id': user_id, 'offset': offset})
context, {'offset': offset})


def recently_changed_packages_activity_stream():
Expand Down
8 changes: 4 additions & 4 deletions ckan/logic/action/get.py
Expand Up @@ -830,7 +830,7 @@ def _group_or_org_show(context, data_dict, is_org=False):
_check_access('organization_show',context, data_dict)
else:
_check_access('group_show',context, data_dict)


group_dict = model_dictize.group_dictize(group, context)

Expand Down Expand Up @@ -2645,11 +2645,11 @@ def dashboard_activity_list_html(context, data_dict):
'''
activity_stream = dashboard_activity_list(context, data_dict)
model = context['model']
offset = int(data_dict.get('offset', 0))
extra_vars = {
'controller': 'dashboard',
'action': 'activity',
'id': data_dict['id'],
'controller': 'user',
'action': 'dashboard',
'offset': offset,
}
return activity_streams.activity_list_to_html(context, activity_stream,
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/activity_streams/activity_stream_items.html
Expand Up @@ -4,7 +4,7 @@
{% if activities %}
<ul class="activity" data-module="activity-stream" data-module-more="{{ has_more }}" data-module-context="{{ controller }}" data-module-id="{{ id }}" data-module-offset="{{ offset }}">
{% if offset > 0 %}
<li class="load-less"><a href="{{ h.url_for(controller=controller, action=action, id=id, offset=offset-30) }}" class="btn btn-rounded">{{ _('Load less') }}</a></li>
<li class="load-less"><a href="{{ h.url_for(controller=controller, action=action, id=id, offset=(offset-30 if offset-30 > 0 else 0)) }}" class="btn btn-rounded">{{ _('Load less') }}</a></li>
{% endif %}
{% for activity in activities %}
{% if loop.index <= has_more_length %}
Expand Down
17 changes: 17 additions & 0 deletions ckan/tests/functional/api/test_dashboard.py
Expand Up @@ -331,3 +331,20 @@ def test_09_activities_that_should_not_show(self):
after = self.dashboard_activity_list(self.new_user)

assert before == after

def test_10_dashboard_activity_list_html_does_not_crash(self):

params = json.dumps({'name': 'irrelevant_dataset1'})
response = self.app.post('/api/action/package_create', params=params,
extra_environ={'Authorization': str(self.annafan['apikey'])})
assert response.json['success'] is True

params = json.dumps({'name': 'another_irrelevant_dataset'})
response = self.app.post('/api/action/package_create', params=params,
extra_environ={'Authorization': str(self.annafan['apikey'])})
assert response.json['success'] is True

res = self.app.get('/api/3/action/dashboard_activity_list_html',
extra_environ={'Authorization':
str(self.annafan['apikey'])})
assert res.json['success'] is True

0 comments on commit 250233e

Please sign in to comment.