diff --git a/emgapi/models.py b/emgapi/models.py index ae8194666..531fa608f 100644 --- a/emgapi/models.py +++ b/emgapi/models.py @@ -38,31 +38,37 @@ class BaseQuerySet(models.QuerySet): def available(self, request=None): _query_filters = { 'StudyQuerySet': { - 'all': Q(is_public=1), + 'all': [Q(is_public=1), ], }, 'SampleQuerySet': { - 'all': Q(is_public=1), + 'all': [Q(is_public=1), ], }, 'RunQuerySet': { - 'all': Q(analysis_status_id=3, run_status_id=4), + 'all': [ + Q(run_status_id=4), + Q(analysis_status_id=3) | Q(analysis_status_id=6) + ], }, 'AnalysisJobQuerySet': { - 'all': Q(analysis_status_id=3, run_status_id=4), + 'all': [ + Q(run_status_id=4), + Q(analysis_status_id=3) | Q(analysis_status_id=6) + ], }, } if request is not None and request.user.is_authenticated(): _username = request.user.username _query_filters['StudyQuerySet']['authenticated'] = \ - (Q(submission_account_id=_username) | Q(is_public=1)) + [Q(submission_account_id=_username) | Q(is_public=1)] _query_filters['SampleQuerySet']['authenticated'] = \ - (Q(submission_account_id=_username) | Q(is_public=1)) + [Q(submission_account_id=_username) | Q(is_public=1)] _query_filters['RunQuerySet']['authenticated'] = \ - (Q(study__submission_account_id=_username, run_status_id=2) | - Q(run_status_id=4)) + [Q(study__submission_account_id=_username, run_status_id=2) | + Q(run_status_id=4)] _query_filters['AnalysisJobQuerySet']['authenticated'] = \ - (Q(study__submission_account_id=_username, run_status_id=2) | - Q(run_status_id=4)) + [Q(study__submission_account_id=_username, run_status_id=2) | + Q(run_status_id=4)] q = list() try: @@ -70,9 +76,9 @@ def available(self, request=None): if isinstance(self, self.__class__): if request is not None and request.user.is_authenticated(): if not request.user.is_superuser: - q.append(_instance['authenticated']) + q.extend(_instance['authenticated']) else: - q.append(_instance['all']) + q.extend(_instance['all']) return self.distinct().filter(*q) except KeyError: pass diff --git a/setup.py b/setup.py index 0d1af1d0d..1d95756d4 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ _requirements = os.path.join(_base, 'requirements.txt') _requirements_test = os.path.join(_base, 'requirements-test.txt') -version = "0.4.0" +version = "0.4.1" install_requirements = [] with open(_requirements) as f: