set password in welcome script
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.core.mail import EmailMessage
|
||||
from django.template.loader import render_to_string
|
||||
from core import utils
|
||||
|
||||
from core.models import CustomUser
|
||||
|
||||
@@ -11,9 +12,16 @@ class Command(BaseCommand):
|
||||
managers = CustomUser.objects.filter(role='COOP_MANAGER')
|
||||
|
||||
for manager in managers:
|
||||
try:
|
||||
password = utils.generate_password(12)
|
||||
manager.set_password(password)
|
||||
manager.save()
|
||||
except:
|
||||
return Response({'error': f"Could not set new password [{str(type(e))}]: {str(e)}"}, status=500)
|
||||
link = "https://latienda.coop/login"
|
||||
company_message = render_to_string('welcome_coop.html', {
|
||||
'manager': manager,
|
||||
'password': password,
|
||||
'link': link
|
||||
})
|
||||
# send email to company
|
||||
|
||||
@@ -486,14 +486,23 @@
|
||||
>
|
||||
Hola {{ manager.full_name }},
|
||||
<br /><br />
|
||||
Te has registrado en latienda.coop. Puedes entrar en este enlace:
|
||||
Te has registrado en latienda.coop.
|
||||
y estas son tus credenciales de acceso:
|
||||
<br>
|
||||
<br>
|
||||
username: {{manager.email}} <br>
|
||||
password: {{password}}
|
||||
<br>
|
||||
<br>
|
||||
Puedes entrar en este enlace:
|
||||
<br/>
|
||||
<a href="{{link}}">{{link}}</a>
|
||||
<br />
|
||||
<br>
|
||||
Te esperamos por latienda.coop para que actualices y añadas más productos.
|
||||
<br />
|
||||
<br />
|
||||
Un abrazo
|
||||
Un abrazo.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user