diff --git a/core/management/commands/sendWelcome.py b/core/management/commands/sendWelcome.py new file mode 100644 index 0000000..7c65d7e --- /dev/null +++ b/core/management/commands/sendWelcome.py @@ -0,0 +1,25 @@ +from django.core.management.base import BaseCommand +from django.core.mail import EmailMessage +from django.template.loader import render_to_string + +from core.models import CustomUser + +class Command(BaseCommand): + def handle(self, *args, **kwargs): + print("Send welcome email to coop managers\n") + + managers = CustomUser.objects.filter(role='COOP_MANAGER') + + for manager in managers: + link = "https://latienda.coop/login" + company_message = render_to_string('welcome_coop.html', { + 'manager': manager, + 'link': link + }) + # send email to company + subject = "Bienvenid@ a LaTienda.COOP" + email = EmailMessage(subject, company_message, to=[manager.email]) + email.content_subtype = "html" + email.send() + + print(f"Messages sent to {len(managers)} coop managers") \ No newline at end of file diff --git a/history/views.py b/history/views.py index e615f9e..1ca0c52 100644 --- a/history/views.py +++ b/history/views.py @@ -2,6 +2,7 @@ from django.shortcuts import render # Create your views here. from rest_framework import viewsets +from rest_framework.permissions import IsAuthenticated from history.models import HistorySync from history.serializers import HistorySyncLogSerializer @@ -11,7 +12,7 @@ from back_latienda.permissions import IsStaff class HistorySyncViewSet(viewsets.ModelViewSet): queryset = HistorySync.objects.all() serializer_class = HistorySyncLogSerializer - permission_classes = [IsStaff,] + permission_classes = [IsAuthenticated,] def perform_create(self, serializer): serializer.save(creator=self.request.user) diff --git a/products/utils.py b/products/utils.py index 58af693..b0af604 100644 --- a/products/utils.py +++ b/products/utils.py @@ -257,6 +257,7 @@ def product_loader(csv_reader, user, company=None): 'identifiers': row['identificadores'], 'active': True, 'history': history, + 'source': 'IMPORTED', 'creator': user, # 'valid': True } diff --git a/templates/welcome_coop.html b/templates/welcome_coop.html new file mode 100644 index 0000000..b118980 --- /dev/null +++ b/templates/welcome_coop.html @@ -0,0 +1,682 @@ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + +
+ + + + + + +
+ + + +
+
+
+ +
+
+ +
+ + + + + + +
+ +
+ + + + +
+
+ Bienvenid@ a LaTienda.COOP +
+
+
+ +
+
+ +
+ + + + + + +
+ +
+ + + + + + + + +
+ + + + + + +
+
+

+ Hola {{ manager.full_name }}, +

+ Te has registrado en latienda.coop. Puedes entrar en este enlace: +
+ {{link}} +
+ Te esperamos por latienda.coop para que actualices y añadas más productos. +
+
+ Un abrazo +

+
+
+ +
+
+ +
+ + + + + + +
+ +
+
+
+ +
+
+ + +
+ + + + +
+
+ 2021 La Tienda.coop +
+
+
+ + + + + +
+ + + +