diff --git a/src/auth_and_perms/api/serializers.py b/src/auth_and_perms/api/serializers.py index 0048eb96..9fbf44b8 100644 --- a/src/auth_and_perms/api/serializers.py +++ b/src/auth_and_perms/api/serializers.py @@ -426,7 +426,7 @@ def validate(self, data): if user_delete.username == "soporte@organilab.org" or user_delete == user_session: logger.debug( f'ValidateDeleteUserSerializer --> user_delete.username == ' - f'"soporte@organilab.org') + f'"soporte@organilab.org or user_delete == user_session') raise serializers.ValidationError({'user_delete': _("User delete invalid")}) return data diff --git a/src/auth_and_perms/management/commands/check_remove_user_notlogin.py b/src/auth_and_perms/management/commands/check_remove_user_notlogin.py index 4e215dfd..8f9cbf13 100644 --- a/src/auth_and_perms/management/commands/check_remove_user_notlogin.py +++ b/src/auth_and_perms/management/commands/check_remove_user_notlogin.py @@ -26,7 +26,7 @@ def enqueue_users(self): DeleteUserList.objects.bulk_create(deletelist) for obj in deletelist: - send_email_delete_user_warning(obj.user, "30", "working days") + send_email_delete_user_warning(obj.user, 30, template_name="user_delete_warning_thirty_days") print("Actual: ", User.objects.all().count()) print("Remove: ", len(deletelist)) diff --git a/src/auth_and_perms/tasks.py b/src/auth_and_perms/tasks.py index 562e9a6d..b4f88dac 100644 --- a/src/auth_and_perms/tasks.py +++ b/src/auth_and_perms/tasks.py @@ -1,14 +1,12 @@ from __future__ import absolute_import, unicode_literals import importlib -from django.utils.translation import gettext_lazy as _ + from django.conf import settings from django.db.models import ExpressionWrapper, Q, F, BooleanField -from dateutil.relativedelta import relativedelta -from django.utils.timezone import now + from auth_and_perms.models import DeleteUserList -from auth_and_perms.users import send_email_delete_user_warning, \ - warning_notification_delete_user +from auth_and_perms.users import warning_notification_delete_user app = importlib.import_module(settings.CELERY_MODULE).app @@ -21,6 +19,6 @@ def update_delete_users_list(): @app.task() def send_notification_warning_delete_user(): - warning_notification_delete_user("8", "working days") - warning_notification_delete_user("1", "working day") + warning_notification_delete_user(8) + warning_notification_delete_user(1) diff --git a/src/auth_and_perms/templates/auth_and_perms/mail/en/user_delete_notification.html b/src/auth_and_perms/templates/auth_and_perms/mail/en/user_delete_notification.html index 88ac52e4..1e9663b7 100644 --- a/src/auth_and_perms/templates/auth_and_perms/mail/en/user_delete_notification.html +++ b/src/auth_and_perms/templates/auth_and_perms/mail/en/user_delete_notification.html @@ -1,22 +1,20 @@ {% extends 'gentelella/registration/email_base.html' %} {% load i18n %} {% block content %} -{% trans 'Dear' %} {{user_delete.get_full_name}}, -

- {% trans 'We would like to inform you that the user' %} {{user_delete.username}} {% trans 'was deleted. The reasons for this delete are as follows:' %} -

- 1) {% trans 'Account inactive for a long time.' %} -
- 2) {% trans 'System purification.' %} -

- {% trans 'This measure has been taken to optimize our resources, ensure more efficient management, and enhance the security of our services.' %} - {% endif %} -

- {% trans 'If you have any questions or require further assistance, please do not hesitate to contact our support team. We will be glad to assist you.' %} -

- {% trans 'Sincerely,' %} -

- Organilab -

- +Dear {{user.get_full_name|default_if_none:user.username}}, +

+We inform you that your account {{user.username}} has been deleted. The reason for deletion is: +

+According to the policies of Organilab platform usage, accounts that have been inactive on the organilab.org website for more than 12 months are automatically deleted. +

+

+To regain access to our services, you will have to create a new user. +

+Important: if your user is an organization administrator, deleting your account could also delete the organization, if there is no other administrator user within the organization. +

+If you have any questions or require further assistance, please don't hesitate to contact our support team. We will be glad to assist you. We appreciate your understanding and value your trust in our services, and we strive to provide you with an optimal experience. +

+Sincerely, +

