From af50480e80bd110432dbddc9b5c2af7d5e92e7d3 Mon Sep 17 00:00:00 2001 From: Zachary Trabookis Date: Wed, 22 Feb 2023 23:54:23 -0500 Subject: [PATCH] feat: Make sure that `TermsOfService` modal form doesn't refresh the page. --- lms/static/sass/features/_termsofservice.scss | 9 +++++++-- lms/templates/static_templates/tos.html | 1 + openedx/features/termsofservice/admin.py | 1 + openedx/features/termsofservice/models.py | 6 +++--- .../termsofservice/static/termsofservice/jsx/Modal.jsx | 9 ++++++++- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lms/static/sass/features/_termsofservice.scss b/lms/static/sass/features/_termsofservice.scss index 4302c7df0a4b..3cb46c499294 100644 --- a/lms/static/sass/features/_termsofservice.scss +++ b/lms/static/sass/features/_termsofservice.scss @@ -12,17 +12,22 @@ position:fixed; background: white; width: 80%; - height: 90%; + height: auto; top:50%; left:50%; transform: translate(-50%,-50%); border-radius: 10px; + + form { + margin-bottom: 20px; } +} .scrollable_tos_style { height: 58vh; width: auto; - overflow: scroll; + overflow-x: hidden; + overflow-y: auto; padding: 6px; } diff --git a/lms/templates/static_templates/tos.html b/lms/templates/static_templates/tos.html index 552d6641ad32..cd5918db5d72 100644 --- a/lms/templates/static_templates/tos.html +++ b/lms/templates/static_templates/tos.html @@ -72,6 +72,7 @@
+

Terms of Service

${tos_html}
diff --git a/openedx/features/termsofservice/admin.py b/openedx/features/termsofservice/admin.py index 29a2c0514bfb..ce48ce45e9cb 100644 --- a/openedx/features/termsofservice/admin.py +++ b/openedx/features/termsofservice/admin.py @@ -16,6 +16,7 @@ class TermsOfServiceAcknowledgementAdmin(admin.ModelAdmin): class TermsOfServiceSitesAdmin(admin.ModelAdmin): list_display = ('site', 'curf') + class TermsOfServiceAllSitesAdmin(admin.ModelAdmin): list_display = ('curf',) diff --git a/openedx/features/termsofservice/models.py b/openedx/features/termsofservice/models.py index bdead5701aed..3cf7044ae5e3 100644 --- a/openedx/features/termsofservice/models.py +++ b/openedx/features/termsofservice/models.py @@ -48,11 +48,11 @@ class Meta: # TermsOfServiceAllSites - holds the default site - This model holds only one default object class TermsOfServiceAllSites(models.Model): + """ + Model to assign all sites (platform) to a Terms of Service (Linked curf_id) + """ class Meta: app_label = 'termsofservice' verbose_name = 'TermsOfServiceAllSite' - # id = models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True) curf = models.OneToOneField(TermsOfService, to_field="curf_id", on_delete=models.CASCADE) - - # models.ForeignKey(TermsOfService, primary_key=True, to_field="curf_id", on_delete=models.CASCADE) diff --git a/openedx/features/termsofservice/static/termsofservice/jsx/Modal.jsx b/openedx/features/termsofservice/static/termsofservice/jsx/Modal.jsx index 075e09ec8ead..9213b4cd24bf 100644 --- a/openedx/features/termsofservice/static/termsofservice/jsx/Modal.jsx +++ b/openedx/features/termsofservice/static/termsofservice/jsx/Modal.jsx @@ -36,6 +36,13 @@ class ModalView extends Component { return !this.state.tos_isChecked; } + // Prevent the default form from submitting and refreshing the page that it's included on. + // (e.g. The dashboard page won't refresh after the learner submits the form) + // https://stackoverflow.com/questions/28479239/setting-onsubmit-in-react-js + submitTOS (e) { + e.preventDefault(); + } + retrievePage() { $.get('/termsofservice/v1/current_tos/') .then(data => { @@ -105,7 +112,7 @@ class ModalView extends Component {
-
+