Skip to content

Commit

Permalink
Support #372
Browse files Browse the repository at this point in the history
-   Instead of codes with hyphens, full names of metadata values are in the generated email for the following fields:
    -   `Discipline`
    -   `DataCategory`
    -   `Species`
-   "Name" removed from metadata keys as follows (matching column A):
    -   `InstitutionName` → `Institution`
    -   `LeadPIName` → `LeadPI`
    -   `OrganName` → `Organ`
    -   But: `ProtocolName`, `ProtcolAbbreviatedName`, and `CollectionName` remain untouched
-   LabCAS's weird capitalization enforced as follows (matching column A):
    -   `InstitutionID` → `InstitutionId`
    -   `LeadPIID` → `LeadPIId`
    -   `OrganID` → `OrganId`
    -   `ProtocolID` → `ProtocolId`
    -   But: `PubMedID` remains as is
-   The following fields moved from being appended to the end of the email, to being "fields" in the metadata (column A):
    -   `Instrument`
    -   `Method Details`
    -   These remain as appended to the end of the email (if filled in): comments, biomarkers researched, additional site, type of data being uploaded, other discipline
-   The field `DataDisclaimer` is always filled in; its text can be changed on Wagtail's "Snippets" control panel
-   All permissible values checked (column B)
    -   "Cancers Research Group" dropped from collaborative group names
    -   For `DataCategory`, the `y` stays on `Antibody Microarray` 😌
  • Loading branch information
nutjob4life committed Dec 9, 2024
1 parent 3acbc14 commit 4ed8aa3
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@
from wagtail.contrib.forms.models import EmailFormMixin


def _collab_groups():
'''Return a vocabulary of collaborative groups.
Normally we'd want to use CollaborativeGroupSnippet but there's a nasty
circular dependency that prevents it from being used here. This form should
be in its own module and not in edrnsite.content, which would fix that.
Also, LabCAS drops the "Cancers Research Group" from each collab group name.
'''
return [
('breast', 'Breast and Gynecologic'),
('gi', 'G.I. and Other Associated'),
('lung', 'Lung and Upper Aerodigestive'),
('prostate', 'Prostate and Urologic')
]


