Avoid false positives when filtering projects by subscriber

At the moment, filtering projects by subscriber also returns the
projects with the same ID as any project groups that the subscriber
is also subscribed to.

This commit fixes that by filtering for an exact match of 'project',
rather than anything which includes the string 'project'.

Change-Id: I3a9f863e8d8dd18f4b5e3fe9c9fe44ee3c72457c
This commit is contained in:
Adam Coldrick 2016-04-19 12:13:44 +00:00
parent cb775ab95d
commit a0a66e150f
1 changed files with 2 additions and 1 deletions

View File

@ -46,8 +46,9 @@ def project_get_all(marker=None, offset=None, limit=None, sort_field=None,
subs = api_base.model_query(models.Subscription)
subs = api_base.apply_query_filters(query=subs,
model=models.Subscription,
target_type='project',
user_id=subscriber_id)
# Filter by exact match, to avoid matching "project_group"
subs = subs.filter(models.Subscription.target_type == 'project')
subs = subs.subquery()
query = query.join(subs, subs.c.target_id == models.Project.id)