+Organilab {% endblock %} diff --git a/src/auth_and_perms/templates/auth_and_perms/mail/en/user_delete_warning.html b/src/auth_and_perms/templates/auth_and_perms/mail/en/user_delete_warning.html index c5d20b01..f48dd609 100644 --- a/src/auth_and_perms/templates/auth_and_perms/mail/en/user_delete_warning.html +++ b/src/auth_and_perms/templates/auth_and_perms/mail/en/user_delete_warning.html @@ -2,4 +2,20 @@ {% load i18n %} {% block content %} {% trans 'Dear' %} {{user.get_full_name|default_if_none:user.username}}, +

+This is a reminder that, according to the policies of the Organilab platform, accounts that have been inactive on the +organilab.org website for more than 12 months are automatically deleted. This reminder message is to inform you that you +have {{days}} calendar {% if days > 1 %}days{% else %}day{% endif %} from this date to log in to the platform and +continue accessing it with your current user. After this time, you will have to create a new user to access. +

+Important: if your user is an organization administrator, deleting your account could also delete the organization, if +there is no other administrator user within the organization. +

+If you have any questions or require further assistance, please don't hesitate to contact our support team. We will be +glad to assist you. We appreciate your understanding and value your trust in our services, and we strive to provide you +with an optimal experience. +

+Sincerely, +

+Organilab {% endblock %} diff --git a/src/auth_and_perms/templates/auth_and_perms/mail/en/user_delete_warning_thirty_days.html b/src/auth_and_perms/templates/auth_and_perms/mail/en/user_delete_warning_thirty_days.html new file mode 100644 index 00000000..e05dada4 --- /dev/null +++ b/src/auth_and_perms/templates/auth_and_perms/mail/en/user_delete_warning_thirty_days.html @@ -0,0 +1,21 @@ +{% extends 'gentelella/registration/email_base.html' %} +{% load i18n %} +{% block content %} +{% trans 'Dear' %} {{user.get_full_name|default_if_none:user.username}}, +

+We are writing to inform you that, according to the policies of Organilab platform usage, accounts that have been +inactive on the organilab.org website for more than 12 months are automatically deleted. This message is to inform you +that you have 30 calendar days from this date to log in to the platform and continue accessing it with your current +user. After the 30 days, you will have to create a new user to access. + +Important: if your user is an organization administrator, deleting your account could also delete the organization, if +there is no other administrator user within the organization. + +If you have any questions or require further assistance, please don't hesitate to contact our support team. We will be +glad to assist you. We appreciate your understanding and value your trust in our services, and we strive to provide you +with an optimal experience. +

+Sincerely, +

+Organilab +{% endblock %} diff --git a/src/auth_and_perms/templates/auth_and_perms/mail/en/user_merge_notification.html b/src/auth_and_perms/templates/auth_and_perms/mail/en/user_merge_notification.html index 3efcc90b..92382541 100644 --- a/src/auth_and_perms/templates/auth_and_perms/mail/en/user_merge_notification.html +++ b/src/auth_and_perms/templates/auth_and_perms/mail/en/user_merge_notification.html @@ -1,15 +1,30 @@ {% extends 'gentelella/registration/email_base.html' %} {% load i18n %} {% block content %} -{% trans 'Dear' %} {{user_base.get_full_name}}, -

- {% trans 'We would like to inform you that an update has been made to your account information. The reason for this update is as follows:' %} -

- {% trans 'Account consolidation by an administrator: An administrator from your organization has decided to consolidate the accounts that belong to you in order to centralize access. This action aims to simplify account management and provide you with a smoother experience when accessing our resources.' %} -

- {% trans 'From now on, you can log in to your account using the following username:' %} {{user_base.username}} -

- {% trans 'If you do not remember your password, you can use the following link to recover it:' %} {% trans 'Click here' %} -

- {% trans 'We appreciate your understanding and cooperation during this account update process. We value your trust in our services and strive to provide you with an optimal experience.' %} +Dear {{user.get_full_name|default_if_none:user.username}}, +

+We would like to inform you that your account information has been updated. The reasons for this update are due to the detection of one of the following cases: +

+It has been detected that you have registered twice in the system with the same username, but in accounts associated with two different email addresses. +

+A second account has been created with the same email address when accepting an invitation to join an organization or external laboratory. +

+For security reasons in data handling and service quality, the following decisions have been made according to the internal protocol for user management. +

+

+1) User deletion and information transfer: It has been decided to remove a specific user and transfer their information to your account. This measure has been taken to optimize our resources, ensure more efficient management, and enhance the security of our services. +

+2) Account consolidation by an administrator: An administrator from your organization has decided to consolidate the accounts that belong to you in order to centralize access. This action aims to simplify account management and provide you with a smoother experience when accessing our resources. +

+From now on, you can log in to your account using the following username: {{user.username}} +

+If you don't remember your password, you can use the following link to recover it: Click here +

+If you have any questions or require further assistance, please don't hesitate to contact our support team. We will be glad to assist you. +

