Skip to content

Commit

Permalink
Convert licenses to HTML and force user to read
Browse files Browse the repository at this point in the history
  • Loading branch information
neoformit committed Aug 31, 2023
1 parent 241108c commit 157d27b
Show file tree
Hide file tree
Showing 8 changed files with 2,117 additions and 90 deletions.
15 changes: 14 additions & 1 deletion webapp/home/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from django import forms
from django.conf import settings
from django.core.exceptions import ValidationError
from django.template.loader import render_to_string
from django.core.mail import EmailMultiAlternatives
from django.template.loader import render_to_string
from django.templatetags.static import static
from utils import galaxy
from utils import postal
from utils.data.fgenesh import genematrix_tree
Expand Down Expand Up @@ -395,6 +396,12 @@ class FgeneshRequestForm(BaseAccessRequestForm):
research_topics = forms.CharField(max_length=200, required=False)
matrices = forms.MultipleChoiceField(choices=genematrix_tree.as_choices())

terms = {
'button_text': 'View terms',
'src': static('home/documents/fgenesh-biocommons-terms.html'),
'agreement_name': 'FGENESH++ Service Terms of Use and Policies',
}

def render_matrix_field(self):
return genematrix_tree.as_ul()

Expand All @@ -419,6 +426,12 @@ class CellRangerRequestForm(BaseAccessRequestForm):
agree_terms = forms.BooleanField()
agree_usage = forms.BooleanField()

terms = {
'button_text': 'View license agreement',
'src': static('home/documents/cellranger-end-user-license.html'),
'agreement_name': 'CellRanger End User Licence Agreement',
}


