Skip to content

Commit

Permalink
[Fixes #3929] Show documents also on Groups Activity Tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Sep 24, 2018
1 parent 9f9fd91 commit 33b1ee3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
10 changes: 10 additions & 0 deletions geonode/groups/templates/groups/activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ <h2 class="page-title">{% trans "Activity Feed for" %} <a href="{% url "group_
<li class="active"><a href="#all" data-toggle="tab"><i class=""></i>{% trans "All" %}</a></li>
<li><a href="#layers" data-toggle="tab"><i class="fa fa-square-o rotate-45"></i> {% trans "Layers" %}</a></li>
<li><a href="#maps" data-toggle="tab"><i class="fa fa-map-marker"></i> {% trans "Maps" %}</a></li>
<li><a href="#documents" data-toggle="tab"><i class="fa fa-file-text-o"></i> {% trans "Documents" %}</a></li>
<li><a href="#comments" data-toggle="tab"><i class="fa fa-comment-o"></i> {% trans "Comments" %}</a></li>
</ul>
<div class="tab-content">
Expand Down Expand Up @@ -55,6 +56,15 @@ <h2 class="page-title">{% trans "Activity Feed for" %} <a href="{% url "group_
{% endfor %}
</ul>
</article>
<article id="documents" class="tab-pane">
<ul class="no-style-list">
{% for action in action_list_documents %}
{% activity_item action %}
{% empty %}
<p>{% trans "No actions yet" %}</p>
{% endfor %}
</ul>
</article>
<article id="comments" class="tab-pane">
<ul class="no-style-list">
{% for action in action_list_comments %}
Expand Down
18 changes: 18 additions & 0 deletions geonode/groups/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,24 @@ def test_group_activity_pages_render(self):

response = self.client.get("/groups/group/bar/activity/")
self.assertEqual(200, response.status_code)
self.assertContains(response,
'Layers',
count=0,
status_code=200,
msg_prefix='',
html=False)
self.assertContains(response,
'Maps',
count=0,
status_code=200,
msg_prefix='',
html=False)
self.assertContains(response,
'Documents',
count=0,
status_code=200,
msg_prefix='',
html=False)
self.assertContains(response,
'<a href="/layers/geonode:CA">CA</a>',
count=0,
Expand Down
9 changes: 9 additions & 0 deletions geonode/groups/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def get_context_data(self, **kwargs):
context['object'] = self.group
context['maps'] = self.group.resources(resource_type='map')
context['layers'] = self.group.resources(resource_type='layer')
context['documents'] = self.group.resources(resource_type='document')
context['is_member'] = self.group.user_is_member(self.request.user)
context['is_manager'] = self.group.user_is_role(
self.request.user,
Expand Down Expand Up @@ -275,6 +276,14 @@ def getKey(action):
for action in actions
if action.action_object and action.action_object.group == self.group.group][:15]
action_list.extend(context['action_list_maps'])
actions = Action.objects.filter(
public=True,
action_object_content_type__model='document')[:15]
context['action_list_documents'] = [
action
for action in actions
if action.action_object and action.action_object.group == self.group.group][:15]
action_list.extend(context['action_list_documents'])
context['action_list_comments'] = Action.objects.filter(
public=True,
actor_object_id__in=members,
Expand Down
4 changes: 4 additions & 0 deletions geonode/social/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def activity_post_modify_object(sender, instance, created=None, **kwargs):
updated_verb=_("updated a comment"),
)
action_settings['layer'].update(created_verb=_('uploaded'))
action_settings['document'].update(created_verb=_('uploaded'))

action = action_settings[obj_type]
if created:
Expand Down Expand Up @@ -151,6 +152,9 @@ def relationship_post_save(instance, sender, created, **kwargs):
signals.post_save.connect(activity_post_modify_object, sender=Map)
signals.post_delete.connect(activity_post_modify_object, sender=Map)

signals.post_save.connect(activity_post_modify_object, sender=Document)
signals.post_delete.connect(activity_post_modify_object, sender=Document)


def notification_post_save_resource(instance, sender, created, **kwargs):
""" Send a notification when a layer, map or document is created or
Expand Down

0 comments on commit 33b1ee3

Please sign in to comment.