Skip to content

Commit

Permalink
Support #284
Browse files Browse the repository at this point in the history
  • Loading branch information
nutjob4life committed Sep 14, 2023
1 parent ab1d4ec commit eb7b7cc
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.9 on 2023-09-14 17:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('edrnsitecontrols', '0002_informatics_entrez_api_key'),
]

operations = [
migrations.AddField(
model_name='informatics',
name='funding_cycle',
field=models.CharField(default='Ⅴ', help_text='EDRN Funding Cycle', max_length=8),
),
]
4 changes: 3 additions & 1 deletion src/edrnsite.controls/src/edrnsite/controls/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ class Informatics(BaseSiteSetting):
default='https://www.compass.fhcrc.org/enterEDRN/?cl=3&dl=0.9&param1=dmcc&extra_param=plin',
null=False, help_text='URL to the DMCC "secure" site', blank=False
)
funding_cycle = models.CharField(default='Ⅴ', max_length=8, null=False, blank=False, help_text='EDRN Funding Cycle')
panels = [
FieldPanel('in_development'),
FieldPanel('entrez_email'),
FieldPanel('entrez_id'),
FieldPanel('entrez_api_key'),
FieldPanel('dmcc_url')
FieldPanel('dmcc_url'),
FieldPanel('funding_cycle'),
]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

'''🎛 EDRN Site Controls: tags.'''

from ..models import AnalyticsSnippet
from ..models import AnalyticsSnippet, Informatics
from django import template
from django.utils.safestring import mark_safe
from wagtail.models import Site


register = template.Library()
Expand All @@ -13,3 +14,9 @@
@register.simple_tag(takes_context=False)
def edrn_analytics(location: str) -> str:
return mark_safe(''.join(AnalyticsSnippet.objects.filter(location=location).values_list('code', flat=True)))


@register.simple_tag(takes_context=False)
def edrn_funding_cycle() -> str:
informatics = Informatics.for_site(Site.objects.filter(is_default_site=True).first())
return informatics.funding_cycle
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{% extends 'base.html' %}
{% load wagtailcore_tags static knowledge_tags %}

{% block title %}Data Sharing Policies{% endblock title %}
{% block title %}External Data Sharing and Reuse Policy{% endblock title %}

{% block content %}
<div class='row mt-3'>
<div class='col-auto'>
<h1>Data Sharing Policies</h1>
<h1>EDRN External Data Sharing and Reuse Policy Funding Cycle {{funding_cycle}}</h1>
<p>The following shows which sites have data sharing policies and which do not.

<h2>Sites with Data Sharing Policies</h2>
<h2>Sites With Signed Data Sharing Policies</h2>
<p>Number of sites: {{agreed|length}}</p>
<ul class='list-unstyled'>
{% for site in agreed %}
Expand All @@ -19,7 +18,7 @@ <h2>Sites with Data Sharing Policies</h2>
{% endfor %}
</ul>

<h2>Sites without Data Sharing Policies</h2>
<h2>Sites Pending Signed Data Sharing Policies</h2>
<p>Number of sites: {{not_agreed|length}}</p>
<ul class='list-unstyled'>
{% for site in not_agreed %}
Expand Down
24 changes: 19 additions & 5 deletions src/eke.knowledge/src/eke/knowledge/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
'''💁‍♀️ EDRN Knowledge Environment: views.'''

from .knowledge import KnowledgeObject
from .tasks import do_full_ingest, do_reindex, do_ldap_group_sync, do_fix_tree
from .sites import Site, Person
from edrn.auth.views import logged_in_or_basicauth
from django.shortcuts import render
from .tasks import do_full_ingest, do_reindex, do_ldap_group_sync, do_fix_tree
from django.db.models import Q
from django.db.models.functions import Lower
from django.shortcuts import render
from edrn.auth.views import logged_in_or_basicauth
from edrnsite.controls.models import Informatics
from wagtail.models import Site as WagtailSite
from django.http import (
HttpRequest, HttpResponse, HttpResponseRedirect, HttpResponseForbidden, HttpResponseNotFound, HttpResponseBadRequest
)
Expand Down Expand Up @@ -107,8 +109,20 @@ def find_members(request: HttpRequest) -> HttpResponse:

def show_data_sharing_agreements(request: HttpRequest) -> HttpResponse:
'''Data sharing agreements view.'''

informatics = Informatics.for_site(WagtailSite.objects.filter(is_default_site=True).first())

# These are the only sites to consider when it comes to the data sharing agreements
q = Q(memberType__in=[
'Biomarker Characterization Center',
'Biomarker Developmental Laboratories',
'Biomarker Reference Laboratories',
'Clinical Validation Center',
'Data Management and Coordinating Center',
])
rendering = {
'agreed': Site.objects.exclude(dataSharingPolicy='').all().order_by('title'),
'not_agreed': Site.objects.filter(dataSharingPolicy='').all().order_by('title'),
'agreed': Site.objects.filter(q).exclude(dataSharingPolicy='').all().order_by('title'),
'not_agreed': Site.objects.filter(q).filter(dataSharingPolicy='').all().order_by('title'),
'funding_cycle': informatics.funding_cycle
}
return render(request, 'eke.knowledge/data-sharing.html', rendering)

0 comments on commit eb7b7cc

Please sign in to comment.