From 273632d68aee5f928e9b8271a4d6326e4716ee2e Mon Sep 17 00:00:00 2001 From: CJ Green <44074998+okaycj@users.noreply.github.com> Date: Mon, 28 Aug 2023 10:50:42 -0400 Subject: [PATCH] Study Details Configuration Views (#1244) * Add js2py package for js validation * html format changes * Experiment runner config url * Update study edit forms * Add exp runner edit button to detail view * Add runner config edit html * Update css * Move study type field to drop down * Add external runner config * Remove study type mixin * populate latest commit sha * Get other field form data * Fix field names, add style to forms * Add preview link to study details, fix view names * Rename study views There are two view named "Study details". The original view is renamed to "Study" and all urls have been updated. Additionally, Clicking save on Study Ad moves you to the new Study Details view. * Add header text to Study Ad * Update version of djlint I updated the version of djlint as it was causing me to have to re-format text on each commit. * Move study type field to bottom of form. * Update preview summary help text * Update study type field label and help text. * Update study type name field In addition to updating the study type field, I am removing the configuration field. Forms have replaced the need for this field. * Add header copy to study details * Update rep url help text * Update study create workflow * Disable study type on study edit form * Clean up study views * Fix Study type name issues * Update Scheduled field to be choice field * Update tests * Add runner view tests * Fix issue with Scheduling Other field There was a small bug with other field on the external details view. The other box wouldn't show up when other was selected * Add test for after effects for updating metadata * Change study ad link icon * Remove language from modal that doesn't make sense * Fix cancel button on study details * Cancel button goes to study view * Add rebuilt/rejected warning to study details * Generator field will always have default code * Fixed commit url * Add help text to commit sha field * Added formatted link to help text * Fix db migration conflict * Copy changes * Update warning message on study details * Update copy on study type --- .pre-commit-config.yaml | 2 +- accounts/templates/accounts/2fa-setup.html | 14 +- .../templates/accounts/account-update.html | 94 ++--- .../accounts/participant_detail.html | 110 ++---- .../templates/accounts/participant_list.html | 8 +- .../accounts/researcher-registration.html | 8 +- ...otify_researcher_of_study_permissions.html | 2 +- ...notify_researcher_of_study_permissions.txt | 2 +- accounts/tests/test_accounts.py | 2 +- exp/templates/exp/_navigation.html | 8 +- exp/tests/test_runner_forms.py | 118 +++++++ exp/tests/test_runner_views.py | 153 +++++++++ exp/tests/test_study_forms.py | 112 ------ exp/tests/test_study_views.py | 179 +--------- exp/urls.py | 20 +- exp/views/mixins.py | 100 +----- exp/views/responses.py | 2 +- exp/views/study.py | 320 ++++++++++++------ poetry.lock | 57 +++- pyproject.toml | 1 + scss/study-fields.scss | 18 +- studies/forms.py | 278 +++++++++------ .../0093_remove_studytype_configuration.py | 54 +++ studies/models.py | 14 +- studies/tasks.py | 4 +- .../emails/notify_admins_of_study_action.html | 10 +- .../emails/notify_admins_of_study_action.txt | 10 +- ...tify_researchers_of_approval_decision.html | 2 +- ...otify_researchers_of_approval_decision.txt | 2 +- .../notify_researchers_of_build_failure.html | 2 +- .../notify_researchers_of_build_failure.txt | 2 +- .../notify_researchers_of_deployment.html | 2 +- .../notify_researchers_of_deployment.txt | 2 +- .../studies/_all_json_and_csv_data.html | 4 +- studies/templates/studies/_data_options.html | 2 +- studies/templates/studies/_image_display.html | 4 +- studies/templates/studies/_study_fields.html | 51 +-- studies/templates/studies/_study_type.html | 100 ------ .../studies/experiment_runner/base.html | 59 ++++ .../studies/experiment_runner/efp_edit.html | 72 ++++ .../experiment_runner/external_edit.html | 17 + studies/templates/studies/lab_create.html | 6 +- studies/templates/studies/lab_list.html | 18 +- .../templates/studies/lab_member_list.html | 58 ++-- studies/templates/studies/lab_update.html | 8 +- .../templates/studies/options/recipients.html | 4 +- .../templates/studies/study_attachments.html | 8 +- .../{study_form.html => study_create.html} | 11 +- studies/templates/studies/study_detail.html | 16 +- .../study_detail/_manage_researchers.html | 22 +- .../studies/study_detail/_modal.html | 4 +- .../studies/study_detail/_study_logs.html | 4 +- .../studies/study_detail/_study_status.html | 6 +- studies/templates/studies/study_edit.html | 134 ++++---- studies/templates/studies/study_list.html | 10 +- .../studies/study_participant_analytics.html | 194 +++-------- .../studies/study_participant_contact.html | 28 +- .../templates/studies/study_responses.html | 52 +-- .../study_responses_consent_ruling.html | 114 ++----- web/static/custom_bootstrap5.css | 6 +- web/static/js/ace-editor.js | 8 + web/static/js/efp-runner.js | 143 ++++++++ web/static/js/external-runner.js | 53 +++ web/static/js/study-edit.js | 25 +- web/static/js/study-fields.js | 165 +-------- web/templates/404.html | 2 +- web/templates/registration/login.html | 38 +-- .../registration/password_change_form.html | 4 +- .../registration/password_reset_confirm.html | 18 +- .../registration/password_reset_form.html | 8 +- web/templates/web/_footer.html | 6 +- web/templates/web/_studies-by-age-group.html | 8 +- web/templates/web/base.html | 18 +- web/templates/web/child-add.html | 10 +- web/templates/web/child-update.html | 14 +- .../web/demographic-data-update.html | 8 +- web/templates/web/faq.html | 92 ++--- web/templates/web/garden/home.html | 6 +- web/templates/web/garden/participate.html | 12 +- web/templates/web/home.html | 10 +- web/templates/web/lab-studies-list.html | 4 +- .../web/participant-email-preferences.html | 10 +- web/templates/web/participant-signup.html | 8 +- web/templates/web/privacy.html | 36 +- web/templates/web/publications.html | 4 +- web/templates/web/resources.html | 3 +- .../web/scientists/staff-alumni.html | 4 +- .../scientists/undergrade-student-alumni.html | 24 +- web/templates/web/studies-history.html | 4 +- web/templates/web/studies-list.html | 2 +- web/templates/web/study-detail.html | 12 +- web/views.py | 20 +- 92 files changed, 1715 insertions(+), 1788 deletions(-) create mode 100644 exp/tests/test_runner_forms.py create mode 100644 exp/tests/test_runner_views.py create mode 100644 studies/migrations/0093_remove_studytype_configuration.py delete mode 100644 studies/templates/studies/_study_type.html create mode 100644 studies/templates/studies/experiment_runner/base.html create mode 100644 studies/templates/studies/experiment_runner/efp_edit.html create mode 100644 studies/templates/studies/experiment_runner/external_edit.html rename studies/templates/studies/{study_form.html => study_create.html} (74%) create mode 100644 web/static/js/ace-editor.js create mode 100644 web/static/js/efp-runner.js create mode 100644 web/static/js/external-runner.js diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1c3cd31ff..4d1350127 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: hooks: - id: black - repo: https://github.com/Riverside-Healthcare/djLint - rev: v1.19.16 + rev: v1.32.1 hooks: - id: djlint-django args: ['--profile', 'django', '--lint', '--reformat', '--quiet'] diff --git a/accounts/templates/accounts/2fa-setup.html b/accounts/templates/accounts/2fa-setup.html index a8a874ef5..4e79c7018 100644 --- a/accounts/templates/accounts/2fa-setup.html +++ b/accounts/templates/accounts/2fa-setup.html @@ -30,15 +30,15 @@
- {{ user.nickname }} has not participated in any studies yet! -
+{{ user.nickname }} has not participated in any studies yet!
{% endif %} {% endblock content %} diff --git a/accounts/templates/accounts/participant_list.html b/accounts/templates/accounts/participant_list.html index a8b14ae22..39652129a 100644 --- a/accounts/templates/accounts/participant_list.html +++ b/accounts/templates/accounts/participant_list.html @@ -16,9 +16,9 @@ placeholder="Filter by nickname or user global ID" size="50" type="text" - value="{{ match }}"/> - - + value="{{ match }}" /> + ++ |
{% if user.nickname %}
{{ user.nickname }}
diff --git a/accounts/templates/accounts/researcher-registration.html b/accounts/templates/accounts/researcher-registration.html
index 55c6e2dd8..1406b8478 100644
--- a/accounts/templates/accounts/researcher-registration.html
+++ b/accounts/templates/accounts/researcher-registration.html
@@ -21,9 +21,9 @@
.
{% form_buttons %}
- {% bootstrap_button bs_icon_plus|add:"Create Account" %}
- {% endform_buttons %}
-
-
+ {% bootstrap_button bs_icon_plus|add:"Create Account" %}
+ {% endform_buttons %}
+
+
{% endblock content %}
diff --git a/accounts/templates/emails/notify_researcher_of_study_permissions.html b/accounts/templates/emails/notify_researcher_of_study_permissions.html
index 1fd0bd31c..f3094b2ef 100644
--- a/accounts/templates/emails/notify_researcher_of_study_permissions.html
+++ b/accounts/templates/emails/notify_researcher_of_study_permissions.html
@@ -1,7 +1,7 @@
Dear {{ researcher_name }}, You have been given {{ permission }} permissions to collaborate on {{ study_name }}. - Here is a link to start collaborating. + Here is a link to start collaborating. Best, diff --git a/accounts/templates/emails/notify_researcher_of_study_permissions.txt b/accounts/templates/emails/notify_researcher_of_study_permissions.txt index 3e9638791..bb371b309 100644 --- a/accounts/templates/emails/notify_researcher_of_study_permissions.txt +++ b/accounts/templates/emails/notify_researcher_of_study_permissions.txt @@ -2,7 +2,7 @@ Dear {{ researcher_name }}, You have been given {{ permission }} permissions to collaborate on {{ study_name }}. -Here is a link to start collaborating: {{ base_url }}{% url 'exp:study-detail' study_id %}. +Here is a link to start collaborating: {{ base_url }}{% url 'exp:study' study_id %}. Best, {{ lab_name }} Admin diff --git a/accounts/tests/test_accounts.py b/accounts/tests/test_accounts.py index 58d06dffc..0dffe071d 100644 --- a/accounts/tests/test_accounts.py +++ b/accounts/tests/test_accounts.py @@ -106,7 +106,7 @@ def setUp(self): reverse("exp:participant-detail", kwargs={"pk": self.participant.pk}), reverse("exp:study-participant-analytics"), reverse("exp:study-create"), - reverse("exp:study-detail", kwargs={"pk": self.study.pk}), + reverse("exp:study", kwargs={"pk": self.study.pk}), reverse("exp:study-participant-contact", kwargs={"pk": self.study.pk}), reverse("exp:study-edit", kwargs={"pk": self.study.pk}), reverse("exp:study-responses-list", kwargs={"pk": self.study.pk}), diff --git a/exp/templates/exp/_navigation.html b/exp/templates/exp/_navigation.html index 7b7351de6..84bc53482 100644 --- a/exp/templates/exp/_navigation.html +++ b/exp/templates/exp/_navigation.html @@ -13,9 +13,7 @@ id="navbarDropdown" role="button" data-bs-toggle="dropdown" - aria-expanded="false"> - Help - + aria-expanded="false">Help @@ -123,9 +106,7 @@ title="" id="id_max_age_years"> {% for x, y in form.fields.max_age_years.choices %} - + {% endfor %} @@ -140,10 +121,7 @@ name="max_age_months" title=""> {% for x, y in form.fields.max_age_months.choices %} - + {% endfor %} @@ -158,9 +136,7 @@ name="max_age_days" title=""> {% for x, y in form.fields.max_age_days.choices %} - + {% endfor %} @@ -181,17 +157,4 @@ {% bootstrap_field form.must_not_have_participated label_class="form-label fw-bold" wrapper_class="mb-4" %} {% bootstrap_field form.criteria_expression label_class="form-label fw-bold" wrapper_class="mb-4" %}-
-
-
-
-
-- Now it's time for the actual study! For internal studies, you will add a protocol configuration or generator. For external studies, you will paste in your study or scheduling link. If you don't see what you expect, check the "External" and "Scheduled" checkboxes at the top of this form! - -{% bootstrap_field form.structure label_class="form-label fw-bold" %}
-{% bootstrap_field form.use_generator label_class="form-label" wrapper_class="form-group" %}
-{{ form.generator.help_text|safe }}
-
- {% bootstrap_field form.generator show_help=False label_class="form-label fw-bold" %}
-
+{% bootstrap_field form.study_type label_class="form-label fw-bold" wrapper_class="mb-4" %}
diff --git a/studies/templates/studies/_study_type.html b/studies/templates/studies/_study_type.html
deleted file mode 100644
index ad9919e5a..000000000
--- a/studies/templates/studies/_study_type.html
+++ /dev/null
@@ -1,100 +0,0 @@
-{% load exp_extras %}
-{% load web_extras %}
-{% load django_bootstrap5 %}
-{% load bootstrap_icons %}
-{% load static %}
-{% button_secondary_classes as btn_secondary_classes %}
-
-
-
diff --git a/studies/templates/studies/experiment_runner/base.html b/studies/templates/studies/experiment_runner/base.html
new file mode 100644
index 000000000..a9d4a0fdc
--- /dev/null
+++ b/studies/templates/studies/experiment_runner/base.html
@@ -0,0 +1,59 @@
+{% extends "exp/base.html" %}
+{% load django_bootstrap5 %}
+{% load bootstrap_icons %}
+{% load web_extras %}
+{% load static %}
+{% block title %}
+ Edit | {{ study.name }}
+{% endblock title %}
+{% block breadcrumb %}
+ {% breadcrumb %}
+ {% url 'exp:study-list' %} Manage Studies
+ {% url 'exp:study' pk=study.id %} {{ study.name }}
+ Edit
+{% endbreadcrumb %}
+{% endblock breadcrumb %}
+{% block content %}
+ {% url 'exp:study' pk=study.pk as url_study_detail %}
+ {% button_secondary_classes as btn_secondary_classes %}
+ {% button_primary_classes as btn_primary_classes %}
+ {% url 'exp:preview-detail' uuid=study.uuid as url_preview_detail %}
+ {% bs_icon "play-circle" as bs_icon_play_circle %}
+ {% bootstrap_form_errors form %}
+
-
-
- {% for study_type in study_types %}
-
-
- {% for field in study_type.configuration.metadata.fields %}
- {% with field.name as key %}
- {% with field.value as value %}
- {% with key_help_text|get_key:key|default:"" as help_text %}
- {% if field.input_type == "checkbox" %}
-
- {% endfor %}
-
-
-
-
- {% elif field.input_type == "radio" %}
-
-
- {% for option in field.options %}
-
- {% else %}
-
- {% endif %}
- {% if key == "last_known_player_sha" %}
-
-
-
- {% if option == "Other" %}
- {% if study %}
- {% with "other_"|add:field.name as other_field %}
- {% with study.metadata|get_key:other_field|default:'' as other_value %}
-
- {% endwith %}
- {% endwith %}
- {% else %}
-
- {% endif %}
- {% endif %}
- {% endfor %}
- {{ help_text }}
-
-
-
-
-
-
- About this version
-
- | {{ video.created_at|date:"n/j/Y g:i A"|default:"N/A" }} | Download + class="{% button_primary_classes %} btn-sm">Download |