def _species():
species = (
'Homo sapiens',
Expand Down Expand Up @@ -66,12 +83,7 @@ class MetadataCollectionForm(AbstractEDRNForm):
cg = forms.ChoiceField(
label='Collaborative Group', help_text='Select the collaborative research group',
widget=forms.RadioSelect,
choices=(
('breast-gyn', 'Breast & Gynecological Cancers Research Group'),
('colorect-gi', 'Colorectal & Other GI Cancers Research Group'),
('lung', 'Lung & Upper Aerodigestive Cancers Research Group'),
('prostate', 'Prostate & Other Urologic Cancers Research Group'),
)
choices=_collab_groups()
)
discipline = forms.MultipleChoiceField(label='Discipline', widget=forms.CheckboxSelectMultiple, choices=discipline_choices)
other_discipline = forms.CharField(
Expand Down Expand Up @@ -177,38 +189,50 @@ def render_email(self, form):
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', 'LeadPIId', pi_id)
cp.set('Collection', 'LeadPI', pi.title)

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

site = Site.objects.filter(dmccSiteID=site_id).first()
cp.set('Collection', 'InstitutionID', site_id)
cp.set('Collection', 'InstitutionName', site.title)
cp.set('Collection', 'InstitutionId', site_id)
cp.set('Collection', 'Institution', site.title)

protocol = Protocol.objects.filter(identifier=data['protocol']).first()
cp.set('Collection', 'ProtocolID', self._code(data['protocol']))
cp.set('Collection', 'ProtocolId', self._code(data['protocol']))
cp.set('Collection', 'ProtocolName', protocol.title)
cp.set('Collection', 'ProtocolAbbreviatedName', protocol.abbreviation)

if data['discipline']:
cp.set('Collection', 'Discipline', '|'.join(data['discipline']))
cp.set('Collection', 'DataCategory', data['category'])
disc_names = {i[0]: i[1] for i in discipline_choices()}
discs = [disc_names[i] for i in data['discipline']]
cp.set('Collection', 'Discipline', '|'.join(discs))
cp.set(
'Collection', 'DataCategory',
{i[0]: i[1] for i in data_category_choices()}[data['category']]
)

bs = BodySystem.objects.filter(identifier=data['organ']).first()
cp.set('Collection', 'OrganID', self._code(data['organ']))
cp.set('Collection', 'OrganName', bs.title)
cp.set('Collection', 'OrganId', self._code(data['organ']))
cp.set('Collection', 'Organ', bs.title)

cp.set(
'Collection', 'CollaborativeGroup',
{i[0]: i[1] for i in _collab_groups()}[data['cg']]
)

cp.set('Collection', 'CollaborativeGroup', data['cg'])
if data['results']: cp.set('Collection', 'ResultsAndConclusionSummary', data['results'])
if data['pub_med_id']: cp.set('Collection', 'PubMedID', data['pub_med_id'])
if data['reference_url']: cp.set('Collection', 'ReferenceURL', data['reference_url'])
if data['reference_url']: cp.set('Collection', 'ReferenceURLLink', data['reference_url'])
if data['reference_url_description']:
cp.set('Collection', 'ReferenceURLDescription', data['reference_url_description'])
if data['reference_url_other']: cp.set('Collection', 'ReferenceURLOther', data['reference_url_other'])
cp.set('Collection', 'Consortium', 'EDRN')
cp.set('Collection', 'Species', data['species'])
cp.set(
'Collection', 'Species',
{i[0]: i[1] for i in _species()}[data['species']]
)

if not data['private']: cp.set('Collection', 'OwnerPrincipal', ALL_USERS_DN)
if data['access_groups']:
Expand All @@ -220,6 +244,18 @@ def render_email(self, form):
if data['doi']: cp.set('Collection', 'DOI', data['doi'])
if data['doi_url']: cp.set('Collection', 'DOIURL', data['doi_url'])

# Always add the data disclaimer #372
from .models import BoilerplateSnippet
disclaimer = BoilerplateSnippet.objects.filter(bp_code='data-disclaimer').first()
if not disclaimer:
disclaimer_text = '«No data disclaimer snippet found in portal snippets»'
else:
disclaimer_text = disclaimer.text
cp.set('Collection', 'DataDisclaimer', disclaimer_text)

if data['instrument']: cp.set('Collection', 'Instrument', data['instrument'])
if data['method_details']: cp.set('Collection', 'MethodDetails', data['method_details'])

buffer = StringIO()
cp.write(buffer)

Expand Down Expand Up @@ -247,18 +283,6 @@ def render_email(self, form):
buffer.write('\n\nThe following was entered into the "type of data" field:\n\n')
buffer.write(data['type_of_data'])

if data['method_details']:
buffer.write('\n\n\n')
buffer.write('-' * 40)
buffer.write('\n\nThe following was entered into the "method details" field:\n\n')
buffer.write(data['method_details'])

if data['instrument']:
buffer.write('\n\n\n')
buffer.write('-' * 40)
buffer.write('\n\nThe following was entered into the "instrument" field:\n\n')
buffer.write(data['instrument'])

if data['other_discipline']:
buffer.write('\n\n\n')
buffer.write('-' * 40)
Expand Down
6 changes: 3 additions & 3 deletions src/edrnsite.content/src/edrnsite/content/base_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ def discipline_choices():
'''Vocabulary for choices for disciplines.'''
return [
('genomics', 'Genomics'),
('immunology', 'Immunology'),
('metabolomics', 'Metabolomics'),
('proteomics', 'Proteomics'),
('pathology', 'Pathology'),
('pathology-images', 'Pathology Images'),
('proteomics', 'Proteomics'),
('radiology', 'Radiology'),
('immunology', 'Immunology'),
('pathology', 'Pathology'),
('other', 'Other'),
]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# encoding: utf-8

'''😌 EDRN Site Content: add data disclaimer snippet.'''

from django.core.management.base import BaseCommand
from django.db.utils import IntegrityError
from edrnsite.content.models import BoilerplateSnippet


_default_data_disclaimer = '''Data and information released from the National Cancer Institute (NCI) are provided on
an "AS IS" basis, without warranty of any kind, including without limitation the warranties of merchantability, fitness
for a particular purpose and non-infringement. Availability of this data and information does not constitute scientific
publication. Data and/or information may contain errors or be incomplete. NCI and its employees make no representation
or warranty, express or implied, including without limitation any warranties of merchantability or fitness for a
particular purpose or warranties as to the identity or ownership of data or information, the quality, accuracy or
completeness of data or information, or that the use of such data or information will not infringe any patent,
intellectual property or proprietary rights of any party. NCI shall not be liable for any claim for any loss, harm,
illness or other damage or injury arising from access to or use of data or information, including without limitation
any direct, indirect, incidental, exemplary, special or consequential damages, even if advised of the possibility of
such damages. In accordance with scientific standards, appropriate acknowledgment of NCI should be made in any
publications or other disclosures concerning data or information made available by NCI.'''


class Command(BaseCommand):
help = 'Add the data disclaimer snippet'

def handle(self, *args, **options):
try:
self.stdout.write('Adding data disclaimer snippet')
BoilerplateSnippet.objects.get_or_create(
bp_code='data-disclaimer', text=_default_data_disclaimer
)
except IntegrityError:
pass
3 changes: 2 additions & 1 deletion support/cbiit-deploy-prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ docker compose --project-name edrn start portal" || exit 1
echo ""
echo "🆙 Applying upgrades"
ssh -q $USER@$WEBSERVER "cd $WEBROOT ; \
docker compose --project-name edrn exec portal /usr/bin/django-admin copy_daily_hits_from_wagtailsearch" || exit 1
docker compose --project-name edrn exec portal /usr/bin/django-admin copy_daily_hits_from_wagtailsearch &&\
docker compose --project-name edrn exec portal /usr/bin/django-admin edrn_data_disclaimer" || exit 1

echo ""
echo "🤷‍♀️ Final portal restart and restart of search engine"
Expand Down
4 changes: 3 additions & 1 deletion support/cbiit-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ docker compose --project-name edrn start portal" || exit 1
echo ""
echo "🆙 Applying upgrades"
ssh -q $USER@$WEBSERVER "cd $WEBROOT ; \
docker compose --project-name edrn exec portal /usr/bin/django-admin copy_daily_hits_from_wagtailsearch" || exit 1
docker compose --project-name edrn exec portal /usr/bin/django-admin copy_daily_hits_from_wagtailsearch &&\
docker compose --project-name edrn exec portal /usr/bin/django-admin edrn_data_disclaimer" || exit 1


echo ""
echo "🤷‍♀️ Final portal restart and restart of search engine"
Expand Down
1 change: 1 addition & 0 deletions support/devrebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ bzip2 --decompress --stdout edrn.sql.bz2 | psql --dbname=edrn --echo-errors --qu
./manage.sh migrate
./manage.sh copy_daily_hits_from_wagtailsearch # Wagtail 5
./manage.sh collectstatic --no-input --clear --link
./manage.sh edrn_data_disclaimer
./manage.sh edrndevreset

# Add additional upgrade steps here:
Expand Down

0 comments on commit 4ed8aa3

Please sign in to comment.