+We appreciate your understanding and cooperation during this account update process. We value your trust in our services and strive to provide you with an optimal experience. +

+Sincerely, +

+Organilab {% endblock content %} diff --git a/src/auth_and_perms/templates/auth_and_perms/mail/es/user_delete_notification.html b/src/auth_and_perms/templates/auth_and_perms/mail/es/user_delete_notification.html index 64379ce2..c65b64ff 100644 --- a/src/auth_and_perms/templates/auth_and_perms/mail/es/user_delete_notification.html +++ b/src/auth_and_perms/templates/auth_and_perms/mail/es/user_delete_notification.html @@ -1,7 +1,20 @@ {% extends 'gentelella/registration/email_base.html' %} {% load i18n %} {% block content %} -Esto es un adiós {{user}}. - -No olvides apoyar a Organilab. +Estimado/a {{user.get_full_name|default_if_none:user.username}}, +

+Le informamos que se ha borrado la cuenta {{user.username}}. Las razones de la eliminacion se debe a: +

+Por políticas de uso seguro de la plataforma Organilab, se establece por protocolo, que las cuentas con más de 12 meses sin actividad en el sitio web organilab.org, son borradas automáticamente. +

+

+Para poder acceder de nuevo a nuestros servicios debe confeccionar un nuevo usuario. +

+Importante: si su usuario es administrador de organización, el borrado de su cuenta podria eliminar la organización, si no se cuenta con otro usuario administrador dentro de la organización. +

+Si tiene alguna pregunta o necesita asistencia adicional, no dude en ponerse en contacto con nuestro equipo de soporte. Estaremos encantados de ayudarlo. Agradecemos su comprensión y valoramos su confianza en nuestros servicios y nos esforzamos por brindarle una experiencia óptima. +

+Atentamente, +

+Organilab {% endblock %} diff --git a/src/auth_and_perms/templates/auth_and_perms/mail/es/user_delete_warning.html b/src/auth_and_perms/templates/auth_and_perms/mail/es/user_delete_warning.html index f6e4984e..78cf910a 100644 --- a/src/auth_and_perms/templates/auth_and_perms/mail/es/user_delete_warning.html +++ b/src/auth_and_perms/templates/auth_and_perms/mail/es/user_delete_warning.html @@ -3,10 +3,20 @@ {% block content %} Estimado/a {{user.get_full_name|default_if_none:user.username}},

- -Por este medio le hacemos saber que usted cuenta con un año de inactividad en nuestra plataforma Organilab y -cuenta con {{available_time}} para volver a ingresar antes de que su usuario sea eliminado. - +Le recordamos que por políticas de uso de la plataforma Organilab, se establece por protocolo, que las cuentas con más +de 12 meses sin actividad en el sitio web organilab.org, son borradas automáticamente. Este mensaje de recordatorio de +vencimiento es para informar que cuenta con {{days}} {% if days > 1 %}días{% else %}día{% endif %} calendario a partir +de esta fecha, para ingresar a la plataforma y continuar accediendo desde su usuario actual. Pasado este tiempo tendrá +que confeccionar otro usuario para poder acceder.

-En caso de que no recuerde su contraseña, puede utilizar el siguiente enlace para recuperarla: Clic aquí +Importante: si su usuario es administrador de organización, el borrado de su cuenta podria eliminar la organización, si +no se cuenta con otro usuario administrador dentro de la organización. +

+Si tiene alguna pregunta o necesita asistencia adicional, no dude en ponerse en contacto con nuestro equipo de soporte. +Estaremos encantados de ayudarlo. Agradecemos su comprensión y valoramos su confianza en nuestros servicios y nos +esforzamos por brindarle una experiencia óptima. +

+Atentamente, +

+Organilab {% endblock %} diff --git a/src/auth_and_perms/templates/auth_and_perms/mail/es/user_delete_warning_thirty_days.html b/src/auth_and_perms/templates/auth_and_perms/mail/es/user_delete_warning_thirty_days.html new file mode 100644 index 00000000..2ab4d6ef --- /dev/null +++ b/src/auth_and_perms/templates/auth_and_perms/mail/es/user_delete_warning_thirty_days.html @@ -0,0 +1,21 @@ +{% extends 'gentelella/registration/email_base.html' %} +{% load i18n %} +{% block content %} +Estimado/a {{user.get_full_name|default_if_none:user.username}}, +

+Le informamos que por políticas de uso de la plataforma Organilab, se establece por protocolo, que las cuentas con más +de 12 meses sin actividad en el sitio web organilab.org, son borradas automáticamente. Este mensaje es para informar +que cuenta con 30 días calendario a partir de esta fecha, para ingresar a la plataforma y continuar accediendo desde su +usuario actual. Pasado los 30 días tendrá que confeccionar otro usuario para poder acceder. +

