|
|
|
@ -9,6 +9,7 @@ from django.utils.html import format_html |
|
|
|
import csv |
|
|
|
import csv |
|
|
|
import io |
|
|
|
import io |
|
|
|
import time |
|
|
|
import time |
|
|
|
|
|
|
|
import logging |
|
|
|
|
|
|
|
|
|
|
|
from .models import Entity, Prospect, Activity, Status, ActivityType, EmailTemplate |
|
|
|
from .models import Entity, Prospect, Activity, Status, ActivityType, EmailTemplate |
|
|
|
from .forms import FileImportForm, EmailTemplateSelectionForm |
|
|
|
from .forms import FileImportForm, EmailTemplateSelectionForm |
|
|
|
@ -20,6 +21,8 @@ from sync.admin import SyncedObjectAdmin |
|
|
|
|
|
|
|
|
|
|
|
User = get_user_model() |
|
|
|
User = get_user_model() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Entity) |
|
|
|
@admin.register(Entity) |
|
|
|
class EntityAdmin(SyncedObjectAdmin): |
|
|
|
class EntityAdmin(SyncedObjectAdmin): |
|
|
|
list_display = ('name', 'address', 'zip_code', 'city') |
|
|
|
list_display = ('name', 'address', 'zip_code', 'city') |
|
|
|
@ -324,6 +327,8 @@ class ProspectAdmin(SyncedObjectAdmin): |
|
|
|
|
|
|
|
|
|
|
|
def send_email(self, request, queryset): |
|
|
|
def send_email(self, request, queryset): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.info('send_email to prospects form initiated...') |
|
|
|
|
|
|
|
|
|
|
|
if 'apply' in request.POST: |
|
|
|
if 'apply' in request.POST: |
|
|
|
form = EmailTemplateSelectionForm(request.POST) |
|
|
|
form = EmailTemplateSelectionForm(request.POST) |
|
|
|
if form.is_valid(): |
|
|
|
if form.is_valid(): |
|
|
|
@ -349,6 +354,8 @@ class ProspectAdmin(SyncedObjectAdmin): |
|
|
|
error_emails = [] |
|
|
|
error_emails = [] |
|
|
|
all_emails = [] |
|
|
|
all_emails = [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.info(f'Sending email to {queryset.count()} users...') |
|
|
|
|
|
|
|
|
|
|
|
for prospect in queryset: |
|
|
|
for prospect in queryset: |
|
|
|
mail_body = email_template.body.replace('{{name}}', prospect.first_name) |
|
|
|
mail_body = email_template.body.replace('{{name}}', prospect.first_name) |
|
|
|
all_emails.append(prospect.email) |
|
|
|
all_emails.append(prospect.email) |
|
|
|
|