Merge pull request #72 from sartography/user-studies-endpoint-561

User studies endpoint #561
This commit is contained in:
Dan Funk 2021-12-07 10:11:19 -05:00 committed by GitHub
commit a37d2f747d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -2,12 +2,12 @@ from pb import session
from pb.models import Investigator, InvestigatorSchema, IRBInfo, IRBInfoSchema, \
IRBStatus, IRBStatusSchema, RequiredDocument, RequiredDocumentSchema, \
Study, StudySchema, StudyDetails, StudyDetailsSchema, \
StudySponsor, StudySponsorSchema
StudySponsor, StudySponsorSchema, CreatorStudySchema
def get_user_studies(uva_id):
studies = session.query(Study).filter(Study.NETBADGEID == uva_id).all()
return StudySchema(many=True).dump(studies)
return CreatorStudySchema(many=True).dump(studies)
def required_docs(studyid):

View File

@ -283,6 +283,20 @@ class IRBStatusSchema(ma.Schema):
fields = ("STATUS", "DETAIL")
class CreatorStudySchema(ma.Schema):
class Meta:
model = Study
include_relationships = True
load_instance = True
fields = ["STUDYID", "TITLE", "DATECREATED", "DATELASTMODIFIED"]
DATECREATED = DATELASTMODIFIED = fields.Method("get_dates")
@staticmethod
def get_dates(obj):
if obj is not None and hasattr(obj, "DATE_MODIFIED"):
return obj.DATE_MODIFIED
class StudySchema(ma.Schema):
class Meta:
include_relationships = True