diff --git a/evap/contributor/templates/contributor_evaluation_form.html b/evap/contributor/templates/contributor_evaluation_form.html index cd7714f428..1c68930638 100644 --- a/evap/contributor/templates/contributor_evaluation_form.html +++ b/evap/contributor/templates/contributor_evaluation_form.html @@ -66,15 +66,17 @@
{% translate 'Course data' %}
{% translate 'Evaluation data' %}
{% if evaluation.allow_editors_to_edit %}
- + {% blocktranslate asvar title with evaluation_name=evaluation.full_name %}Request account creation for {{ evaluation_name }}{% endblocktranslate %} + {% translate 'Please tell us which new account we should create. We need the name and email for all new accounts.' as teaser %} + {% translate 'Request creation of new account' as show_button_text %} + {% include 'contact_modal.html' with modal_id='createParticipantAccountRequestModal' user=request.user title=title teaser=teaser show_button_text=show_button_text show_button_class="btn btn-sm btn-light mb-3" %}
{% else %}
- + {% blocktranslate asvar title with evaluation_name=evaluation.full_name %}Request evaluation changes for {{ evaluation_name }}{% endblocktranslate %} + {% translate 'Please tell us what changes to the evaluation we should make.' as teaser %} + {% translate 'Request changes' as show_button_text %} + {% include 'contact_modal.html' with modal_id='changeEvaluationRequestModal' user=request.user title=title teaser=teaser show_button_text=show_button_text show_button_class="btn btn-sm btn-light" %}
{% endif %} @@ -130,18 +132,6 @@ {% endif %} {% endblock %} -{% block modals %} - {{ block.super }} - - {% blocktranslate asvar title with evaluation_name=evaluation.full_name %}Request account creation for {{ evaluation_name }}{% endblocktranslate %} - {% translate 'Please tell us which new account we should create. We need the name and email for all new accounts.' as teaser %} - {% include 'contact_modal.html' with modal_id='createAccountRequestModal' user=request.user title=title teaser=teaser %} - - {% blocktranslate asvar title with evaluation_name=evaluation.full_name %}Request evaluation changes for {{ evaluation_name }}{% endblocktranslate %} - {% translate 'Please tell us what changes to the evaluation we should make.' as teaser %} - {% include 'contact_modal.html' with modal_id='changeEvaluationRequestModal' user=request.user title=title teaser=teaser %} -{% endblock %} - {% block additional_javascript %} {% include 'evap_evaluation_edit_js.html' %} diff --git a/evap/contributor/tests/test_views.py b/evap/contributor/tests/test_views.py index 4db2451b10..56069a4033 100644 --- a/evap/contributor/tests/test_views.py +++ b/evap/contributor/tests/test_views.py @@ -246,7 +246,7 @@ def test_contact_modal_escape(self): self.evaluation.save() page = self.app.get(self.url, user=self.responsible, status=200) - self.assertIn("changeEvaluationRequestModalLabel", page) + self.assertIn("createContributorAccountRequestModalTitle", page) self.assertNotIn("Adam & Eve", page) self.assertIn("Adam & Eve", page) diff --git a/evap/evaluation/templates/base.html b/evap/evaluation/templates/base.html index c3f18eb0f1..7ed8493571 100644 --- a/evap/evaluation/templates/base.html +++ b/evap/evaluation/templates/base.html @@ -31,11 +31,6 @@ {% include "custom_elements.html" %} {% block modals %} - {% if user.is_authenticated %} - {% translate 'Feedback' as title %} - {% translate 'You are welcome to submit feedback regarding the evaluation platform or specific evaluations. Please let us know how we can improve your experience on EvaP.' as teaser %} - {% include 'contact_modal.html' with modal_id='feedbackModal' user=request.user title=title teaser=teaser %} - {% endif %} {% endblock %}
diff --git a/evap/evaluation/templates/contact_modal.html b/evap/evaluation/templates/contact_modal.html index b0d77ab18c..e58b97a1c0 100644 --- a/evap/evaluation/templates/contact_modal.html +++ b/evap/evaluation/templates/contact_modal.html @@ -1,55 +1,36 @@ {% load static %} - +
diff --git a/evap/evaluation/templates/profile.html b/evap/evaluation/templates/profile.html index 36841bcf66..7f2a692d5a 100644 --- a/evap/evaluation/templates/profile.html +++ b/evap/evaluation/templates/profile.html @@ -69,27 +69,19 @@

{% translate 'Delegates and emails' %}

