Skip to content

Commit

Permalink
Emails messages updated
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelagz committed May 23, 2024
1 parent 5211a72 commit 4f18f52
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/auth_and_perms/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def validate(self, data):
if user_delete.username == "[email protected]" or user_delete == user_session:
logger.debug(
f'ValidateDeleteUserSerializer --> user_delete.username == '
f'"[email protected]')
f'"[email protected] or user_delete == user_session')
raise serializers.ValidationError({'user_delete': _("User delete invalid")})

return data
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
12 changes: 5 additions & 7 deletions src/auth_and_perms/tasks.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)

Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
{% extends 'gentelella/registration/email_base.html' %}
{% load i18n %}
{% block content %}
{% trans 'Dear' %} {{user_delete.get_full_name}},
<br><br>
{% trans 'We would like to inform you that the user' %} <b>{{user_delete.username}}</b> {% trans 'was deleted. The reasons for this delete are as follows:' %}
<br><br>
1) {% trans 'Account inactive for a long time.' %}
<br>
2) {% trans 'System purification.' %}
<br><br>
{% trans 'This measure has been taken to optimize our resources, ensure more efficient management, and enhance the security of our services.' %}
{% endif %}
<br><br>
{% 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.' %}
<br><br>
{% trans 'Sincerely,' %}
<br><br>
Organilab
</p>

Dear {{user.get_full_name|default_if_none:user.username}},
<br><br>
We inform you that your account {{user.username}} has been deleted. The reason for deletion is:
<br><br>
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.
<br><br>
<br><br>
To regain access to our services, you will have to create a new user.
<br><br>
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.
<br><br>
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.
<br><br>
Sincerely,
<br><br>
Organilab
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,20 @@
{% load i18n %}
{% block content %}
{% trans 'Dear' %} {{user.get_full_name|default_if_none:user.username}},
<br><br>
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.
<br><br>
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.
<br><br>
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.
<br><br>
Sincerely,
<br><br>
Organilab
{% endblock %}
Original file line number Diff line number Diff line change
@@ -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}},
<br><br>
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.
<br><br>
Sincerely,
<br><br>
Organilab
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
{% extends 'gentelella/registration/email_base.html' %}
{% load i18n %}
{% block content %}
{% trans 'Dear' %} {{user_base.get_full_name}},
<br><br>
{% 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:' %}
<br><br>
{% 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.' %}
<br><br>
{% trans 'From now on, you can log in to your account using the following username:' %} {{user_base.username}}
<br><br>
{% trans 'If you do not remember your password, you can use the following link to recover it:' %} <a href="{{domain}}{% url 'password_reset' %}" target="_blank">{% trans 'Click here' %}</a>
<br><br>
{% 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}},
<br><br>
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:
<br><br>
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.
<br><br>
A second account has been created with the same email address when accepting an invitation to join an organization or external laboratory.
<br><br>
For security reasons in data handling and service quality, the following decisions have been made according to the internal protocol for user management.
<br><br>
<br><br>
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.
<br><br>
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.
<br><br>
From now on, you can log in to your account using the following username: {{user.username}}
<br><br>
If you don't remember your password, you can use the following link to recover it: <a href="{{domain}}{% url 'password_reset' %}" target="_blank">Click here</a>
<br><br>
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.
<br><br>
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.
<br><br>
Sincerely,
<br><br>
Organilab
{% endblock content %}
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
{% extends 'gentelella/registration/email_base.html' %}
{% load i18n %}
{% block content %}
Esto es un adiós <strong>{{user}}</strong>.

No olvides apoyar a Organilab.
Estimado/a {{user.get_full_name|default_if_none:user.username}},
<br><br>
Le informamos que se ha borrado la cuenta {{user.username}}. Las razones de la eliminacion se debe a:
<br><br>
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.
<br><br>
<br><br>
Para poder acceder de nuevo a nuestros servicios debe confeccionar un nuevo usuario.
<br><br>
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.
<br><br>
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.
<br><br>
Atentamente,
<br><br>
Organilab
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@
{% block content %}
Estimado/a {{user.get_full_name|default_if_none:user.username}},
<br><br>

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.
<br><br>
En caso de que no recuerde su contraseña, puede utilizar el siguiente enlace para recuperarla: <a href="{{domain}}{% url 'password_reset' %}" target="_blank">Clic aquí</a>
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.
<br><br>
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.
<br><br>
Atentamente,
<br><br>
Organilab
{% endblock %}
Original file line number Diff line number Diff line change
@@ -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}},
<br><br>
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.
<br><br>
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.
<br><br>
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.
<br><br>
Atentamente,
<br><br>
Organilab
{% endblock %}
Original file line number Diff line number Diff line change
@@ -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}},
<br><br>
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:
<br><br>
Registrarse dos veces en el sistema con el mismo nombre de usuario pero en cuentas asociadas con dos correos electrónicos diferentes.
<br><br>
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.
<br><br>
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.
<br><br>
<br><br>
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.
<br><br>
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.
<br><br>
A partir de este momento, podrá acceder a su cuenta utilizando el siguiente nombre de usuario: {{user.username}}
<br><br>
En caso de que no recuerde su contraseña, puede utilizar el siguiente enlace para recuperarla: <a href="{{domain}}{% url 'password_reset' %}" target="_blank">Clic aquí</a>
<br><br>
Si tiene alguna pregunta o necesita asistencia adicional, no dude en ponerse en contacto con nuestro equipo de soporte. Estaremos encantados de ayudarlo.
<br><br>
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.
<br><br>
Atentamente,
<br><br>
Organilab
{% endblock %}
10 changes: 5 additions & 5 deletions src/auth_and_perms/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
Expand Down Expand Up @@ -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)

0 comments on commit 4f18f52

Please sign in to comment.