Skip to content

Commit

Permalink
Merge pull request #43 from ola-t/runs
Browse files Browse the repository at this point in the history
Run analysis status
  • Loading branch information
atarkowska authored Nov 15, 2017
2 parents c5d65b6 + d1d89bf commit ad423fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
30 changes: 18 additions & 12 deletions emgapi/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,47 @@ 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:
_instance = _query_filters[self.__class__.__name__]
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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ad423fd

Please sign in to comment.