Skip to content

Commit

Permalink
#166 - added new admin email field and email confirmation sending whe…
Browse files Browse the repository at this point in the history
…n new user is created
  • Loading branch information
jbc25 committed May 30, 2024
1 parent 893b762 commit 13c42a3
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 0 deletions.
10 changes: 10 additions & 0 deletions authentication/models/preregister.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ def send_email(self):

self.email_sent = True
self.save()

# Admin confirmation email
send_template_email(
title=_('Nueva usuaria creada en la app'),
destination=self.account.node.admin_email,
template_name='admin_preregister_confirm_msg',
template_params={
'user': self.user,
'account': self.account }
)
except Exception as e:
print(e)

Expand Down
18 changes: 18 additions & 0 deletions core/migrations/0012_node_admin_email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0 on 2024-05-30 09:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0011_node_add_takahe_invite_url'),
]

operations = [
migrations.AddField(
model_name='node',
name='admin_email',
field=models.EmailField(blank=True, help_text='Para mensajes de la herramienta', max_length=200, null=True, verbose_name='Email de administración'),
),
]
1 change: 1 addition & 0 deletions core/models/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Node(models.Model):
longitude = models.FloatField(null=False, verbose_name=_('Longitud'), default=0)

contact_email = models.EmailField(null=True, blank=True, max_length=200, verbose_name=_('Email de contacto'))
admin_email = models.EmailField(null=True, blank=True, max_length=200, verbose_name=_('Email de administración'), help_text=_('Para mensajes de la herramienta'))
self_register_allowed = models.BooleanField(default=False, verbose_name=_('Permitir el registro abierto'))
register_provider_url = models.TextField(blank=True, null=True, verbose_name=_('Enlace al formulario de registro de proveedoras'))
register_consumer_url = models.TextField(blank=True, null=True, verbose_name=_('Enlace al formulario de registro de consumidoras'))
Expand Down
11 changes: 11 additions & 0 deletions templates/email/admin_preregister_confirm_msg.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% load settings_value %}

<h2>Nueva usuaria registrada en la app.</h2>

<p>
{% if account %}
Se ha creado correctamente un usuario en la app para {{account.display_name}} y se le ha enviado el email de bienvenida a {{account.email}}
{% else %}
Se ha creado correctamente un usuario en la app para {{user.email}} (Sin cuenta de miembro asociada) y se le ha enviado el email de bienvenida.
{% endif %}
</p>
9 changes: 9 additions & 0 deletions templates/email/admin_preregister_confirm_msg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% load settings_value %}

Nueva usuaria registrada en la app.

{% if account %}
Se ha creado correctamente un usuario en la app para {{account.display_name}} y se le ha enviado el email de bienvenida a {{account.email}}
{% else %}
Se ha creado correctamente un usuario en la app para {{user.email}} (Sin cuenta de miembro asociada) y se le ha enviado el email de bienvenida.
{% endif %}
1 change: 1 addition & 0 deletions templates/market/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ <h4 class="card-title"><i class="material-icons">edit_location</i> {% translate
{% include "common/forms/field.html" with field=form.info_page_url %}

{% include "common/forms/field.html" with field=form.contact_email %}
{% include "common/forms/field.html" with field=form.admin_email %}

<label class="mt-3 mb-2">{% translate 'Logo del mercado (preferiblemente PNG con transparencia)' %}</label>
<div class="card form-photo mb-3">
Expand Down

0 comments on commit 13c42a3

Please sign in to comment.