Skip to content

Commit

Permalink
filter on users OR microblog context, not both
Browse files Browse the repository at this point in the history
  • Loading branch information
gyst committed Jun 28, 2013
1 parent 904f2d5 commit e4e79ef
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
6 changes: 4 additions & 2 deletions CHANGES.txt
@@ -1,8 +1,10 @@
Changelog
=========

0.4.4 (Unreleased)
------------------
0.5 (Unreleased)
-----------------

* Filter on users OR microblog context, not both [gyst]

* French translation.
[thomasdesvenain]
Expand Down
28 changes: 14 additions & 14 deletions plonesocial/activitystream/browser/stream_provider.py
Expand Up @@ -62,6 +62,7 @@ def __init__(self, context, request, view):
# @@stream and plonesocial.network:@@profile
# render this optionally with a users filter
self.users = None
self.microblog_context = get_microblog_context(context)

def update(self):
pass
Expand Down Expand Up @@ -110,15 +111,15 @@ def _activities_brains(self):
contentfilter = dict(sort_on='Date',
sort_order='reverse',
sort_limit=self.count * 10)
microblog_context = get_microblog_context(self.context)
if microblog_context:
contentfilter['path'] = \
'/'.join(microblog_context.getPhysicalPath())

if self.tag:
contentfilter["Subject"] = self.tag
# filter on users OR context, not both
if self.users:
contentfilter["Creator"] = self.users
elif self.microblog_context:
contentfilter['path'] = \
'/'.join(self.microblog_context.getPhysicalPath())

return catalog.searchResults(**contentfilter)

def _activities_statuses(self):
Expand All @@ -129,22 +130,21 @@ def _activities_statuses(self):
if not container:
return []
try:
# filter on users OR context, not both
if self.users:
# support plonesocial.network integration
return container.user_values(self.users,
limit=self.count,
tag=self.tag)
elif self.microblog_context:
# support collective.local integration
return container.context_values(self.microblog_context,
limit=self.count,
tag=self.tag)
else:
# default implementation
microblog_context = get_microblog_context(self.context)
if microblog_context:
return container.context_values(microblog_context,
limit=self.count,
tag=self.tag)
else:
return container.values(limit=self.count,
tag=self.tag,
)
return container.values(limit=self.count,
tag=self.tag)
except Unauthorized:
return []

Expand Down
2 changes: 1 addition & 1 deletion setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

version = '0.4.3'
version = '0.5.dev'

long_description = (
open('README.rst').read()
Expand Down

0 comments on commit e4e79ef

Please sign in to comment.