diff --git a/invenio_config_tuw/tasks.py b/invenio_config_tuw/tasks.py index 713623641bddd1aff8b8a404bee4e50cb02c1afc..ff9cb47e65160e4fd6a281d5b13663dde39a5eff 100644 --- a/invenio_config_tuw/tasks.py +++ b/invenio_config_tuw/tasks.py @@ -206,13 +206,19 @@ def send_publication_notification_email(recid: str, user_id: Optional[str] = Non user = owner.resolve() html_message = render_template( - "invenio_theme_tuw/mails/record_published.html", + [ + "invenio_theme_tuw/mails/record_published.html", + "mails/record_published.html", + ], uploader=user, record=record, app=current_app, ) message = render_template( - "invenio_theme_tuw/mails/record_published.txt", + [ + "invenio_theme_tuw/mails/record_published.txt", + "mails/record_published.txt", + ], uploader=user, record=record, app=current_app, diff --git a/invenio_config_tuw/users/templates/curation_settings.html b/invenio_config_tuw/users/templates/curation_settings.html new file mode 100644 index 0000000000000000000000000000000000000000..da5a96b6c363f8c62a6729e97e5808e64337082f --- /dev/null +++ b/invenio_config_tuw/users/templates/curation_settings.html @@ -0,0 +1,50 @@ +{#- + Copyright (C) 2025 TU Wien. + + Invenio Config TUW is free software; you can redistribute it and/or modify + it under the terms of the MIT License; see LICENSE file for more details. +#} +{%- extends config.USERPROFILES_SETTINGS_TEMPLATE %} +{%- from "invenio_userprofiles/settings/_macros.html" import render_field, form_errors %} + +{%- block settings_content scoped %} + <section aria-label="{{ _('Curation') }}" class="ui segments"> + <div class="ui segment secondary"> + <i class="file icon" aria-hidden="true"></i> + <strong class="header item">{{ _("Curation") }}</strong> + </div> + <div class="ui segment"> + <form method="POST" name="preferences_curation_form" class="ui form"> + {%- set form = preferences_curation_form %} + {%- for field in form %} + {%- if field.widget.input_type == 'hidden' %} + {{ field() }} + {%- endif %} + {%- endfor %} + + {%- set consent_field = form.consent %} + {%- set consent_given = current_user.preferences.get("curation_consent", False) %} + <div class="field"> + <label for="{{ consent_field.id }}">{{ consent_field.label }}</label> + <p><small>{{ consent_field.description }}</small></p> + + <div class="ui toggle on-off checkbox"> + <input type="checkbox" name="{{ consent_field.id }}" id="{{ consent_field.id }}" {{ "checked" if consent_given else "" }} /> + <label for="{{ consent_field.id }}">Curate my records</label> + </div> + </div> + + <div class="form-actions"> + <a href="." class="ui labeled icon button mt-5"> + <i class="close icon" aria-hidden="true"></i> + {{ _('Cancel') }} + </a> + <button type="submit" name="submit" value="{{ form._prefix }}" class="ui primary labeled icon button mt-5"> + <i class="check icon" aria-hidden="true"></i> + {{ _('Update curation preferences') }} + </button> + </div> + </form> + </div> + </section> +{% endblock %} diff --git a/invenio_config_tuw/users/templates/mails/record_published.html b/invenio_config_tuw/users/templates/mails/record_published.html new file mode 100644 index 0000000000000000000000000000000000000000..f2914dc6f58c28c9bcccf81de753887a4e52070b --- /dev/null +++ b/invenio_config_tuw/users/templates/mails/record_published.html @@ -0,0 +1,30 @@ +{#- + Copyright (C) 2025 TU Wien. + + Invenio Config TUW is free software; you can redistribute it and/or modify + it under the terms of the MIT License; see LICENSE file for more details. +-#} +{%- if record.pids and record.pids.doi %} + {%- set doi = record.pids.doi.identifier %} + {%- set doi_base_url = "https://doi.org/" if not app.config["DATACITE_TEST_MODE"] else "https://handle.test.datacite.org/" %} + {%- set doi_ref = "DOI" if not app.config["DATACITE_TEST_MODE"] else "DOI-like handle" %} + {%- set avail_message = 'It is now available under the following ' + doi_ref + ': <a href="' + doi_base_url + doi + '">' + doi_base_url + doi + '</a>' %} +{%- else %} + {%- set avail_message = 'It is now available under the following URL: <a href="' + record.links.self_html + '">' + record.links.self_html + '</a>' %} +{%- endif %} +<p> + Dear {{ uploader.user_profile.full_name }}, +</p> +<p> + Your record "{{ record.metadata.title }}" just got published! + <br /> + {{ avail_message|safe }} +</p> +<p> + Metadata edits for this record will <em>not</em> require another review. +</p> +<p> + Cheers, + <br /> + The team at the Center for Research Data Management +</p> diff --git a/invenio_config_tuw/users/templates/mails/record_published.txt b/invenio_config_tuw/users/templates/mails/record_published.txt new file mode 100644 index 0000000000000000000000000000000000000000..211355a08d673fbc1b9e9ba3265d340cb27bf62a --- /dev/null +++ b/invenio_config_tuw/users/templates/mails/record_published.txt @@ -0,0 +1,23 @@ +{#- + Copyright (C) 2025 TU Wien. + + Invenio Config TUW is free software; you can redistribute it and/or modify + it under the terms of the MIT License; see LICENSE file for more details. +-#} +{%- if record.pids and record.pids.doi %} + {%- set doi = record.pids.doi.identifier %} + {%- set doi_base_url = "https://doi.org/" if not app.config["DATACITE_TEST_MODE"] else "https://handle.test.datacite.org/" %} + {%- set doi_ref = "DOI" if not app.config["DATACITE_TEST_MODE"] else "DOI-like handle" %} + {%- set avail_message = "It is now available under the following " + doi_ref + ": " + doi_base_url + doi %} +{%- else %} + {%- set avail_message = "It is now available under the following URL: " + record.links.self_html %} +{%- endif %} +Dear {{ uploader.user_profile.full_name }}, + +Your record "{{ record.metadata.title }}" just got published! +{{ avail_message|safe }} + +Metadata edits for this record will *not* require another review. + +Cheers, +The team at the Center for Research Data Management diff --git a/invenio_config_tuw/views.py b/invenio_config_tuw/views.py index b294d22fd7f606ca33b3e0ee9cf9fba765c88ded..e17a6da4fd2d41d3c78c06baff538a2aee771cb9 100644 --- a/invenio_config_tuw/views.py +++ b/invenio_config_tuw/views.py @@ -17,6 +17,7 @@ blueprint = Blueprint( "invenio_config_tuw_settings", __name__, url_prefix="/account/settings/curation", + template_folder="templates", ) @@ -40,6 +41,6 @@ def curation_settings_view(): flash(("Curation settings were updated."), category="success") return render_template( - "invenio_theme_tuw/settings/curation.html", + ["invenio_theme_tuw/settings/curation.html", "curation_settings.html"], preferences_curation_form=preferences_curation_form, )