Skip to content

Commit

Permalink
Idea for #334
Browse files Browse the repository at this point in the history
  • Loading branch information
nutjob4life committed Jan 24, 2024
1 parent 94d5a11 commit c271cd8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ class DatasetMetadataForm(AbstractEDRNForm):
label='Reference URL Description',
help_text='Select the description of the resource found at the reference URL.',
choices=(
('gdc', 'Genomics Data Commons'),
('cd', 'Clinical Data'),
('dbgap', 'dbGAP'),
('gdc', 'Genomics Data Commons'),
('other', 'Other'),
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'''😌 EDRN Site Content: metadata collection form.'''

from .base_forms import (
AbstractEDRNForm, institution_choices, pi_choices, discipline_choices, data_category_choices, ALL_USERS_DN
AbstractEDRNForm, pi_site_choices, discipline_choices, data_category_choices, ALL_USERS_DN
)
from .base_models import AbstractFormPage
from captcha.fields import ReCaptchaField
Expand Down Expand Up @@ -46,8 +46,7 @@ class MetadataCollectionForm(AbstractEDRNForm):
description = forms.CharField(label='Collection Description', help_text='A short summary of this collection.', widget=forms.Textarea)
custodian = forms.CharField(label='Data Custodian', help_text='Genrally, this is your name.')
custodian_email = forms.EmailField(label='Data Custodian Email', help_text='Email address for the data custodian.')
lead_pi = forms.ChoiceField(label='Lead PI', help_text='Select a primary investigator.', choices=pi_choices)
institution = forms.ChoiceField(label='Institution', help_text='Select the curating instutition.', choices=institution_choices)
pi_site = forms.ChoiceField(label='Lead PI and Institution', help_text='Select a primary investigator and the institution to which they belong.', choices=pi_site_choices)
protocol = forms.ChoiceField(label='Protocol', help_text='Select the protocol that generated the data.', choices=_protocols)
discipline = forms.MultipleChoiceField(label='Discipline', widget=forms.CheckboxSelectMultiple, choices=discipline_choices)
cg = forms.ChoiceField(
Expand Down Expand Up @@ -80,8 +79,9 @@ class MetadataCollectionForm(AbstractEDRNForm):
label='Reference URL Description',
help_text='Select the description of the resource found at the reference URL.',
choices=(
('gdc', 'Genomics Data Commons'),
('cd', 'Clinical Data'),
('dbgap', 'dbGAP'),
('gdc', 'Genomics Data Commons'),
('other', 'Other'),
)
)
Expand Down Expand Up @@ -146,15 +146,17 @@ def render_email(self, form):
cp.set('Collection', 'CollectionName', data['collection_name'])
cp.set('Collection', 'CollectionDescription', data['description'])

pi = Person.objects.filter(identifier=data['lead_pi']).first()
cp.set('Collection', 'LeadPIID', self._code(data['lead_pi']))
site_id, pi_id = data['pi_site'].split('-')

pi = Person.objects.filter(personID=pi_id).first()
cp.set('Collection', 'LeadPIID', pi_id)
cp.set('Collection', 'LeadPIName', pi.title)

cp.set('Collection', 'DataCustodian', data['custodian'])
cp.set('Collection', 'DataCustodianEmail', data['custodian_email'])

site = Site.objects.filter(identifier=data['institution']).first()
cp.set('Collection', 'InstitutionID', self._code(data['institution']))
site = Site.objects.filter(dmccSiteID=site_id).first()
cp.set('Collection', 'InstitutionID', site_id)
cp.set('Collection', 'InstitutionName', site.title)

protocol = Protocol.objects.filter(identifier=data['protocol']).first()
Expand Down
18 changes: 18 additions & 0 deletions src/edrnsite.content/src/edrnsite/content/base_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,24 @@ def pi_choices():
]


def pi_site_choices():
'''Vocabulary for choices for principal investigators and their sites.'''

_kinds = {
'Clinical Validation Center', 'Data Management and Coordinating Center', 'National Cancer Institute',
'Biomarker Reference Laboratories', 'Associate Member A - EDRN Funded', 'Associate Member B',
'Associate Member C', 'Biomarker Characterization Center', 'Biomarker Developmental Laboratories'
}
return [
(
f'{site.dmccSiteID}-{site.pi.personID}',
f'{site.pi.title.strip()} ({site.title.strip()}, {site.memberType}, site ID {site.dmccSiteID})'
) for site in Site.objects.filter(
memberType__in=_kinds
).exclude(dmccSiteID=None).exclude(pi=None).exclude(pi__personID=None).order_by('pi__title')
]


def discipline_choices():
'''Vocabulary for choices for disciplines.'''
return [
Expand Down

0 comments on commit c271cd8

Please sign in to comment.