ACCESS_FORMS = {
'alphafold': AlphafoldRequestForm,
Expand Down
758 changes: 758 additions & 0 deletions webapp/home/static/home/documents/cellranger-end-user-license.html

Large diffs are not rendered by default.

Binary file not shown.
1,229 changes: 1,229 additions & 0 deletions webapp/home/static/home/documents/fgenesh-biocommons-terms.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions webapp/home/static/home/js/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ $(document).ready(scrollToErrors);
function scrollToErrors() {
const errors = $('.errorlist');
if (errors.length) {
const top = errors.offset().top;
$('html, body').animate({scrollTop: top - 80}, 500);
const scrollTo = errors.offset().top - 150;
$('html, body').animate({scrollTop: scrollTo}, 500);
}
}

Expand Down
18 changes: 4 additions & 14 deletions webapp/home/templates/home/requests/access/cellranger.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,9 @@ <h2> Galaxy Australia CellRanger Access Request </h2>
</a>
must be read and acknowledged prior to access being provisioned.
</p>
{{ form.agree_terms.errors }}
<button type="button" class="ga-btn" onclick="showAcceptLicense(this);">
I have read the license agreement
</button>
<div class="form-check mt-2" style="display: none;">
<input
class="form-check-input"
id="termsInput"
name="agree_terms"
type="checkbox"
{% if form.agree_terms.value %}checked{% endif %}
/>
<label for="termsInput" class="form-check-label">I accept the terms of the license agreement</label>
</div>

{% include 'home/requests/access/snippets/agree-terms-modal.html' %}

</div>

<div class="col-sm-12">
Expand All @@ -96,6 +85,7 @@ <h2> Galaxy Australia CellRanger Access Request </h2>
id="usageInput"
name="agree_usage"
type="checkbox"
required
{% if form.agree_usage.value %}checked{% endif %}
/>
<label for="usageInput" class="form-check-label">I agree to only use CellRanger for academic or non-commercial research purposes</label>
Expand Down
75 changes: 2 additions & 73 deletions webapp/home/templates/home/requests/access/fgenesh.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,63 +132,9 @@ <h3 class="mb-3">Select matrices</h3>
The FGENESH++ Terms of Use and Acknowledgement Statement
are required to be acknowledged prior to access.
</p>
<button
class="ga-btn"
type="button"
data-bs-toggle="modal"
data-bs-target="#termsModal"
>
View Terms of Use
</button>
<div class="form-check mt-2" style="visibility: hidden;">
{{ form.agree_terms.errors }}
<input
class="form-check-input"
id="agreeTermsInput"
name="agree_terms"
type="checkbox"
required
{% if form.agree_terms.value %}checked{% endif %}
/>
<label for="agreeTermsInput" class="check-label">
I, the Principal Investigator or End User have read and acknowledged
the FGENESH++ Service Terms of Use and Policies.
</label>
</div>

<div class="modal" tabindex="-1" id="termsModal">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<iframe
src="{% static 'home/documents/fgenesh-biocommons-terms.pdf' %}"
style="width: 100%; height: calc(80vh - 100px);"
frameborder="0"
></iframe>
</div>
<div class="modal-footer justify-content-center">
<div class="w-100">
<p class="text-center">
I, the Principal Investigator or End User have read and acknowledged
the FGENESH++ Service Terms of Use and Policies.
</p>
</div>
<button
type="button"
class="btn btn-primary"
data-bs-dismiss="modal"
onclick="agreeTermsAction(this);"
>
Agree
</button>
</div>
</div>
</div>
</div>
{% include 'home/requests/access/snippets/agree-terms-modal.html' %}

</div>

<hr>
Expand Down Expand Up @@ -257,23 +203,6 @@ <h5 class="modal-title"></h5>
{% block script %}
<script src="{% static 'home/js/tree-list.js' %}"></script>
<script src="{% static 'home/js/forms.js' %}"></script>
<script type="text/javascript">
$('form').submit( (e) => {
showTermsInput();
$('button[type="submit"]').prop('disabled', true);
$('button[type="submit"]').html('<i class="fas fa-sync-alt fa-spin"></i>');
return true;
});

function agreeTermsAction(el) {
showTermsInput();
$('#agreeTermsInput').attr('checked', true);
}

const showTermsInput = () => $('#termsModal')
.siblings('.form-check')
.css('visibility', 'visible');
</script>
{% endblock %}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{% load static %}

{{ form.agree_terms.errors }}

<button
class="ga-btn"
type="button"
data-bs-toggle="modal"
data-bs-target="#termsModal"
>
{{ form.terms.button_text }}
</button>

<div class="form-check mt-2">
<input
class="form-check-input"
id="agreeTermsInput"
name="agree_terms"
type="checkbox"
disabled
{% if form.agree_terms.value %}checked{% endif %}
/>
<label id="agreeTermsLabel" for="agreeTermsInput" class="check-label" style="opacity: 0.2;">
I, the Principal Investigator or End User have read and acknowledged
the {{ form.terms.agreement_name }}.
</label>
</div>

<div class="modal" tabindex="-1" id="termsModal">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<iframe
src="{{ form.terms.src }}"
style="width: 100%; height: calc(95vh - 240px);"
frameborder="0"
></iframe>
</div>
<div class="modal-footer justify-content-center">
<div class="w-100">
<p class="text-center">
I, the Principal Investigator or End User have read and acknowledged
the {{ form.terms.agreement_name }}.
</p>
</div>
<div
title="Please scroll to the end to accept"
data-bs-toggle="tooltip"
data-bs-placement="right"
>
<button
type="button"
class="btn btn-primary"
id="agreeTermsButton"
data-bs-dismiss="modal"
onclick=""
disabled
>
Agree
</button>
</div>
</div>
</div>
</div>

<script>
function agreeTermsAction(el) {
enableTermsInput();
$('#agreeTermsInput').attr('checked', true);
}
function enableTermsInput() {
$('#agreeTermsInput').attr('disabled', false);
$('#agreeTermsLabel').css('opacity', '1');
}

function enableAgreeTermsButton() {
$('#agreeTermsButton').attr('disabled', false);
$('#agreeTermsButton').attr('onclick', 'agreeTermsAction(this);');
const tooltip = new bootstrap.Tooltip($('#agreeTermsButton').closest('div')[0]);
tooltip.disable();
}

function setEventHandler() {
const termsContainer = $('#termsModal iframe').contents().find('#page-container');
if (!termsContainer.length) {
return setTimeout(setEventHandler, 100);
}
termsContainer.on('scroll', (event) => {
const scrolledToEnd = $(event.target)[0].scrollHeight
- $(event.target).scrollTop()
- $('#termsModal iframe').height() < 50;
scrolledToEnd && enableAgreeTermsButton();
});
}

$('#termsModal iframe').contents().ready(setEventHandler);

// Enable terms checkbox so validation messages can be displayed
$('form').submit( () => {
enableTermsInput();
return true;
});
</script>
</div>

0 comments on commit 157d27b

Please sign in to comment.