Skip to content

Commit

Permalink
Bootstrap 5 studies (#1104)
Browse files Browse the repository at this point in the history
* Update django bootstrap to v5

* Update load bootstrap tag

* Moves static HTML to web template directory

* Fix sonarcloud issues

* Changes to the login page to support BS5

* Add bootstrap icons package

* Add title to login view

* Move footer to its own file

* Clean up navigation bar html

* HTML update to home view

* Updates to FAQ accordion

* Updates to the studies list page
  • Loading branch information
okaycj authored Feb 16, 2023
1 parent 6c699ca commit 57f19c1
Show file tree
Hide file tree
Showing 60 changed files with 1,149 additions and 1,144 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ local-certs:
mkcert -install
cd certs && mkcert local_lookit.mit.edu

media:
gsutil -m cp -r "gs://lookit-staging/media" ./project

test:
docker compose run --rm -e ENVIRONMENT= web poetry run ./manage.py test --failfast
2 changes: 1 addition & 1 deletion accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ class StudyLocation(FormChoiceEnum):
study_list_tabs = forms.ChoiceField(
choices=Tabs.choices(),
initial=0,
widget=forms.RadioSelect(attrs={"class": "hidden"}),
widget=forms.RadioSelect(attrs={"class": "d-none"}),
required=False,
)
study_location = forms.ChoiceField(choices=StudyLocation.choices(), required=False)
Expand Down
2 changes: 1 addition & 1 deletion accounts/templates/accounts/2fa-setup.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "web/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% block title %}
Set up Two Factor Authentication
{% endblock title %}
Expand Down
2 changes: 1 addition & 1 deletion accounts/templates/accounts/account-update.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "web/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% block title %}
Update account information
{% endblock title %}
Expand Down
2 changes: 1 addition & 1 deletion accounts/templates/accounts/participant_detail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load exp_extras %}
{% load i18n %}
{% block title %}
Expand Down
2 changes: 1 addition & 1 deletion accounts/templates/accounts/participant_list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load exp_extras %}
{% load i18n %}
{% block title %}
Expand Down
2 changes: 1 addition & 1 deletion accounts/templates/accounts/researcher-registration.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "web/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% block title %}
Researcher Registration
{% endblock title %}
Expand Down
3 changes: 2 additions & 1 deletion exp/templates/exp/base.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load static %}
{% load guardian_tags %}
{% load web_extras %}
Expand Down Expand Up @@ -47,6 +47,7 @@
{% endblock header %}
</header>
<section id="flash-messages">
{% bootstrap_messages %}
{% block flash %}
{% endblock flash %}
</section>
Expand Down
2 changes: 1 addition & 1 deletion exp/templates/exp/support.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load i18n %}
{% block title %}
Support Lookit
Expand Down
30 changes: 23 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"guardian",
"localflavor",
"rest_framework",
"bootstrap3",
"django_bootstrap5",
"django_bootstrap_icons",
"ace_overlay",
"corsheaders",
"rest_framework.authtoken",
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Django = "3.2.11"
django-ace-overlay = { git = "https://github.com/lookit/django-ace-overlay.git", branch = "master" }
django-allauth = "0.42.0"
django-bitfield = "2.1.0"
django-bootstrap3 = "^21.1"
django-bootstrap5 = "22.2"
django-celery-beat = "2.0.0"
django-cors-headers = "3.13.0"
django-countries = "7.2.1"
Expand Down Expand Up @@ -51,6 +51,7 @@ sentry-sdk = "1.3.0"
transitions = "0.8.1"
uWSGI = "2.0.19.1"
pillow = "9.4.0"
django-bootstrap-icons = "0.8.2"

[tool.poetry.dev-dependencies]
coverage = "^5.5"
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/_all_json_and_csv_data.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load exp_extras %}
{% block title %}
All Responses | {{ study.name }}
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/_study_fields.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load bootstrap3 %}
{% load django_bootstrap5 %}
<script>

// Show the generator function field only if use_generator is checked.
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/lab_create.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% block title %}
Create lab
{% endblock title %}
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/lab_detail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% block title %}
{{ lab.name }}
{% endblock title %}
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/lab_list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load exp_extras %}
{% block title %}
Labs
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/lab_member_list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load exp_extras %}
{% block title %}
Lab members
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/lab_update.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% block title %}
Update lab
{% endblock title %}
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/study_attachments.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load exp_extras %}
{% load tz %}
{% block title %}
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/study_detail.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load guardian_tags %}
{% load static %}
{% load tz %}
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/study_edit.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load guardian_tags %}
{% load exp_extras %}
{% block head %}
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/study_form.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% block title %}
Create Study
{% endblock title %}
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/study_list.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load exp_extras %}
{% block title %}
Studies
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/study_participant_analytics.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load static %}
{% load guardian_tags %}
{% block head %}
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/study_participant_contact.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load guardian_tags %}
{% load exp_extras %}
{% load static %}
Expand Down
2 changes: 1 addition & 1 deletion studies/templates/studies/study_responses.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load exp_extras %}
{% load static %}
{% block title %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "exp/base.html" %}
{% load bootstrap3 %}
{% load django_bootstrap5 %}
{% load exp_extras %}
{% load static %}
{% block title %}
Expand Down
44 changes: 44 additions & 0 deletions web/static/js/studies-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const $form = $('form');
const $hideStudiesCheckbox = $form.find('input:checkbox[name=hide_studies_we_have_done]')
const $checkboxes = $form.find('input:checkbox')
const $dropdownSelected = $form.find('select option:selected')

if ($dropdownSelected.val() === '') {
$hideStudiesCheckbox.attr('disabled', true);
}

$form.on('reset', function (event) {
resetForm(submitForm);
})

function resetForm(callbackFn) {
$form.find('input:text').attr('value', '')
$checkboxes.attr('checked', true);
$hideStudiesCheckbox.attr('checked', false)
$dropdownSelected.removeAttr('selected');
callbackFn()
}

function submitForm() {
$checkboxes.attr('disabled', false);
$form.submit()
}

$('select, input:checkbox').on('change', submitForm)

// Set active tab based on which "tabs" radio button is checked.
const checked_radio = document.querySelector('input[name=study_list_tabs]:checked')
const active_tab = document.querySelector(`[data-value="${checked_radio.value}"] a`)
active_tab.classList.add('active')

// On click, update radio group
document.querySelectorAll('[role=study_list_tabs]').forEach(function (tab) {
tab.addEventListener('click', function (event) {
event.preventDefault()
const radio = document.querySelector(`[name="study_list_tabs"][value="${tab.dataset.value}"]`)
if (!radio.hasAttribute('checked')) {
radio.checked = true
submitForm()
}
})
})
86 changes: 0 additions & 86 deletions web/templates/frontpages/default.html

This file was deleted.

Loading

0 comments on commit 57f19c1

Please sign in to comment.