Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pacifica/metadata/rest/project_queries/project_user_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""CherryPy Status Metadata object class."""
import re
from cherrypy import tools, HTTPError
from pacifica.metadata.orm import Projects, ProjectUser
from pacifica.metadata.orm import Projects, ProjectUser, Relationships
from pacifica.metadata.rest.project_queries.query_base import QueryBase
from pacifica.metadata.rest.userinfo import user_exists_decorator
from pacifica.metadata.orm.base import db_connection_decorator
Expand All @@ -19,9 +19,11 @@ class ProjectUserSearch(QueryBase):
def get_projects_for_user(user_id):
"""Return a list of formatted project objects for the indicated user."""
# get list of project_ids for this user
where_clause = ProjectUser().where_clause(
{'user_id': user_id})
if not user_id:
return []
where_clause = ProjectUser().where_clause({'user_id': user_id})
# pylint: disable=no-member
where_clause &= Relationships().where_clause({'name': 'member_of'})
projects = (Projects
.select(
Projects.id, Projects.title, Projects.actual_start_date,
Expand All @@ -30,6 +32,7 @@ def get_projects_for_user(user_id):
Projects.project_type
)
.join(ProjectUser)
.join(Relationships)
.where(where_clause)
.order_by(Projects.title))
# pylint: enable=no-member
Expand Down
2 changes: 1 addition & 1 deletion tests/core/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,4 +303,4 @@ def test_client_update_unk_error(self):
client.update(class_type, params, post_body)
except PMClientError as ex:
self.assertTrue('301' in str(ex))
self.assertTrue('This is the error.'in str(ex))
self.assertTrue('This is the error.' in str(ex))
2 changes: 2 additions & 0 deletions tests/core/cmd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def requests_retry_session(retries=3, backoff_factor=0.5, status_forcelist=(500,
# The complication here is that older versions of the metadata service can't install
# in Python versions > 3.7. The psycopg2 package required for those older versions
# do not compile against Python > 3.7.


@pytest.mark.skipif(sys.version_info > (3, 8), reason='requires python3.7 or less')
class AdminCmdBase:
"""Test base class for setting up update environments."""
Expand Down