mirror of
https://github.com/sartography/protocol-builder-mock.git
synced 2025-01-12 08:44:46 +00:00
Merge pull request #72 from sartography/user-studies-endpoint-561
User studies endpoint #561
This commit is contained in:
commit
a37d2f747d
@ -2,12 +2,12 @@ from pb import session
|
|||||||
from pb.models import Investigator, InvestigatorSchema, IRBInfo, IRBInfoSchema, \
|
from pb.models import Investigator, InvestigatorSchema, IRBInfo, IRBInfoSchema, \
|
||||||
IRBStatus, IRBStatusSchema, RequiredDocument, RequiredDocumentSchema, \
|
IRBStatus, IRBStatusSchema, RequiredDocument, RequiredDocumentSchema, \
|
||||||
Study, StudySchema, StudyDetails, StudyDetailsSchema, \
|
Study, StudySchema, StudyDetails, StudyDetailsSchema, \
|
||||||
StudySponsor, StudySponsorSchema
|
StudySponsor, StudySponsorSchema, CreatorStudySchema
|
||||||
|
|
||||||
|
|
||||||
def get_user_studies(uva_id):
|
def get_user_studies(uva_id):
|
||||||
studies = session.query(Study).filter(Study.NETBADGEID == uva_id).all()
|
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):
|
def required_docs(studyid):
|
||||||
|
14
pb/models.py
14
pb/models.py
@ -283,6 +283,20 @@ class IRBStatusSchema(ma.Schema):
|
|||||||
fields = ("STATUS", "DETAIL")
|
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 StudySchema(ma.Schema):
|
||||||
class Meta:
|
class Meta:
|
||||||
include_relationships = True
|
include_relationships = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user