+Importante: si su usuario es administrador de organización, el borrado de su cuenta podria eliminar la organización, si +no se cuenta con otro usuario administrador dentro de la organización. +

+Si tiene alguna pregunta o necesita asistencia adicional, no dude en ponerse en contacto con nuestro equipo de soporte. +Estaremos encantados de ayudarlo. Agradecemos su comprensión y valoramos su confianza en nuestros servicios y nos +esforzamos por brindarle una experiencia óptima. +

+Atentamente, +

+Organilab +{% endblock %} diff --git a/src/auth_and_perms/templates/auth_and_perms/mail/es/user_merge_notification.html b/src/auth_and_perms/templates/auth_and_perms/mail/es/user_merge_notification.html index c65484e1..68535890 100644 --- a/src/auth_and_perms/templates/auth_and_perms/mail/es/user_merge_notification.html +++ b/src/auth_and_perms/templates/auth_and_perms/mail/es/user_merge_notification.html @@ -1,5 +1,30 @@ {% extends 'gentelella/registration/email_base.html' %} {% load i18n %} {% block content %} -Su usuario ha sido mezclado. +Estimado/a {{user.get_full_name|default_if_none:user.username}}, +

+Le informamos que se ha realizado una actualización de la información de su cuenta. Las razones de esta actualización se deben a que se ha detectado alguno de los siguientes casos: +

+Registrarse dos veces en el sistema con el mismo nombre de usuario pero en cuentas asociadas con dos correos electrónicos diferentes. +

+Que se haya creado una segunda cuenta con la misma dirección de correo, al aceptar la invitación a formar parte de una organización o laboratorio externo a su organización. +

+Por motivos de seguridad en el manejo de datos y calidad en el servicio se han tomado las siguientes decisiones de acuerdo con el protocolo interno de manejo de usuarios. +

+

+1) Eliminación de usuario y transferencia de información: Se ha decidido eliminar a un usuario específico y transferir su información a su cuenta. Esta medida se ha tomado con el objetivo de optimizar nuestros recursos y garantizar una gestión más eficiente, así como mejorar la seguridad de nuestros servicios. +

+2) Unificación de cuentas por parte de un administrador: Un administrador de su organización ha decidido unificar las cuentas que le pertenecen con el fin de centralizar el acceso. Esta acción tiene como objetivo simplificar la administración de cuentas y proporcionarle una experiencia más fluida al acceder a nuestros recursos. +

+A partir de este momento, podrá acceder a su cuenta utilizando el siguiente nombre de usuario: {{user.username}} +

+En caso de que no recuerde su contraseña, puede utilizar el siguiente enlace para recuperarla: Clic aquí +

+Si tiene alguna pregunta o necesita asistencia adicional, no dude en ponerse en contacto con nuestro equipo de soporte. Estaremos encantados de ayudarlo. +

+Agradecemos su comprensión y cooperación durante este proceso de actualización de cuenta. Valoramos su confianza en nuestros servicios y nos esforzamos por brindarle una experiencia óptima. +

+Atentamente, +

+Organilab {% endblock %} diff --git a/src/auth_and_perms/users.py b/src/auth_and_perms/users.py index 3adc41f9..cb516ee2 100644 --- a/src/auth_and_perms/users.py +++ b/src/auth_and_perms/users.py @@ -54,19 +54,19 @@ def send_delete_user_email(user_delete): ) activate(oldlang) -def send_email_delete_user_warning(user_delete, days, msg): +def send_email_delete_user_warning(user_delete, days, template_name="user_delete_warning"): if hasattr(user_delete, 'profile'): lang = user_delete.profile.language oldlang = get_language() context = {'lang': lang, 'user': user_delete} activate(lang) - context.update({"available_time": "%s %s" % (str(days), _(msg))}) + context.update({"days": int(days)}) send_mail(subject=_("Delete User Notification"), message=_(""), recipient_list=[user_delete.email], from_email=settings.DEFAULT_FROM_EMAIL, html_message=render_to_string( - "auth_and_perms/mail/"+lang+"/user_delete_warning.html", + "auth_and_perms/mail/"+lang+"/"+template_name+".html", context=context ) ) @@ -109,9 +109,9 @@ def user_management(request, user_base, user_delete, action): delete_user(user_delete, user_base) -def warning_notification_delete_user(days, msg): +def warning_notification_delete_user(days): working_days_date = now() + relativedelta(days=days) queryset = DeleteUserList.objects.filter(expiration_date=working_days_date) for obj in queryset: - send_email_delete_user_warning(obj.user, days, msg) + send_email_delete_user_warning(obj.user, days)