Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
sweng66 committed Dec 5, 2019
1 parent c524a03 commit 0c7d10a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/author_response_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,54 @@
from sqlalchemy.exc import IntegrityError, DataError
import transaction
import json
from pyramid.response import Response
from validate_email import validate_email
from src.models import DBSession, Authorresponse, Referencedbentity, Source
from src.curation_helpers import get_curator_session

def get_author_responses(curation_id=None):

try:
all = None
if curation_id is None:
all = DBSession.query(Authorresponse).filter_by(no_action_required = '0').all()
else:
all = DBSession.query(Authorresponse).filter_by(curation_id=int(curation_id)).all()
data = []
for x in all:
reference_id = None
if curation_id is not None:
r = DBSession.query(Referencedbentity).filter_by(pmid=int(x.pmid)).one_or_none()
if r is not None:
reference_id = r.dbentity_id
if x.curator_checked_datasets == '1' and curator_checked_genelist == '1':
continue
genes = x.gene_list
if x.gene_list:
genes = genes.replace('|', ' ')
data.append({ 'curation_id': x.curation_id,
'author_email': x.author_email,
'pmid': x.pmid,
'no_action_required': x.no_action_required,
'has_novel_research': x.has_novel_research,
'has_large_scale_data': x.has_large_scale_data,
'has_fast_track_tag': x.has_fast_track_tag,
'curator_checked_datasets': x.curator_checked_datasets,
'curator_checked_genelist': x.curator_checked_genelist,
'research_results': x.research_results,
'gene_list': genes,
'dataset_description': x.dataset_description,
'other_description': x.other_description,
'date_created': str(x.date_created).split(' ')[0] })
if curation_id is not None:
row = data[0]
row['reference_id'] = reference_id
return Response(body=json.dumps(row), content_type='application/json')
else:
return Response(body=json.dumps(data), content_type='application/json')
except Exception as e:
return HTTPBadRequest(body=json.dumps({'error': str(e)}))

def insert_author_response(request):

try:
Expand Down

0 comments on commit 0c7d10a

Please sign in to comment.