Skip to content

Commit

Permalink
Support #348
Browse files Browse the repository at this point in the history
  • Loading branch information
nutjob4life committed Mar 14, 2024
1 parent 8eedd0e commit c13eaea
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.10 on 2024-03-14 16:46

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("ekeknowledge", "0017_protocol_estimated_finish_date_protocol_start_date"),
]

operations = [
migrations.AddField(
model_name="protocol",
name="outcome",
field=models.TextField(
blank=True, help_text="What this protocol's net result was"
),
),
migrations.AddField(
model_name="protocol",
name="secure_outcome",
field=models.TextField(
blank=True, help_text="What this protocol's secret net result was"
),
),
]
16 changes: 16 additions & 0 deletions src/eke.knowledge/src/eke/knowledge/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def compute_new_value(self, modelField: Field, value: str, predicates: dict) ->
rdflib.URIRef('http://edrn.nci.nih.gov/rdf/schema.rdf#objective'),
rdflib.URIRef('http://edrn.nci.nih.gov/rdf/schema.rdf#aims'),
rdflib.URIRef('http://edrn.nci.nih.gov/rdf/schema.rdf#outcome'),
rdflib.URIRef('http://edrn.nci.nih.gov/rdf/schema.rdf#secureOutcome')
):
text = predicates.get(pred, [''])[0]
if text:
Expand Down Expand Up @@ -113,6 +114,8 @@ class Protocol(KnowledgeObject):
# 🤬 Get bent # collaborativeGroupsDeNormalized = models.CharField(max_length=400, blank=True, null=False, help_text='🙄')
collaborativeGroup = models.CharField(max_length=400, blank=True, null=False, help_text='Collaborative Group')
kind = models.CharField(max_length=80, blank=True, null=False, help_text='Protocol type')
outcome = models.TextField(null=False, blank=True, help_text="What this protocol's net result was")
secure_outcome = models.TextField(null=False, blank=True, help_text="What this protocol's secret net result was")
content_panels = KnowledgeObject.content_panels + [
FieldPanel('coordinatingInvestigatorSite'),
FieldPanel('leadInvestigatorSite'),
Expand All @@ -132,6 +135,8 @@ class Protocol(KnowledgeObject):
FieldPanel('collaborativeGroup'),
FieldPanel('kind'),
FieldPanel('publications'),
FieldPanel('outcome'),
FieldPanel('secure_outcome')
]
search_fields = KnowledgeObject.search_fields + [
index.SearchField('abbreviation'),
Expand All @@ -140,6 +145,8 @@ class Protocol(KnowledgeObject):
index.FilterField('piName'),
index.FilterField('collaborativeGroup'),
index.FilterField('cancer_types'),
index.FilterField('outcome'),
index.FilterField('secure_outcome'),
]
class Meta:
pass
Expand All @@ -164,14 +171,18 @@ class RDFMeta:
_internalIDPredicate: RDFAttribute('protocolID', scalar=True),
str(rdflib.DCTERMS.title): RDFAttribute('title', scalar=True),
str(rdflib.DCTERMS.description): _ComplexDescriptionRDFAttribute('description', scalar=True),
esu('outcome'): _ComplexDescriptionRDFAttribute('outcome', scalar=True),
esu('secureOutcome'): _ComplexDescriptionRDFAttribute('secure_outcome', scalar=True),
esu('protocolType'): RDFAttribute('kind', scalar=True)
}

def _authentication(self, request: HttpRequest) -> dict:
'''Given a request, determine if the user is authenticated and what the login link would be if not.'''
params = {'authenticated': request.user.is_authenticated}
if not params['authenticated']:
params['login'] = reverse('wagtailcore_login') + '?next=' + request.path
return params

def get_context(self, request: HttpRequest, *args, **kwargs) -> dict:
'''Get the context for the page template.'''
context = super().get_context(request, args, kwargs)
Expand All @@ -192,7 +203,12 @@ def get_context(self, request: HttpRequest, *args, **kwargs) -> dict:
context['biomarkers'] = bms
context['cancer_types'] = [i for i in self.cancer_types.all().order_by('title').values_list('title', flat=True)]
context['publications'] = [i for i in self.publications.order_by(Lower('title'))]

# Show the new secure outcome only for logged in users
context['show_secure_outcome'] = request and request.user.is_authenticated

return context

def data_table(self) -> dict:
if self.leadInvestigatorSite:
if self.leadInvestigatorSite.pi:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ <h3>Comments</h3>
<p>{{page.comments|safe}}</p>
{% endif %}

{% if page.outcome %}
<h3>Outcome</h3>
<p>{{page.outcome|safe}}</p>
{% endif %}

{% if page.secure_outcome and show_secure_outcome %}
<h3>Secure Outcome</h3>
<p>{{page.secure_outcome|safe}}</p>
{% endif %}

<h2>Publications</h2>
<ul>
{% for publication in publications %}
Expand Down

0 comments on commit c13eaea

Please sign in to comment.