{% endif %} + -
-
-
-
- - -
-
+
+
+
+ + {% translate 'Request user setting changes' as title %} + {% translate 'Please tell us which of your settings we should change.' as teaser %} + {% translate "Request changes" as show_button_text %} + {% include 'contact_modal.html' with modal_id='requestChangesModal' user=request.user title=title teaser=teaser show_button_text=show_button_text show_button_class="btn btn-light"%}
- -{% endblock %} - -{% block modals %} - {{ block.super }} - {% translate 'Request user setting changes' as title %} - {% translate 'Please tell us which of your settings we should change.' as teaser %} - {% include 'contact_modal.html' with modal_id='changeRequestModal' user=request.user title=title teaser=teaser %} +
{% endblock %} diff --git a/evap/evaluation/tests/test_live.py b/evap/evaluation/tests/test_live.py index e789091268..701f16e317 100644 --- a/evap/evaluation/tests/test_live.py +++ b/evap/evaluation/tests/test_live.py @@ -11,11 +11,11 @@ def test_contact_modal(self) -> None: self.selenium.find_element(By.ID, "feedbackModalShowButton").click() self.wait.until(visibility_of_element_located((By.ID, "feedbackModalMessageText"))) self.selenium.find_element(By.ID, "feedbackModalMessageText").send_keys("Test message") - self.selenium.find_element(By.ID, "feedbackModalActionButton").click() + self.selenium.find_element(By.CSS_SELECTOR, "confirmation-modal > span[slot='action-text']").click() self.wait.until( text_to_be_present_in_element( - (By.CSS_SELECTOR, "#successMessageModal_feedbackModal .modal-body"), + (By.CSS_SELECTOR, ".alert-success"), "Your message was successfully sent.", ) ) diff --git a/evap/evaluation/views.py b/evap/evaluation/views.py index d94eddea23..70cbc71325 100644 --- a/evap/evaluation/views.py +++ b/evap/evaluation/views.py @@ -189,6 +189,7 @@ def contact(request): try: mail.send() logger.info("Sent contact email: \n%s\n", mail.message()) + messages.success(request, _("Your message was successfully sent.")) return HttpResponse() except Exception: logger.exception("An exception occurred when sending the following contact email:\n%s\n", mail.message()) diff --git a/evap/static/ts/src/contact_modal.ts b/evap/static/ts/src/contact_modal.ts deleted file mode 100644 index 287d372459..0000000000 --- a/evap/static/ts/src/contact_modal.ts +++ /dev/null @@ -1,69 +0,0 @@ -declare const bootstrap: typeof import("bootstrap"); - -import { selectOrError, sleep, assert } from "./utils.js"; -import { CSRF_HEADERS } from "./csrf-utils.js"; - -const SUCCESS_MESSAGE_TIMEOUT = 3000; - -export class ContactModalLogic { - private readonly modal: bootstrap.Modal; - private readonly successMessageModal: bootstrap.Modal; - private readonly actionButtonElement: HTMLButtonElement; - private readonly messageTextElement: HTMLInputElement; - private readonly showButtonElements: HTMLElement[]; - private readonly title: string; - - // may be null if anonymous feedback is not enabled - private readonly anonymousRadioElement: HTMLInputElement | null; - - constructor(modalId: string, title: string) { - this.title = title; - this.modal = new bootstrap.Modal(selectOrError("#" + modalId)); - this.successMessageModal = new bootstrap.Modal(selectOrError("#successMessageModal_" + modalId)); - this.actionButtonElement = selectOrError("#" + modalId + "ActionButton"); - this.messageTextElement = selectOrError("#" + modalId + "MessageText"); - this.anonymousRadioElement = document.querySelector("#" + modalId + "AnonymousName"); - this.showButtonElements = Array.from(document.querySelectorAll(`#${modalId}ShowButton, .${modalId}ShowButton`)); - } - - public attach = (): void => { - this.actionButtonElement.addEventListener("click", async event => { - this.actionButtonElement.disabled = true; - event.preventDefault(); - const message = this.messageTextElement.value; - if (message.trim() === "") { - this.modal.hide(); - this.actionButtonElement.disabled = false; - return; - } - try { - const response = await fetch("/contact", { - body: new URLSearchParams({ - anonymous: String(this.anonymousRadioElement?.checked), - message, - title: this.title, - }), - headers: CSRF_HEADERS, - method: "POST", - }); - assert(response.ok); - } catch (_) { - window.alert("Sending failed, sorry!"); - return; - } - this.modal.hide(); - this.successMessageModal.show(); - this.messageTextElement.value = ""; - - await sleep(SUCCESS_MESSAGE_TIMEOUT); - this.successMessageModal.hide(); - this.actionButtonElement.disabled = false; - }); - - this.showButtonElements.forEach(button => - button.addEventListener("click", () => { - this.modal.show(); - }), - ); - }; -}