Merge "Allow worklists to be filtered by subscriber_id"
This commit is contained in:
commit
1bf547aa37
@ -364,11 +364,12 @@ class WorklistsController(rest.RestController):
|
||||
@secure(checks.guest)
|
||||
@wsme_pecan.wsexpose([wmodels.Worklist], wtypes.text, int, int,
|
||||
bool, int, int, int, bool, wtypes.text, wtypes.text,
|
||||
wtypes.text, int, int, int)
|
||||
wtypes.text, int, int, int, int)
|
||||
def get_all(self, title=None, creator_id=None, project_id=None,
|
||||
archived=False, user_id=None, story_id=None, task_id=None,
|
||||
hide_lanes=True, sort_field='id', sort_dir='asc',
|
||||
item_type=None, board_id=None, offset=None, limit=None):
|
||||
item_type=None, board_id=None, subscriber_id=None,
|
||||
offset=None, limit=None):
|
||||
"""Retrieve definitions of all of the worklists.
|
||||
|
||||
:param title: A string to filter the title by.
|
||||
@ -389,6 +390,7 @@ class WorklistsController(rest.RestController):
|
||||
from the story.
|
||||
:param board_id: Get all worklists in the board with this id. Other
|
||||
filters are not applied.
|
||||
:param subscriber_id: Filter worklists by whether a user is subscribed.
|
||||
:param offset: Offset at which to begin the results.
|
||||
:param limit: Maximum number of results to return.
|
||||
|
||||
@ -416,6 +418,7 @@ class WorklistsController(rest.RestController):
|
||||
user_id=user_id,
|
||||
story_id=story_id,
|
||||
task_id=task_id,
|
||||
subscriber_id=subscriber_id,
|
||||
sort_field=sort_field,
|
||||
sort_dir=sort_dir,
|
||||
offset=offset,
|
||||
@ -431,6 +434,7 @@ class WorklistsController(rest.RestController):
|
||||
user_id=user_id,
|
||||
story_id=story_id,
|
||||
task_id=task_id,
|
||||
subscriber_id=subscriber_id,
|
||||
current_user=current_user,
|
||||
hide_lanes=hide_lanes,
|
||||
item_type=item_type)
|
||||
|
@ -42,7 +42,7 @@ def get(worklist_id):
|
||||
def _build_worklist_query(title=None, creator_id=None, project_id=None,
|
||||
archived=False, user_id=None, session=None,
|
||||
current_user=None, hide_lanes=True, item_type=None,
|
||||
story_id=None, task_id=None):
|
||||
story_id=None, task_id=None, subscriber_id=None):
|
||||
query = api_base.model_query(models.Worklist, session=session).distinct()
|
||||
|
||||
query = api_base.apply_query_filters(query=query,
|
||||
@ -148,13 +148,23 @@ def _build_worklist_query(title=None, creator_id=None, project_id=None,
|
||||
query = query.filter(items.item_type == 'task')
|
||||
query = query.filter(items.item_id == task_id)
|
||||
|
||||
# Filter by subscriber id
|
||||
if subscriber_id is not None:
|
||||
subs = api_base.model_query(models.Subscription)
|
||||
subs = api_base.apply_query_filters(query=subs,
|
||||
model=models.Subscription,
|
||||
target_type='worklist',
|
||||
user_id=subscriber_id)
|
||||
subs = subs.subquery()
|
||||
query = query.join(subs, subs.c.target_id == models.Worklist.id)
|
||||
|
||||
return query
|
||||
|
||||
|
||||
def get_all(title=None, creator_id=None, project_id=None, board_id=None,
|
||||
user_id=None, story_id=None, task_id=None, sort_field=None,
|
||||
sort_dir=None, session=None, offset=None, limit=None,
|
||||
archived=False, current_user=None, hide_lanes=True,
|
||||
user_id=None, story_id=None, task_id=None, subscriber_id=None,
|
||||
sort_field=None, sort_dir=None, session=None, offset=None,
|
||||
limit=None, archived=False, current_user=None, hide_lanes=True,
|
||||
item_type=None, **kwargs):
|
||||
if sort_field is None:
|
||||
sort_field = 'id'
|
||||
@ -172,6 +182,7 @@ def get_all(title=None, creator_id=None, project_id=None, board_id=None,
|
||||
creator_id=creator_id,
|
||||
project_id=project_id,
|
||||
user_id=user_id,
|
||||
subscriber_id=subscriber_id,
|
||||
archived=archived,
|
||||
session=session,
|
||||
current_user=current_user,
|
||||
@ -190,9 +201,9 @@ def get_all(title=None, creator_id=None, project_id=None, board_id=None,
|
||||
|
||||
|
||||
def get_count(title=None, creator_id=None, project_id=None, board_id=None,
|
||||
user_id=None, story_id=None, task_id=None, session=None,
|
||||
archived=False, current_user=None, hide_lanes=True,
|
||||
item_type=None, **kwargs):
|
||||
user_id=None, story_id=None, task_id=None, subscriber_id=None,
|
||||
session=None, archived=False, current_user=None,
|
||||
hide_lanes=True, item_type=None, **kwargs):
|
||||
if board_id is not None:
|
||||
board = boards.get(board_id)
|
||||
if board is None:
|
||||
@ -205,6 +216,7 @@ def get_count(title=None, creator_id=None, project_id=None, board_id=None,
|
||||
creator_id=creator_id,
|
||||
project_id=project_id,
|
||||
user_id=user_id,
|
||||
subscriber_id=subscriber_id,
|
||||
archived=archived,
|
||||
session=session,
|
||||
current_user=current_user,
|
||||
|
Loading…
x
Reference in New Issue
Block a user