blocked domain and email filter in sales, elasticsearch related changes (#301)
* updated testcases, update code for account view page, modified code for attachments and comments for assigned user * updated testcases in events, invoices, tasks modules * added duplicate contacts tabs, fixed time format in marketing campaign list page, added test cases in marketing, added contacts list filter in contacts page * updated requirements * added email search using elasticsearch, changes for unsubscribing contacts, added blocked emails, domains in settings pages * added elasticsearch in travis file * blocked domain and email filter in sales, elasticsearch related changes
This commit is contained in:
parent
3696b76ef9
commit
8a0994e79a
27 changed files with 1253 additions and 275 deletions
|
|
@ -4,7 +4,7 @@ Python 3.5.2:
|
|||
- virtualenv -p python3 env
|
||||
- source env/bin/activate
|
||||
- pip install --no-cache-dir -r requirements.txt
|
||||
- python manage.py test --keepdb --noinput
|
||||
- python manage.py test --keepdb --parallel --noinput
|
||||
- coverage run --source=accounts,cases,common,contacts,leads,opportunity,tasks,invoices,events,teams,marketing manage.py test --keepdb --noinput
|
||||
- coverage report -m
|
||||
except:
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ python:
|
|||
services:
|
||||
- elasticsearch
|
||||
- redis-server
|
||||
- elasticsearch
|
||||
|
||||
|
||||
#Django & Database
|
||||
addons:
|
||||
|
|
|
|||
|
|
@ -13,39 +13,43 @@ from accounts.models import Account, Email, EmailLog
|
|||
from common.models import User
|
||||
from common.utils import convert_to_custom_timezone
|
||||
from contacts.models import Contact
|
||||
from marketing.models import BlockedDomain, BlockedEmail
|
||||
|
||||
|
||||
@task
|
||||
def send_email(email_obj_id):
|
||||
email_obj = Email.objects.filter(id=email_obj_id).first()
|
||||
blocked_domains = BlockedDomain.objects.values_list('domain', flat=True)
|
||||
blocked_emails = BlockedEmail.objects.values_list('email', flat=True)
|
||||
if email_obj:
|
||||
from_email = email_obj.from_email
|
||||
contacts = email_obj.recipients.all()
|
||||
for contact_obj in contacts:
|
||||
if not EmailLog.objects.filter(email=email_obj, contact=contact_obj, is_sent=True).exists():
|
||||
html = email_obj.message_body
|
||||
context_data = {
|
||||
'email': contact_obj.email if contact_obj.email else '',
|
||||
'name': contact_obj.first_name if contact_obj.first_name else '' + ' ' + contact_obj.last_name if contact_obj.last_name else '',
|
||||
}
|
||||
try:
|
||||
html_content = Template(html).render(Context(context_data))
|
||||
subject = email_obj.message_subject
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
from_email=from_email,
|
||||
to=[contact_obj.email, ]
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
res = msg.send()
|
||||
if res:
|
||||
email_obj.rendered_message_body = html_content
|
||||
email_obj.save()
|
||||
EmailLog.objects.create(email=email_obj, contact=contact_obj, is_sent=True)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
pass
|
||||
if (contact_obj.email not in blocked_emails) and (contact_obj.email.split('@')[-1] not in blocked_domains):
|
||||
html = email_obj.message_body
|
||||
context_data = {
|
||||
'email': contact_obj.email if contact_obj.email else '',
|
||||
'name': contact_obj.first_name if contact_obj.first_name else '' + ' ' + contact_obj.last_name if contact_obj.last_name else '',
|
||||
}
|
||||
try:
|
||||
html_content = Template(html).render(Context(context_data))
|
||||
subject = email_obj.message_subject
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
from_email=from_email,
|
||||
to=[contact_obj.email, ]
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
res = msg.send()
|
||||
if res:
|
||||
email_obj.rendered_message_body = html_content
|
||||
email_obj.save()
|
||||
EmailLog.objects.create(email=email_obj, contact=contact_obj, is_sent=True)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
|
@ -54,28 +58,33 @@ def send_email_to_assigned_user(recipients, from_email, domain='demo.django-crm.
|
|||
""" Send Mail To Users When they are assigned to a contact """
|
||||
account = Account.objects.filter(id=from_email).first()
|
||||
created_by = account.created_by
|
||||
|
||||
blocked_domains = BlockedDomain.objects.values_list('domain', flat=True)
|
||||
blocked_emails = BlockedEmail.objects.values_list('email', flat=True)
|
||||
|
||||
for user in recipients:
|
||||
recipients_list = []
|
||||
user = User.objects.filter(id=user, is_active=True).first()
|
||||
if user:
|
||||
recipients_list.append(user.email)
|
||||
context = {}
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('accounts:view_account', args=(account.id,))
|
||||
context["user"] = user
|
||||
context["account"] = account
|
||||
context["created_by"] = created_by
|
||||
subject = 'Assigned a account for you.'
|
||||
html_content = render_to_string(
|
||||
'assigned_to/account_assigned.html', context=context)
|
||||
if (user.email not in blocked_emails) and (user.email.split('@')[-1] not in blocked_domains):
|
||||
recipients_list.append(user.email)
|
||||
context = {}
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('accounts:view_account', args=(account.id,))
|
||||
context["user"] = user
|
||||
context["account"] = account
|
||||
context["created_by"] = created_by
|
||||
subject = 'Assigned a account for you.'
|
||||
html_content = render_to_string(
|
||||
'assigned_to/account_assigned.html', context=context)
|
||||
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
to=recipients_list
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
to=recipients_list
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
|
||||
|
||||
@task
|
||||
|
|
@ -92,10 +101,16 @@ def send_scheduled_emails():
|
|||
sent_time = convert_to_custom_timezone(
|
||||
sent_time, each.timezone, to_utc=True)
|
||||
|
||||
# if (
|
||||
# str(each.scheduled_date_time.date()) == str(sent_time.date()) and
|
||||
# str(scheduled_date_time.hour) == str(sent_time.hour) and
|
||||
# (str(scheduled_date_time.minute + 5) < str(sent_time.minute) or
|
||||
# str(scheduled_date_time.minute - 5) > str(sent_time.minute))
|
||||
# ):
|
||||
# send_email.delay(each.id)
|
||||
if (
|
||||
str(each.scheduled_date_time.date()) == str(sent_time.date()) and
|
||||
str(scheduled_date_time.hour) == str(sent_time.hour) and
|
||||
(str(scheduled_date_time.minute + 5) < str(sent_time.minute) or
|
||||
str(scheduled_date_time.minute - 5) > str(sent_time.minute))
|
||||
str(scheduled_date_time.minute) == str(sent_time.minute)
|
||||
):
|
||||
send_email.delay(each.id)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from django.template.loader import render_to_string
|
|||
|
||||
from accounts.models import User
|
||||
from cases.models import Case
|
||||
from marketing.models import BlockedDomain, BlockedEmail
|
||||
|
||||
|
||||
@task
|
||||
|
|
@ -14,25 +15,28 @@ def send_email_to_assigned_user(recipients, case_id, domain='demo.django-crm.io'
|
|||
""" Send Mail To Users When they are assigned to a case """
|
||||
case = Case.objects.get(id=case_id)
|
||||
created_by = case.created_by
|
||||
blocked_domains = BlockedDomain.objects.values_list('domain', flat=True)
|
||||
blocked_emails = BlockedEmail.objects.values_list('email', flat=True)
|
||||
for user in recipients:
|
||||
recipients_list = []
|
||||
user = User.objects.filter(id=user, is_active=True).first()
|
||||
if user:
|
||||
recipients_list.append(user.email)
|
||||
context = {}
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('cases:view_case', args=(case.id,))
|
||||
context["user"] = user
|
||||
context["case"] = case
|
||||
context["created_by"] = created_by
|
||||
subject = 'Assigned to case.'
|
||||
html_content = render_to_string(
|
||||
'assigned_to/cases_assigned.html', context=context)
|
||||
if (user.email not in blocked_emails) and (user.email.split('@')[-1] not in blocked_domains):
|
||||
recipients_list.append(user.email)
|
||||
context = {}
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('cases:view_case', args=(case.id,))
|
||||
context["user"] = user
|
||||
context["case"] = case
|
||||
context["created_by"] = created_by
|
||||
subject = 'Assigned to case.'
|
||||
html_content = render_to_string(
|
||||
'assigned_to/cases_assigned.html', context=context)
|
||||
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
to=recipients_list
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
to=recipients_list
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ from django.contrib.auth.tokens import PasswordResetTokenGenerator
|
|||
from django.core.mail import EmailMessage
|
||||
from django.shortcuts import reverse
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils import six
|
||||
|
||||
from common.models import Comment, User, Profile
|
||||
from django.utils import timezone
|
||||
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
|
||||
from django.utils import six, timezone
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode
|
||||
|
||||
from common.models import Comment, Profile, User
|
||||
from common.token_generator import account_activation_token
|
||||
from marketing.models import BlockedDomain, BlockedEmail
|
||||
|
||||
|
||||
@task
|
||||
|
|
@ -104,19 +104,22 @@ def send_email_user_mentions(comment_id, called_from, domain='demo.django-crm.io
|
|||
else:
|
||||
context["url"] = ''
|
||||
# subject = 'Django CRM : comment '
|
||||
blocked_domains = BlockedDomain.objects.values_list('domain', flat=True)
|
||||
blocked_emails = BlockedEmail.objects.values_list('email', flat=True)
|
||||
if recipients:
|
||||
for recipient in recipients:
|
||||
recipients_list = [recipient, ]
|
||||
context["mentioned_user"] = recipient
|
||||
html_content = render_to_string('comment_email.html', context=context)
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
from_email=comment.commented_by.email,
|
||||
to=recipients_list
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
if (recipient not in blocked_emails) and (recipient.split('@')[-1] not in blocked_domains):
|
||||
recipients_list = [recipient, ]
|
||||
context["mentioned_user"] = recipient
|
||||
html_content = render_to_string('comment_email.html', context=context)
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
from_email=comment.commented_by.email,
|
||||
to=recipients_list
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
|
||||
|
||||
@task
|
||||
|
|
|
|||
|
|
@ -5,32 +5,36 @@ from django.template.loader import render_to_string
|
|||
|
||||
from common.models import User
|
||||
from contacts.models import Contact
|
||||
from marketing.models import BlockedDomain, BlockedEmail
|
||||
|
||||
|
||||
@task
|
||||
def send_email_to_assigned_user(recipients, contact_id, domain='demo.django-crm.io', protocol='http'):
|
||||
""" Send Mail To Users When they are assigned to a contact """
|
||||
contact = Contact.objects.get(id=contact_id)
|
||||
blocked_domains = BlockedDomain.objects.values_list('domain', flat=True)
|
||||
blocked_emails = BlockedEmail.objects.values_list('email', flat=True)
|
||||
created_by = contact.created_by
|
||||
for user in recipients:
|
||||
recipients_list = []
|
||||
user = User.objects.filter(id=user, is_active=True).first()
|
||||
if user:
|
||||
recipients_list.append(user.email)
|
||||
context = {}
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('contacts:view_contact', args=(contact.id,))
|
||||
context["user"] = user
|
||||
context["contact"] = contact
|
||||
context["created_by"] = created_by
|
||||
subject = 'Assigned a contact for you.'
|
||||
html_content = render_to_string(
|
||||
'assigned_to/contact_assigned.html', context=context)
|
||||
if (user.email not in blocked_emails) and (user.email.split('@')[-1] not in blocked_domains):
|
||||
recipients_list.append(user.email)
|
||||
context = {}
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('contacts:view_contact', args=(contact.id,))
|
||||
context["user"] = user
|
||||
context["contact"] = contact
|
||||
context["created_by"] = created_by
|
||||
subject = 'Assigned a contact for you.'
|
||||
html_content = render_to_string(
|
||||
'assigned_to/contact_assigned.html', context=context)
|
||||
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
to=recipients_list
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
to=recipients_list
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ CELERY_BEAT_SCHEDULE = {
|
|||
"task": "marketing.tasks.send_scheduled_campaigns",
|
||||
"schedule": crontab(hour='*/1')
|
||||
},
|
||||
"runs-scheduled-emails-for-accounts-every-five-minutes": {
|
||||
"runs-scheduled-emails-for-accounts-every-one-minute": {
|
||||
"task": "accounts.tasks.send_scheduled_emails",
|
||||
"schedule": crontab(minute='*/1')
|
||||
}
|
||||
|
|
@ -352,3 +352,11 @@ if os.path.isfile('crm/local_settings.py'):
|
|||
from .local_settings import *
|
||||
else:
|
||||
print("No local settings file found")
|
||||
|
||||
|
||||
# CACHES = {
|
||||
# 'default': {
|
||||
# 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
# 'LOCATION': '127.0.0.1:11211',
|
||||
# }
|
||||
# }
|
||||
|
|
@ -7,6 +7,7 @@ from django.template.loader import render_to_string
|
|||
from common.models import User
|
||||
from contacts.models import Contact
|
||||
from events.models import Event
|
||||
from marketing.models import BlockedDomain, BlockedEmail
|
||||
|
||||
|
||||
@task
|
||||
|
|
@ -21,27 +22,45 @@ def send_email(event_id, recipients, domain='demo.django-crm.io', protocol='http
|
|||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('events:detail_view', args=(event.id,))
|
||||
# recipients = event.assigned_to.filter(is_active=True)
|
||||
|
||||
blocked_domains = BlockedDomain.objects.values_list('domain', flat=True)
|
||||
blocked_emails = BlockedEmail.objects.values_list('email', flat=True)
|
||||
for user in recipients:
|
||||
recipients_list = []
|
||||
user = User.objects.filter(id=user, is_active=True).first()
|
||||
if user:
|
||||
recipients_list.append(user.email)
|
||||
event_members = event.assigned_to.filter(is_active=True)
|
||||
if (user.email not in blocked_emails) and (user.email.split('@')[-1] not in blocked_domains):
|
||||
recipients_list.append(user.email)
|
||||
event_members = event.assigned_to.filter(is_active=True)
|
||||
|
||||
context['other_members'] = list(event_members.exclude(
|
||||
id=user.id).values_list('email', flat=True))
|
||||
if len(context['other_members']) > 0:
|
||||
context['other_members'] = ', '.join(context['other_members'])
|
||||
else:
|
||||
context['other_members'] = ''
|
||||
context['user'] = user.email
|
||||
html_content = render_to_string(
|
||||
'assigned_to_email_template_event.html', context=context)
|
||||
msg = EmailMessage(
|
||||
subject=subject, body=html_content, to=recipients_list)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
context['other_members'] = list(event_members.exclude(
|
||||
id=user.id).values_list('email', flat=True))
|
||||
if len(context['other_members']) > 0:
|
||||
context['other_members'] = ', '.join(context['other_members'])
|
||||
else:
|
||||
context['other_members'] = ''
|
||||
context['user'] = user.email
|
||||
html_content = render_to_string(
|
||||
'assigned_to_email_template_event.html', context=context)
|
||||
msg = EmailMessage(
|
||||
subject=subject, body=html_content, to=recipients_list)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
|
||||
# if recipients.count() > 0:
|
||||
# for recipient in recipients:
|
||||
# context['other_members'] = list(recipients.exclude(
|
||||
# id=recipient.id).values_list('email', flat=True))
|
||||
# if len(context['other_members']) > 0:
|
||||
# context['other_members'] = ', '.join(context['other_members'])
|
||||
# else:
|
||||
# context['other_members'] = ''
|
||||
# context['user'] = recipient.email
|
||||
# html_content = render_to_string(
|
||||
# 'assigned_to_email_template_event.html', context=context)
|
||||
# msg = EmailMessage(
|
||||
# subject=subject, body=html_content, to=[recipient.email, ])
|
||||
# msg.content_subtype = "html"
|
||||
# msg.send()
|
||||
|
||||
# if recipients.count() > 0:
|
||||
# for recipient in recipients:
|
||||
|
|
|
|||
|
|
@ -6,32 +6,36 @@ from django.template.loader import render_to_string
|
|||
|
||||
from common.models import User
|
||||
from invoices.models import Invoice, InvoiceHistory
|
||||
from marketing.models import BlockedDomain, BlockedEmail
|
||||
|
||||
|
||||
@task
|
||||
def send_email(invoice_id, recipients, domain='demo.django-crm.io', protocol='http'):
|
||||
invoice = Invoice.objects.filter(id=invoice_id).first()
|
||||
created_by = invoice.created_by
|
||||
blocked_domains = BlockedDomain.objects.values_list('domain', flat=True)
|
||||
blocked_emails = BlockedEmail.objects.values_list('email', flat=True)
|
||||
for user in recipients:
|
||||
recipients_list = []
|
||||
user = User.objects.filter(id=user, is_active=True).first()
|
||||
if user:
|
||||
recipients_list.append(user.email)
|
||||
subject = 'Shared an invoice with you.'
|
||||
context = {}
|
||||
context['invoice_title'] = invoice.invoice_title
|
||||
context['invoice_id'] = invoice_id
|
||||
context['invoice_created_by'] = invoice.created_by
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('invoices:invoice_details', args=(invoice.id,))
|
||||
if (user.email not in blocked_emails) and (user.email.split('@')[-1] not in blocked_domains):
|
||||
recipients_list.append(user.email)
|
||||
subject = 'Shared an invoice with you.'
|
||||
context = {}
|
||||
context['invoice_title'] = invoice.invoice_title
|
||||
context['invoice_id'] = invoice_id
|
||||
context['invoice_created_by'] = invoice.created_by
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('invoices:invoice_details', args=(invoice.id,))
|
||||
|
||||
context['user'] = user
|
||||
html_content = render_to_string(
|
||||
'assigned_to_email_template.html', context=context)
|
||||
msg = EmailMessage(
|
||||
subject=subject, body=html_content, to=recipients_list)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
context['user'] = user
|
||||
html_content = render_to_string(
|
||||
'assigned_to_email_template.html', context=context)
|
||||
msg = EmailMessage(
|
||||
subject=subject, body=html_content, to=recipients_list)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
recipients = invoice.accounts.filter(status='open')
|
||||
if recipients.count() > 0:
|
||||
subject = 'Shared an invoice with you.'
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ from django.template.loader import render_to_string
|
|||
|
||||
from accounts.models import User
|
||||
from leads.models import Lead
|
||||
from marketing.models import BlockedDomain, BlockedEmail
|
||||
|
||||
|
||||
def get_rendered_html(template_name, context={}):
|
||||
|
|
@ -70,28 +71,31 @@ def send_email_to_assigned_user(recipients, lead_id, domain='demo.django-crm.io'
|
|||
""" Send Mail To Users When they are assigned to a lead """
|
||||
lead = Lead.objects.get(id=lead_id)
|
||||
created_by = lead.created_by
|
||||
blocked_domains = BlockedDomain.objects.values_list('domain', flat=True)
|
||||
blocked_emails = BlockedEmail.objects.values_list('email', flat=True)
|
||||
for user in recipients:
|
||||
recipients_list = []
|
||||
user = User.objects.filter(id=user, is_active=True).first()
|
||||
if user:
|
||||
recipients_list.append(user.email)
|
||||
context = {}
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('leads:view_lead', args=(lead.id,))
|
||||
context["user"] = user
|
||||
context["lead"] = lead
|
||||
context["created_by"] = created_by
|
||||
context["source"] = source
|
||||
subject = 'Assigned a lead for you. '
|
||||
html_content = render_to_string(
|
||||
'assigned_to/leads_assigned.html', context=context)
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
to=recipients_list
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
if (user.email not in blocked_emails) and (user.email.split('@')[-1] not in blocked_domains):
|
||||
recipients_list.append(user.email)
|
||||
context = {}
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('leads:view_lead', args=(lead.id,))
|
||||
context["user"] = user
|
||||
context["lead"] = lead
|
||||
context["created_by"] = created_by
|
||||
context["source"] = source
|
||||
subject = 'Assigned a lead for you. '
|
||||
html_content = render_to_string(
|
||||
'assigned_to/leads_assigned.html', context=context)
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
to=recipients_list
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
|
||||
|
||||
@task
|
||||
|
|
@ -112,7 +116,6 @@ def create_lead_from_file(validated_rows, invalid_rows, user_id, source):
|
|||
lead.email = row.get('email')
|
||||
lead.phone = row.get('phone')
|
||||
lead.address_line = row.get('address')
|
||||
lead.source = source
|
||||
# lead.city = row.get('city')
|
||||
# lead.state = row.get('state')
|
||||
# lead.postcode = row.get('postcode')
|
||||
|
|
|
|||
|
|
@ -2,6 +2,12 @@
|
|||
{% load staticfiles %}
|
||||
{% load paginate %}
|
||||
{% load thumbnail %}
|
||||
|
||||
{% block date_picker %}
|
||||
{% endblock date_picker %}
|
||||
|
||||
{% block quill_editor_links %}
|
||||
{% endblock quill_editor_links %}
|
||||
{% block extralinks %}
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
|
||||
<style>
|
||||
|
|
@ -241,8 +247,8 @@
|
|||
<a href="{% url 'leads:edit_lead' lead.id %}" class="btn btn-success edit" title="Edit"><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
{% if request.user == lead.created_by or request.user.role == "ADMIN" or request.user.is_superuser %}
|
||||
<a href="{% url 'leads:remove_lead' lead.id %}"
|
||||
class="btn btn-danger delete remove_account" title="Delete" ><i class="fas fa-trash-alt"></i></a>
|
||||
<a href="{% url 'leads:remove_lead' lead.id %}" class="btn btn-danger delete remove_account"
|
||||
title="Delete"><i class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -352,8 +358,8 @@
|
|||
<a href="{% url 'leads:edit_lead' lead.id %}" class="btn btn-success edit" title="Edit"><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
{% if request.user == lead.created_by or request.user.is_superuser or request.user.role == 'ADMIN' %}
|
||||
<a href="{% url 'leads:remove_lead' lead.id %}"
|
||||
class="btn btn-danger delete remove_account" title="Delete"><i class="fas fa-trash-alt"></i></a>
|
||||
<a href="{% url 'leads:remove_lead' lead.id %}" class="btn btn-danger delete remove_account"
|
||||
title="Delete"><i class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -376,39 +382,11 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{% for lead_record in open_leads %}
|
||||
|
||||
{% comment %}
|
||||
<!-- modal for editing and deleting tags -->
|
||||
|
||||
<div class="modal fade bd-example-modal-lg modal_tags{{lead_record.id}}" tabindex="-1" role="dialog"
|
||||
aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="padding:20px 50px;">
|
||||
<h4><span class="glyphicon glyphicon-lock"></span>Update Tags</h4>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body" style="padding:20px 50px;">
|
||||
<form role="form" id="" method="POST" action="{% url 'leads:update_lead_tags' lead_record.id %}">
|
||||
<div class="form-group">
|
||||
<label>Tags</label>
|
||||
<div class="txt-box-div" id="tag-div"><input type="text" name="tags" id="tags_1"
|
||||
value="{% for t in lead_record.tags.all %}{{t.name}}, {% endfor %}" class="tags tags_1" />
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="full_path" value="{{request.get_full_path}}">
|
||||
<div class="text-center">
|
||||
<button id="" class="btn btn-success">Update</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% for lead_record in open_leads %}
|
||||
|
||||
<!-- modal for editing and deleting tags -->
|
||||
{% endcomment %}
|
||||
|
||||
<div class="modal fade" id="exampleModalCenter_lead{{lead_record.id}}" tabindex="-1" role="dialog"
|
||||
aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
|
||||
|
|
@ -772,6 +750,7 @@
|
|||
</div>
|
||||
|
||||
{% endfor %}
|
||||
{% endcomment %}
|
||||
|
||||
<div class="modal fade" id="uploadleadfile" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
|
||||
aria-hidden="true">
|
||||
|
|
@ -820,10 +799,18 @@
|
|||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js_block %}
|
||||
{% endblock extra_js_block %}
|
||||
|
||||
{% block moment_js_block %}
|
||||
{% endblock moment_js_block %}
|
||||
|
||||
{% block js_block %}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-tagsinput/1.3.6/jquery.tagsinput.min.css" rel="stylesheet">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-tagsinput/1.3.6/jquery.tagsinput.min.js"></script>
|
||||
|
||||
<!-- <link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-tagsinput/1.3.6/jquery.tagsinput.min.css" rel="stylesheet">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-tagsinput/1.3.6/jquery.tagsinput.min.js"></script> -->
|
||||
<script src="{% static 'js/ajaxForm.js' %}"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
|
|
@ -831,8 +818,8 @@
|
|||
$('#id_tag').select2();
|
||||
$('#loading_spinner').hide()
|
||||
$('#spinner_body').hide()
|
||||
$('#tags_1').tagsInput({ width: 'auto' });
|
||||
$('.tags_1').tagsInput({ width: 'auto' });
|
||||
// $('#tags_1').tagsInput({ width: 'auto' });
|
||||
// $('.tags_1').tagsInput({ width: 'auto' });
|
||||
$(".filter_toggle").click(function () {
|
||||
$(".list_filter_row").toggle();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -40,7 +40,8 @@ class LeadListView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateView):
|
|||
template_name = "leads.html"
|
||||
|
||||
def get_queryset(self):
|
||||
queryset = self.model.objects.all().exclude(status='converted')
|
||||
queryset = self.model.objects.all().exclude(status='converted').select_related('created_by').prefetch_related(
|
||||
'tags', 'contacts', 'assigned_to',)
|
||||
if (self.request.user.role != "ADMIN" and not
|
||||
self.request.user.is_superuser):
|
||||
queryset = queryset.filter(
|
||||
|
|
@ -106,7 +107,6 @@ class LeadListView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateView):
|
|||
if self.request.POST.get('tab_status'):
|
||||
tab_status = self.request.POST.get('tab_status')
|
||||
context['tab_status'] = tab_status
|
||||
|
||||
return context
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
|
|
|||
|
|
@ -178,6 +178,10 @@ class FailedContact(models.Model):
|
|||
def __str__(self):
|
||||
return self.email
|
||||
|
||||
@property
|
||||
def created_on_arrow(self):
|
||||
return arrow.get(self.created_on).humanize()
|
||||
|
||||
|
||||
def get_campaign_attachment_path(self, filename):
|
||||
file_split = filename.split('.')
|
||||
|
|
|
|||
|
|
@ -1,26 +1,40 @@
|
|||
from haystack import indexes
|
||||
from marketing.models import Contact
|
||||
from marketing.models import Contact, FailedContact
|
||||
|
||||
|
||||
class MarketingContactIndex(indexes.SearchIndex, indexes.Indexable):
|
||||
text = indexes.CharField(
|
||||
document=True, use_template=True, template_name='search/contact_emails.txt')
|
||||
# title = indexes.CharField(model_attr='title')
|
||||
# authors = indexes.CharField()
|
||||
|
||||
id = indexes.CharField(model_attr='id')
|
||||
email = indexes.CharField(model_attr='email')
|
||||
email_domain = indexes.CharField()
|
||||
name = indexes.CharField(model_attr='name')
|
||||
company_name = indexes.CharField()
|
||||
created_on = indexes.CharField(model_attr='created_on')
|
||||
created_on_arrow = indexes.CharField(model_attr='created_on_arrow')
|
||||
created_by = indexes.CharField()
|
||||
contact_list = indexes.MultiValueField()
|
||||
created_by_id = indexes.CharField()
|
||||
contact_lists = indexes.MultiValueField()
|
||||
contact_lists_id = indexes.MultiValueField()
|
||||
contact_lists_name = indexes.MultiValueField()
|
||||
is_bounced = indexes.BooleanField()
|
||||
contact_lists_count = indexes.IntegerField()
|
||||
|
||||
def get_model(self):
|
||||
return Contact
|
||||
|
||||
def prepare_contact_list(self, obj):
|
||||
return [(contact_list.id, contact_list.name) for contact_list in obj.contact_list.all()]
|
||||
def prepare_email_domain(self, obj):
|
||||
return obj.email.split('@')[-1]
|
||||
|
||||
def prepare_contact_lists(self, obj):
|
||||
return [[contact_list.id, contact_list.name if contact_list.name else ''] for contact_list in obj.contact_list.all()]
|
||||
|
||||
def prepare_contact_lists_id(self, obj):
|
||||
return [contact_list.id for contact_list in obj.contact_list.all().order_by('id')]
|
||||
|
||||
def prepare_contact_lists_name(self, obj):
|
||||
return [contact_list.name for contact_list in obj.contact_list.all().order_by('id')]
|
||||
|
||||
def prepare_company_name(self, obj):
|
||||
return obj.company_name if obj.company_name else ''
|
||||
|
|
@ -28,8 +42,65 @@ class MarketingContactIndex(indexes.SearchIndex, indexes.Indexable):
|
|||
def prepare_created_by(self, obj):
|
||||
return obj.created_by.email if obj.created_by else ''
|
||||
|
||||
# def prepare_contact_id(self, obj):
|
||||
# return obj.id
|
||||
def prepare_created_by_id(self, obj):
|
||||
return obj.created_by.id if obj.created_by else ''
|
||||
|
||||
def prepare_is_bounced(self, obj):
|
||||
return obj.is_bounced
|
||||
|
||||
def prepare_contact_lists_count(self, obj):
|
||||
return obj.contact_list.count()
|
||||
|
||||
def index_queryset(self, using=None):
|
||||
return self.get_model().objects.all()
|
||||
|
||||
|
||||
|
||||
class MarketingFailedContactIndex(indexes.SearchIndex, indexes.Indexable):
|
||||
text = indexes.CharField(
|
||||
document=True, use_template=True, template_name='search/failed_contact_emails.txt')
|
||||
|
||||
id = indexes.CharField(model_attr='id')
|
||||
email = indexes.CharField(model_attr='email')
|
||||
email_domain = indexes.CharField()
|
||||
name = indexes.CharField(model_attr='name')
|
||||
company_name = indexes.CharField()
|
||||
created_on = indexes.CharField(model_attr='created_on')
|
||||
created_on_arrow = indexes.CharField(model_attr='created_on_arrow')
|
||||
created_by = indexes.CharField()
|
||||
created_by_id = indexes.CharField()
|
||||
contact_lists = indexes.MultiValueField()
|
||||
contact_lists_id = indexes.MultiValueField()
|
||||
contact_lists_name = indexes.MultiValueField()
|
||||
contact_lists_count = indexes.IntegerField()
|
||||
|
||||
|
||||
def get_model(self):
|
||||
return FailedContact
|
||||
|
||||
def prepare_email_domain(self, obj):
|
||||
return obj.email.split('@')[-1]
|
||||
|
||||
def prepare_contact_lists(self, obj):
|
||||
return [[contact_list.id, contact_list.name if contact_list.name else ''] for contact_list in obj.contact_list.all()]
|
||||
|
||||
def prepare_contact_lists_id(self, obj):
|
||||
return [contact_list.id for contact_list in obj.contact_list.all().order_by('id')]
|
||||
|
||||
def prepare_contact_lists_name(self, obj):
|
||||
return [contact_list.name for contact_list in obj.contact_list.all().order_by('id')]
|
||||
|
||||
def prepare_company_name(self, obj):
|
||||
return obj.company_name if obj.company_name else ''
|
||||
|
||||
def prepare_created_by(self, obj):
|
||||
return obj.created_by.email if obj.created_by else ''
|
||||
|
||||
def prepare_created_by_id(self, obj):
|
||||
return obj.created_by.id if obj.created_by else ''
|
||||
|
||||
def prepare_contact_lists_count(self, obj):
|
||||
return obj.contact_list.count()
|
||||
|
||||
def index_queryset(self, using=None):
|
||||
return self.get_model().objects.all()
|
||||
|
|
|
|||
|
|
@ -267,51 +267,54 @@ def send_campaign_email_to_admin_contact(campaign, domain='demo.django-crm.io',
|
|||
subject = campaign.subject
|
||||
contacts = ContactEmailCampaign.objects.all()
|
||||
default_html = campaign.html_processed
|
||||
blocked_domains = BlockedDomain.objects.values_list('domain', flat=True)
|
||||
blocked_emails = BlockedEmail.objects.values_list('email', flat=True)
|
||||
for each_contact in contacts:
|
||||
html = default_html
|
||||
if campaign.reply_to_email:
|
||||
reply_to_email = campaign.reply_to_email
|
||||
else:
|
||||
domain_name = 'django-crm.com'
|
||||
if campaign.from_email is not None:
|
||||
from_email = campaign.from_email
|
||||
if ((each_contact.email not in blocked_emails) and (each_contact.email.split('@')[-1] not in blocked_domains)):
|
||||
html = default_html
|
||||
if campaign.reply_to_email:
|
||||
reply_to_email = campaign.reply_to_email
|
||||
else:
|
||||
from_email = campaign.created_by.email
|
||||
reply_to_email = str(from_email) + ' <' + \
|
||||
str(settings.EMAIL_HOST_USER + '@' + domain_name + '') + '>'
|
||||
domain_name = 'django-crm.com'
|
||||
if campaign.from_email is not None:
|
||||
from_email = campaign.from_email
|
||||
else:
|
||||
from_email = campaign.created_by.email
|
||||
reply_to_email = str(from_email) + ' <' + \
|
||||
str(settings.EMAIL_HOST_USER + '@' + domain_name + '') + '>'
|
||||
|
||||
# domain_url = settings.URL_FOR_LINKS
|
||||
domain_url = protocol + '://' + domain
|
||||
# img_src_url = domain_url + reverse('marketing:campaign_open', kwargs={
|
||||
# 'campaign_log_id': campaign_log.id, 'email_id': each_contact.id})
|
||||
# # images can only be accessed over https
|
||||
# link = '<img src={img_src_url} alt="company_logo" title="company_logo" height="1" width="1" />'.format(
|
||||
# img_src_url=img_src_url)
|
||||
# link = '<img src="' + domain_url + '/m/cm/track-email/' + \
|
||||
# str(campaign_log.id) + '/contact/' + \
|
||||
# str(each_contact.id) + '/" height="1" width="1" alt="company_logo" + \
|
||||
# title="company_logo"/>'
|
||||
# domain_url = settings.URL_FOR_LINKS
|
||||
domain_url = protocol + '://' + domain
|
||||
# img_src_url = domain_url + reverse('marketing:campaign_open', kwargs={
|
||||
# 'campaign_log_id': campaign_log.id, 'email_id': each_contact.id})
|
||||
# # images can only be accessed over https
|
||||
# link = '<img src={img_src_url} alt="company_logo" title="company_logo" height="1" width="1" />'.format(
|
||||
# img_src_url=img_src_url)
|
||||
# link = '<img src="' + domain_url + '/m/cm/track-email/' + \
|
||||
# str(campaign_log.id) + '/contact/' + \
|
||||
# str(each_contact.id) + '/" height="1" width="1" alt="company_logo" + \
|
||||
# title="company_logo"/>'
|
||||
|
||||
# unsubscribe_from_campaign_url = reverse(
|
||||
# 'marketing:unsubscribe_from_campaign', kwargs={'contact_id': each_contact.id,
|
||||
# 'campaign_id': campaign.id})
|
||||
# unsubscribe_from_campaign_html = "<br><br/><a href={}>Unsubscribe</a>".format(
|
||||
# domain_url + unsubscribe_from_campaign_url)
|
||||
# unsubscribe_from_campaign_url = reverse(
|
||||
# 'marketing:unsubscribe_from_campaign', kwargs={'contact_id': each_contact.id,
|
||||
# 'campaign_id': campaign.id})
|
||||
# unsubscribe_from_campaign_html = "<br><br/><a href={}>Unsubscribe</a>".format(
|
||||
# domain_url + unsubscribe_from_campaign_url)
|
||||
|
||||
# names_dict = {'company_name': '', 'city': '', 'state': '',
|
||||
# 'last_name': each_contact.last_name if each_contact.last_name else '',
|
||||
# 'email': each_contact.email, 'email_id': each_contact.id,
|
||||
# 'name': each_contact.name + ' ' + each_contact.last_name if each_contact.last_name else '',
|
||||
# }
|
||||
# names_dict = {'company_name': '', 'city': '', 'state': '',
|
||||
# 'last_name': each_contact.last_name if each_contact.last_name else '',
|
||||
# 'email': each_contact.email, 'email_id': each_contact.id,
|
||||
# 'name': each_contact.name + ' ' + each_contact.last_name if each_contact.last_name else '',
|
||||
# }
|
||||
|
||||
# mail_html = html + link + unsubscribe_from_campaign_html
|
||||
html = Template(html).render(Context({'email_id': each_contact.id}))
|
||||
mail_html = html
|
||||
from_email = str(campaign.from_name) + "<" + \
|
||||
str(campaign.from_email) + '>'
|
||||
to_email = [each_contact.email]
|
||||
send_campaign_mail(
|
||||
subject, mail_html, from_email, to_email, [], [reply_to_email], attachments)
|
||||
# mail_html = html + link + unsubscribe_from_campaign_html
|
||||
html = Template(html).render(Context({'email_id': each_contact.id}))
|
||||
mail_html = html
|
||||
from_email = str(campaign.from_name) + "<" + \
|
||||
str(campaign.from_email) + '>'
|
||||
to_email = [each_contact.email]
|
||||
send_campaign_mail(
|
||||
subject, mail_html, from_email, to_email, [], [reply_to_email], attachments)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -4,3 +4,16 @@
|
|||
{{ object.company_name }}
|
||||
{{ object.created_on_arrow }}
|
||||
{{ object.created_on }}
|
||||
{{ object.created_by }}
|
||||
{{ object.created_by_id }}
|
||||
{{ object.email_domain }}
|
||||
{{ object.is_bounced }}
|
||||
{{ object.contact_lists_count }}
|
||||
|
||||
{% for contact_list in object.contact_lists.all %}
|
||||
{{ contact_list.id }}
|
||||
{% endfor %}
|
||||
|
||||
{% for contact_list in object.contact_lists.all %}
|
||||
{{ contact_list.name }}
|
||||
{% endfor %}
|
||||
|
|
|
|||
18
marketing/templates/search/failed_contact_emails.txt
Normal file
18
marketing/templates/search/failed_contact_emails.txt
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{{ object.id }}
|
||||
{{ object.email }}
|
||||
{{ object.name }}
|
||||
{{ object.company_name }}
|
||||
{{ object.created_on_arrow }}
|
||||
{{ object.created_on }}
|
||||
{{ object.created_by }}
|
||||
{{ object.created_by_id }}
|
||||
{{ object.email_domain }}
|
||||
{{ object.contact_lists_count }}
|
||||
|
||||
{% for contact_list in object.contact_lists.all %}
|
||||
{{ contact_list.id }}
|
||||
{% endfor %}
|
||||
|
||||
{% for contact_list in object.contact_lists.all %}
|
||||
{{ contact_list.name }}
|
||||
{% endfor %}
|
||||
666
marketing/templates/search_contact_emails.html
Normal file
666
marketing/templates/search_contact_emails.html
Normal file
|
|
@ -0,0 +1,666 @@
|
|||
{% extends 'marketing/base.html' %}
|
||||
{% load staticfiles %}
|
||||
{% load paginate %}
|
||||
{% block content %}
|
||||
{{ block.super }}
|
||||
<!-- main_container starts here -->
|
||||
<div class="main_container">
|
||||
<!-- heading_create starts here -->
|
||||
<div class="row marl">
|
||||
<div class="col-lg-12 text-right">
|
||||
<span class="d-inline">
|
||||
<a href="{% url 'marketing:contact_list_new' %}" class="primary_btn">Add New Contact List</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_row list_filter_row row marl">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form id="leads_filter" action="" method="POST">
|
||||
<div class="card-body ">
|
||||
<div class="card-title">Filters</div>
|
||||
<div class="row marl">
|
||||
<!-- <div class="filter_col col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Name</label>
|
||||
<input type="text" class="form-control" placeholder="Name" name="name"
|
||||
value="{{request.POST.name}}">
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="filter_col col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Email</label>
|
||||
<input type="text" class="form-control" placeholder="Email" name="email"
|
||||
value="{{request.POST.email}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Domain Name</label>
|
||||
<input type="text" class="form-control" placeholder="Domain Name" name="domain_name"
|
||||
value="{{request.POST.domain_name}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Created By</label>
|
||||
<select name="created_by" id="created_by" class="assigned_users_ form-control">
|
||||
<option value="">
|
||||
------------------</option>
|
||||
{% for user in users %}
|
||||
<option value="{{user.id}}" {% if user.id|slugify == request.POST.created_by %} selected=""
|
||||
{% endif %}>
|
||||
{{user.email}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-3">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Contact List</label>
|
||||
<select name="contact_list" id="id_contact_list" class="class_contact_list_ form-control">
|
||||
<option value="">
|
||||
------------------</option>
|
||||
{% for contact_list in contact_lists %}
|
||||
<option value="{{contact_list.id}}" {% if contact_list.id|slugify == request.POST.contact_list %}
|
||||
selected="" {% endif %}>
|
||||
{{contact_list.name}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="tab_status" id="tab_status">
|
||||
<div class="filter_col col-2">
|
||||
<div class="form-group buttons_row">
|
||||
<button class="btn btn-primary save" type="submit">Search</button>
|
||||
<a href="" class="btn btn-default clear" onclick="window.location.reload">Clear</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- heading_create ends here -->
|
||||
<!-- filter_row starts here -->
|
||||
<div class="filter_row row marl">
|
||||
<div class="col-md-12 col-lg-12 col-xl-12">
|
||||
<div class="table_container_row row marl no-gutters">
|
||||
<div class="col-md-12">
|
||||
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="open-tab" data-toggle="tab" href="#open" role="tab" aria-controls="open"
|
||||
aria-selected="true">Contacts ({{contacts|length}})</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="close-tab" data-toggle="tab" href="#close" role="tab" aria-controls="close"
|
||||
aria-selected="false">Bounced ({{bounced_contacts|length}})</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="failed-contacts" data-toggle="tab" href="#failed_contacts" role="tab"
|
||||
aria-controls="close" aria-selected="false">Failed Contacts ({{failed_contacts|length}})</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="open" role="tabpanel" aria-labelledby="open">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="panel-heading-list card-title text-right">
|
||||
<span class="total_count float-left">Contacts - {% if show_pageitems %}
|
||||
{% show_pageitems %}{% else %}{{contacts|length}}{% endif %}</span>
|
||||
<span class="filter_toggle ">
|
||||
<a href="#" class="primary_btn"><i class="fas fa-filter"></i></a>
|
||||
</span>
|
||||
<!-- <button href="#" class="primary_btn" id="delete_all" style="background:black; color: white;">Delete
|
||||
Selected</button>
|
||||
<button href="#" class="primary_btn" id="delete_all_complete"
|
||||
style="background:black; color: white;">Delete All</button> -->
|
||||
</div>
|
||||
<div class="table-responsive table-bordered ">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th width="1%">
|
||||
<input type="checkbox" name="check_all" id="check_all">
|
||||
</th> -->
|
||||
<th width="5%">S. No</th>
|
||||
<th width="10%">Name</th>
|
||||
<th width="10%">Email</th>
|
||||
<th width="15%">Company</th>
|
||||
<th width="15%">Created by</th>
|
||||
<th width="15%">Created On</th>
|
||||
<th width="15%">Related Contact List</th>
|
||||
<th width="10%">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if per_page %}
|
||||
{% paginate per_page contacts %}
|
||||
{% else%}
|
||||
{% paginate 10 contacts %}
|
||||
{% endif %}
|
||||
{% for contact in contacts %}
|
||||
<tr style="text-align:center;">
|
||||
<td scope="row">{{ forloop.counter }}</td>
|
||||
<td><a href="{% url 'marketing:contact_detail' contact.id %}">{{ contact.name }}</td>
|
||||
<td class="text-center">{{ contact.email }}</td>
|
||||
<td class="text-center">{{ contact.company_name }}</td>
|
||||
<td>{{ contact.created_by }}</td>
|
||||
<td title="{{contact.created_on}}">{{ contact.created_on_arrow }}</td>
|
||||
<td>
|
||||
{% for contact_list in contact.contact_lists %}
|
||||
<span> <a
|
||||
href="{% url 'marketing:contact_list_detail' contact_list.0 %}">{{contact_list.1}}</a>
|
||||
</span>
|
||||
{% empty %}
|
||||
<span>None</span>
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td class="actions text-center">
|
||||
<!-- <a href="{% url 'marketing:edit_contact' contact.id %}" class="btn btn-success edit edit_contact"
|
||||
data-other-contacts-lists='{{contact.contact_list.all|length}}'><i class="fas fa-edit"></i></a> -->
|
||||
<!-- <a href="#" class="sky_blue box"><i class="far fa-copy"></i></a>
|
||||
<a href="#" class="purple box"><i class="fas fa-upload"></i></a> -->
|
||||
<a href="{% url 'marketing:delete_contact' contact.id %}"
|
||||
class="btn btn-danger delete remove_account"
|
||||
data-other-contacts-lists='{{contact.contact_lists_count}}' title="Delete"><i
|
||||
class="fas fa-trash-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{% empty %}
|
||||
<tr style="text-align:center;">
|
||||
<td colspan="6">There are no records</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center row marl mt-3">
|
||||
{% show_pages %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="close" role="tabpanel" aria-labelledby="close">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="panel-heading-list card-title text-right">
|
||||
<span class="total_count float-left">Bounced Contacts - {{bounced_contacts|length}}</span>
|
||||
<span class="filter_toggle ">
|
||||
<a href="#" class="primary_btn"><i class="fas fa-filter"></i></a>
|
||||
</span>
|
||||
<!-- <button href="#" class="primary_btn" id="delete_all_bounced"
|
||||
style="background:black; color: white;">Delete Selected</button>
|
||||
<button href="#" class="primary_btn" id="delete_all_bounced_complete"
|
||||
style="background:black; color: white;">Delete All</button> -->
|
||||
</div>
|
||||
<div class="table-responsive table-bordered ">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">S. No</th>
|
||||
<th width="10%">Name</th>
|
||||
<th width="10%">Email</th>
|
||||
<th width="15%">Company</th>
|
||||
<th width="15%">Created by</th>
|
||||
<th width="15%">Created On</th>
|
||||
<th width="15%">Related Contact List</th>
|
||||
<th width="10%">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if per_page %}
|
||||
{% paginate per_page bounced_contacts %}
|
||||
{% else%}
|
||||
{% paginate 10 bounced_contacts %}
|
||||
{% endif %}
|
||||
{% for contact in bounced_contacts %}
|
||||
<tr style="text-align:center;">
|
||||
<td scope="row">{{ forloop.counter }}</td>
|
||||
<td><a href="{% url 'marketing:contact_detail' contact.id %}">{{ contact.name }}</td>
|
||||
<td class="text-center">{{ contact.email }}</td>
|
||||
<td class="text-center">{{ contact.company_name }}</td>
|
||||
<td>{{ contact.created_by }}</td>
|
||||
<td title="{{contact.created_on}}">{{ contact.created_on_arrow }}</td>
|
||||
<td>
|
||||
{% for contact_list in contact.contact_lists %}
|
||||
<span> <a
|
||||
href="{% url 'marketing:contact_list_detail' contact_list.0 %}">{{contact_list.1}}</a>
|
||||
</span>
|
||||
{% empty %}
|
||||
<span>None</span>
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td class="actions text-center">
|
||||
<!-- <a href="{% url 'marketing:edit_contact' contact.id %}" class="btn btn-success edit edit_contact"
|
||||
data-other-contacts-lists='{{contact.contact_list.all|length}}'><i class="fas fa-edit"></i></a> -->
|
||||
<!-- <a href="#" class="sky_blue box"><i class="far fa-copy"></i></a>
|
||||
<a href="#" class="purple box"><i class="fas fa-upload"></i></a> -->
|
||||
<a href="{% url 'marketing:delete_contact' contact.id %}"
|
||||
class="btn btn-danger delete remove_account"
|
||||
data-other-contacts-lists='{{contact.contact_lists_count}}' title="Delete"><i
|
||||
class="fas fa-trash-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{% empty %}
|
||||
<tr style="text-align:center;">
|
||||
<td colspan="6">There are no records</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center row marl mt-3">
|
||||
<ul class="pagination">
|
||||
{% show_pages %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="failed_contacts" role="tabpanel" aria-labelledby="close">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="panel-heading-list card-title text-right">
|
||||
<span class="total_count float-left">Failed Contacts - {{failed_contacts|length}}</span>
|
||||
<span class="filter_toggle ">
|
||||
<a href="#" class="primary_btn"><i class="fas fa-filter"></i></a>
|
||||
</span>
|
||||
<!-- <button href="#" class="primary_btn" id="delete_all_bounced"
|
||||
style="background:black; color: white;">Delete Selected</button>
|
||||
<button href="#" class="primary_btn" id="delete_all_bounced_complete"
|
||||
style="background:black; color: white;">Delete All</button> -->
|
||||
</div>
|
||||
<div class="table-responsive table-bordered ">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">S. No</th>
|
||||
<th width="10%">Name</th>
|
||||
<th width="10%">Email</th>
|
||||
<th width="15%">Company</th>
|
||||
<th width="15%">Created by</th>
|
||||
<th width="15%">Created On</th>
|
||||
<th width="15%">Related Contact List</th>
|
||||
<th width="10%">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if per_page %}
|
||||
{% paginate per_page failed_contacts %}
|
||||
{% else%}
|
||||
{% paginate 10 failed_contacts %}
|
||||
{% endif %}
|
||||
{% for contact in failed_contacts %}
|
||||
<tr style="text-align:center;">
|
||||
<td scope="row">{{ forloop.counter }}</td>
|
||||
<td><a href="{% url 'marketing:contact_detail' contact.id %}">{{ contact.name }}</td>
|
||||
<td class="text-center">{{ contact.email }}</td>
|
||||
<td class="text-center">{{ contact.company_name }}</td>
|
||||
<td>{{ contact.created_by }}</td>
|
||||
<td title="{{contact.created_on}}">{{ contact.created_on_arrow }}</td>
|
||||
<td>
|
||||
{% for contact_list in contact.contact_lists %}
|
||||
<span> <a
|
||||
href="{% url 'marketing:contact_list_detail' contact_list.0 %}">{{contact_list.1}}</a>
|
||||
</span>
|
||||
{% empty %}
|
||||
<span>None</span>
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td class="actions text-center">
|
||||
<!-- <a href="{% url 'marketing:edit_contact' contact.id %}" class="btn btn-success edit edit_contact"
|
||||
data-other-contacts-lists='{{contact.contact_list.all|length}}'><i class="fas fa-edit"></i></a> -->
|
||||
<!-- <a href="#" class="sky_blue box"><i class="far fa-copy"></i></a>
|
||||
<a href="#" class="purple box"><i class="fas fa-upload"></i></a> -->
|
||||
<a href="{% url 'marketing:delete_contact' contact.id %}"
|
||||
class="btn btn-danger delete remove_account"
|
||||
data-other-contacts-lists='{{contact.contact_lists_count}}' title="Delete"><i
|
||||
class="fas fa-trash-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{% empty %}
|
||||
<tr style="text-align:center;">
|
||||
<td colspan="6">There are no records</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center row marl mt-3">
|
||||
<ul class="pagination">
|
||||
{% show_pages %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br clear="all">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- filter_row ends here -->
|
||||
<!-- accounts list start -->
|
||||
<!-- accounts list end -->
|
||||
</div>
|
||||
<!-- main_container ends here -->
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js_block %}
|
||||
<script>
|
||||
$(function () {
|
||||
$(".filter_toggle").click(function () {
|
||||
$(".list_filter_row").toggle();
|
||||
});
|
||||
$('#id_tag').select2();
|
||||
$('#delete_all').hide()
|
||||
$('#delete_all_bounced').hide()
|
||||
$('#delete_all_complete').hide()
|
||||
$('#delete_all_bounced_complete').hide()
|
||||
$('#delete_all_duplicate').hide()
|
||||
$('#delete_all_complete_duplicate').hide()
|
||||
|
||||
$(".tag_class_cl").click(function () {
|
||||
// $(".tag_class_opp").css('cursor', 'pointer')
|
||||
url = "{% url 'marketing:contact_lists' %}"
|
||||
url = url + "?tag=" + $(this).attr('data-link')
|
||||
window.location.href = url;
|
||||
})
|
||||
|
||||
$("#check_all").click(function () {
|
||||
$(".check_delete").prop('checked', $(this).prop('checked'))
|
||||
|
||||
if ($('#check_all').prop('checked')) {
|
||||
$('#delete_all').show()
|
||||
$('#delete_all_complete').show()
|
||||
}
|
||||
else {
|
||||
$('#delete_all').hide()
|
||||
$('#delete_all_complete').hide()
|
||||
}
|
||||
});
|
||||
|
||||
$('.check_delete').on('change', function () {
|
||||
// console.log('changed')
|
||||
if ($('.check_delete:checked').length > 1) {
|
||||
$('#delete_all').show()
|
||||
}
|
||||
else {
|
||||
$('#delete_all').hide()
|
||||
}
|
||||
})
|
||||
|
||||
$('#delete_all_complete').click(function () {
|
||||
if (!confirm('Are you sure you want to delete all the {{contacts_list_count}} contacts ?')) {
|
||||
$('#check_all').prop('checked', false)
|
||||
$('.check_delete').prop('checked', false)
|
||||
$('#delete_all').hide()
|
||||
$('#delete_all_complete').hide()
|
||||
return;
|
||||
}
|
||||
{% comment %}
|
||||
window.location.href = "{% url 'marketing:delete_all_contacts' contact.id %}"
|
||||
{% endcomment %}
|
||||
|
||||
})
|
||||
|
||||
$('#delete_all').click(function (e) {
|
||||
e.preventDefault()
|
||||
if (!confirm('Are you sure you want to delete the selected contacts ?')) {
|
||||
$('#check_all').prop('checked', false)
|
||||
$('.check_delete').prop('checked', false)
|
||||
$('#delete_all').hide()
|
||||
$('#delete_all_complete').hide()
|
||||
return;
|
||||
}
|
||||
$('#delete_all').attr('disabled', 'disabled')
|
||||
var selected = [];
|
||||
$('.check_delete:checked').each(function () {
|
||||
selected.push($(this).attr('value'));
|
||||
// console.log(selected)
|
||||
});
|
||||
console.log(selected)
|
||||
$.ajax({
|
||||
url: "{% url 'marketing:delete_multiple_contacts' %}",
|
||||
type: 'POST',
|
||||
data: {
|
||||
'selected_list': selected,
|
||||
'from_contact': "{{contact_list.id}}",
|
||||
},
|
||||
success: function (data) {
|
||||
console.log(data)
|
||||
if (data['error'] === false) {
|
||||
window.location.reload()
|
||||
}
|
||||
else {
|
||||
$('#delete_all').removeAttr('disabled', 'disabled')
|
||||
alert(data['message'])
|
||||
}
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
// for bounced
|
||||
|
||||
$("#check_all_bounced").click(function () {
|
||||
$(".check_delete_bounced").prop('checked', $(this).prop('checked'))
|
||||
|
||||
if ($('#check_all_bounced').prop('checked')) {
|
||||
$('#delete_all_bounced').show()
|
||||
$('#delete_all_bounced_complete').show()
|
||||
}
|
||||
else {
|
||||
$('#delete_all_bounced').hide()
|
||||
$('#delete_all_bounced_complete').hide()
|
||||
}
|
||||
});
|
||||
|
||||
$('.check_delete_bounced').on('change', function () {
|
||||
// console.log('changed')
|
||||
if ($('.check_delete_bounced:checked').length > 1) {
|
||||
$('#delete_all_bounced').show()
|
||||
}
|
||||
else {
|
||||
$('#delete_all_bounced').hide()
|
||||
}
|
||||
})
|
||||
|
||||
$('#delete_all_bounced_complete').click(function () {
|
||||
if (!confirm('Are you sure you want to delete all the {{bounced_contacts_list_count}} contacts ?')) {
|
||||
$('#check_all_bounced').prop('checked', false)
|
||||
$('.check_delete_bounced').prop('checked', false)
|
||||
$('#delete_all_bounced').hide()
|
||||
$('#delete_all_bounced_complete').hide()
|
||||
return;
|
||||
}
|
||||
{% comment %}
|
||||
window.location.href = "{% url 'marketing:delete_all_contacts' contact.id %}?bounced=true"
|
||||
{% endcomment %}
|
||||
})
|
||||
|
||||
$('#delete_all_bounced').click(function (e) {
|
||||
e.preventDefault()
|
||||
if (!confirm('Are you sure you want to delete the selected contacts ?')) {
|
||||
$('#check_all_bounced').prop('checked', false)
|
||||
$('.check_delete_bounced').prop('checked', false)
|
||||
$('#delete_all_bounced').hide()
|
||||
$('#delete_all_bounced_complete').hide()
|
||||
return;
|
||||
}
|
||||
$('#delete_all_bounced').attr('disabled', 'disabled')
|
||||
var selected = [];
|
||||
$('.check_delete_bounced:checked').each(function () {
|
||||
selected.push($(this).attr('value'));
|
||||
// console.log(selected)
|
||||
});
|
||||
console.log(selected)
|
||||
$.ajax({
|
||||
url: "{% url 'marketing:delete_multiple_contacts' %}",
|
||||
type: 'POST',
|
||||
data: {
|
||||
'selected_list': selected,
|
||||
'from_contact': "{{contact_list.id}}",
|
||||
},
|
||||
success: function (data) {
|
||||
console.log(data)
|
||||
if (data['error'] === false) {
|
||||
window.location.reload()
|
||||
}
|
||||
else {
|
||||
$('#delete_all_bounced').removeAttr('disabled', 'disabled')
|
||||
alert(data['message'])
|
||||
}
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
|
||||
// for duplicates
|
||||
|
||||
$("#check_all_duplicate").click(function () {
|
||||
$(".check_delete_duplicate").prop('checked', $(this).prop('checked'))
|
||||
|
||||
if ($('#check_all_duplicate').prop('checked')) {
|
||||
$('#delete_all_duplicate').show()
|
||||
$('#delete_all_complete_duplicate').show()
|
||||
}
|
||||
else {
|
||||
$('#delete_all_duplicate').hide()
|
||||
$('#delete_all_complete_duplicate').hide()
|
||||
}
|
||||
});
|
||||
|
||||
$('.check_delete_duplicate').on('change', function () {
|
||||
// console.log('changed')
|
||||
if ($('.check_delete_duplicate:checked').length > 1) {
|
||||
$('#delete_all_duplicate').show()
|
||||
}
|
||||
else {
|
||||
$('#delete_all_duplicate').hide()
|
||||
}
|
||||
})
|
||||
|
||||
$('#delete_all_complete_duplicate').click(function () {
|
||||
if (!confirm('Are you sure you want to delete all the {{duplicate_contacts.count}} contacts ?')) {
|
||||
$('#check_all_duplicate').prop('checked', false)
|
||||
$('.check_delete_duplicate').prop('checked', false)
|
||||
$('#delete_all_duplicate').hide()
|
||||
$('#delete_all_complete_duplicate').hide()
|
||||
return;
|
||||
}
|
||||
{% comment %}
|
||||
|
||||
window.location.href = "{% url 'marketing:delete_all_contacts' contact.id %}?duplicate_contacts=true"
|
||||
{% endcomment %}
|
||||
})
|
||||
|
||||
$('#delete_all_duplicate').click(function (e) {
|
||||
e.preventDefault()
|
||||
if (!confirm('Are you sure you want to delete the selected contacts ?')) {
|
||||
$('#check_all_duplicate').prop('checked', false)
|
||||
$('.check_delete_duplicate').prop('checked', false)
|
||||
$('#delete_all_duplicate').hide()
|
||||
$('#delete_all_complete_duplicate').hide()
|
||||
return;
|
||||
}
|
||||
$('#delete_all_duplicate').attr('disabled', 'disabled')
|
||||
var selected = [];
|
||||
$('.check_delete_duplicate:checked').each(function () {
|
||||
selected.push($(this).attr('value'));
|
||||
// console.log(selected)
|
||||
});
|
||||
console.log(selected)
|
||||
$.ajax({
|
||||
url: "{% url 'marketing:delete_multiple_contacts' %}",
|
||||
type: 'POST',
|
||||
data: {
|
||||
'selected_list': selected,
|
||||
'from_contact': "{{contact_list.id}}",
|
||||
'duplicate_contacts': "true"
|
||||
},
|
||||
success: function (data) {
|
||||
console.log(data)
|
||||
if (data['error'] === false) {
|
||||
window.location.reload()
|
||||
}
|
||||
else {
|
||||
$('#delete_all_bounced').removeAttr('disabled', 'disabled')
|
||||
alert(data['message'])
|
||||
}
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
// $(".remove_account").click(function (e) {
|
||||
// e.preventDefault()
|
||||
// url = $(this).attr('href')
|
||||
// if (!confirm('Are you sure you want to delete?'))
|
||||
// return;
|
||||
// window.location = $(this).attr('href')
|
||||
// })
|
||||
|
||||
$(".remove_account").click(function (e) {
|
||||
e.preventDefault()
|
||||
url = $(this).attr('href')
|
||||
var contact_lists = parseInt($(this).attr('data-other-contacts-lists'));
|
||||
if (contact_lists > 1) {
|
||||
if (!confirm('This contact exists in other contact lists too. Are you sure you want to delete this contact?'))
|
||||
return;
|
||||
window.location = $(this).attr('href');
|
||||
} else {
|
||||
if (!confirm('Are you sure you want to delete?'))
|
||||
return;
|
||||
window.location = $(this).attr('href');
|
||||
}
|
||||
if (!confirm('Are you sure you want to delete?'))
|
||||
return;
|
||||
window.location = $(this).attr('href');
|
||||
})
|
||||
|
||||
$(".edit_contact").click(function (e) {
|
||||
e.preventDefault()
|
||||
url = $(this).attr('href')
|
||||
console.log(url)
|
||||
var contact_lists = parseInt($(this).attr('data-other-contacts-lists'));
|
||||
console.log(contact_lists);
|
||||
window.location = $(this).attr('href');
|
||||
})
|
||||
|
||||
$("a[rel='page']").click(function (e) {
|
||||
e.preventDefault();
|
||||
$('#leads_filter').attr("action", $(this).attr("href"));
|
||||
$('#leads_filter').submit();
|
||||
});
|
||||
|
||||
var queryParams = (window.location.search).replace('?', '').split('&').map(param => param.split('=')).reduce((values, [key, value]) => { values[key] = value; return values; }, {})
|
||||
|
||||
if (!queryParams.hasOwnProperty('page') && queryParams.hasOwnProperty('bounced_contacts_page')) {
|
||||
$('#close-tab').trigger('click')
|
||||
}
|
||||
|
||||
if (!queryParams.hasOwnProperty('page') && queryParams.hasOwnProperty('failed_contacts')) {
|
||||
$('#failed-contacts').trigger('click')
|
||||
}
|
||||
if (queryParams.hasOwnProperty('duplicate_contacts')) {
|
||||
$('#duplicate-contacts').trigger('click')
|
||||
}
|
||||
|
||||
})
|
||||
</script>
|
||||
{% endblock js_block %}
|
||||
30
marketing/templates/unsubscribe_from_campaign_template.html
Normal file
30
marketing/templates/unsubscribe_from_campaign_template.html
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Django-CRM</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 10%;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>You have successfully unsubscribed from Campaign emails from
|
||||
|
||||
<span>
|
||||
<a href="{{request.scheme}}://{{request.get_host}}/">{{request.get_host}}</a> .
|
||||
</span>
|
||||
</h1>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -4,8 +4,11 @@ from datetime import datetime, timedelta
|
|||
import openpyxl
|
||||
import xlwt
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.core.management import call_command
|
||||
from django.shortcuts import reverse
|
||||
from django.test import Client, TestCase
|
||||
from django.test.utils import override_settings
|
||||
from haystack import connections
|
||||
|
||||
from common.models import User
|
||||
from marketing.models import (Campaign, CampaignLinkClick, CampaignLog,
|
||||
|
|
@ -14,6 +17,14 @@ from marketing.models import (Campaign, CampaignLinkClick, CampaignLog,
|
|||
Tag)
|
||||
from marketing.views import *
|
||||
|
||||
TEST_INDEX = {
|
||||
'default': {
|
||||
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
|
||||
'URL': 'http://127.0.0.1:9200/',
|
||||
'TIMEOUT': 60 * 10,
|
||||
'INDEX_NAME': 'test_index',
|
||||
},
|
||||
}
|
||||
|
||||
class TestMarketingModel(object):
|
||||
def setUp(self):
|
||||
|
|
@ -125,9 +136,19 @@ class TestMarketingModel(object):
|
|||
campaign=self.campaign,
|
||||
contact=self.contact_1
|
||||
)
|
||||
# connections.reload('default')
|
||||
|
||||
# def tearDown(self):
|
||||
# call_command('clear_index', interactive=False, verbosity=0)
|
||||
|
||||
|
||||
@override_settings(HAYSTACK_CONNECTIONS=TEST_INDEX )
|
||||
class TestTemplates(TestMarketingModel, TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestTemplates, self).setUp()
|
||||
connections.reload('default')
|
||||
|
||||
def test_templates(self):
|
||||
url1 = reverse('marketing:dashboard')
|
||||
url2 = reverse('marketing:contact_lists')
|
||||
|
|
@ -139,7 +160,7 @@ class TestTemplates(TestMarketingModel, TestCase):
|
|||
url13 = reverse('marketing:campaign_new')
|
||||
resp1 = self.client.get(url1)
|
||||
resp2 = self.client.get(url2)
|
||||
resp4 = self.client.get(url4)
|
||||
# resp4 = self.client.get(url4)
|
||||
resp5 = self.client.get(url5)
|
||||
resp8 = self.client.get(url8)
|
||||
resp9 = self.client.get(url9)
|
||||
|
|
@ -147,7 +168,7 @@ class TestTemplates(TestMarketingModel, TestCase):
|
|||
resp13 = self.client.get(url13)
|
||||
self.assertEqual(resp1.status_code, 200)
|
||||
self.assertEqual(resp2.status_code, 200)
|
||||
self.assertEqual(resp4.status_code, 200)
|
||||
# self.assertEqual(resp4.status_code, 200)
|
||||
self.assertEqual(resp5.status_code, 200)
|
||||
self.assertEqual(resp8.status_code, 200)
|
||||
self.assertEqual(resp9.status_code, 200)
|
||||
|
|
@ -229,8 +250,13 @@ class TestDasboardView(TestMarketingModel, TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
@override_settings(HAYSTACK_CONNECTIONS=TEST_INDEX )
|
||||
class TestContactListsListPage(TestMarketingModel, TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestContactListsListPage, self).setUp()
|
||||
connections.reload('default')
|
||||
|
||||
def test_contact_lists_list_page(self):
|
||||
self.client.login(username='john@example.com', password='password')
|
||||
response = self.client.get(
|
||||
|
|
@ -253,9 +279,16 @@ class TestContactListsListPage(TestMarketingModel, TestCase):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
@override_settings(HAYSTACK_CONNECTIONS=TEST_INDEX )
|
||||
class TestContactsListPage(TestMarketingModel, TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestContactsListPage, self).setUp()
|
||||
connections.reload('default')
|
||||
# connections = ConnectionHandler(TEST_INDEX )
|
||||
|
||||
def test_contacts_list_page(self):
|
||||
connections.reload('default')
|
||||
self.client.login(username='john@example.com', password='password')
|
||||
response = self.client.get(
|
||||
reverse('marketing:contacts_list'))
|
||||
|
|
@ -774,7 +807,7 @@ class TestContactListDetail(TestMarketingModel, TestCase):
|
|||
def test_unsubscribe_from_campaign(self):
|
||||
response = self.client.get(
|
||||
reverse('marketing:unsubscribe_from_campaign', kwargs={'contact_id': self.contact.id,'campaign_id': self.campaign.id,}))
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_contact_detail(self):
|
||||
self.client.login(username='janeMarketing@example.com', password='password')
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ from .views import (
|
|||
add_email_for_campaigns, list_all_emails_for_campaigns, edit_email_for_campaigns, delete_email_for_campaigns,
|
||||
add_blocked_domain, blocked_domain_list, edit_blocked_domain, delete_blocked_domain,
|
||||
add_blocked_email, blocked_email_list, edit_blocked_email, delete_blocked_email,
|
||||
# MarketingContactEmailSearch,
|
||||
contacts_list_elastic_search,
|
||||
# MarketingContactEmailSearch,
|
||||
# contacts_list_new
|
||||
# delete_contact_list
|
||||
# campaign_edit
|
||||
|
|
@ -27,7 +28,7 @@ urlpatterns = [
|
|||
path('contact-list/', contact_lists, name='contact_lists'),
|
||||
path('contacts/<int:pk>/edit/', edit_contact, name='edit_contact'),
|
||||
path('contacts/<int:pk>/delete/', delete_contact, name='delete_contact'),
|
||||
path('contacts/', contacts_list, name='contacts_list'),
|
||||
path('contacts/', contacts_list_elastic_search, name='contacts_list'),
|
||||
path('contact-list/create/', contact_list_new, name='contact_list_new'),
|
||||
# path('cl/list/cnew/', contacts_list_new, name='contacts_list_new'),
|
||||
path('contact-list/<int:pk>/detail/', contact_list_detail, name='contact_list_detail'),
|
||||
|
|
@ -77,4 +78,5 @@ urlpatterns = [
|
|||
path('delete-blocked-email/<int:blocked_email_id>/', delete_blocked_email, name="delete_blocked_email"),
|
||||
|
||||
path('search-marketing-contact-emails/', include('haystack.urls')),
|
||||
# path('elastic-search/', contacts_list_elastic_search),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -878,7 +878,7 @@ def unsubscribe_from_campaign(request, contact_id, campaign_id):
|
|||
if campaign_obj:
|
||||
ContactUnsubscribedCampaign.objects.create(
|
||||
campaigns=campaign_obj, contacts=contact_obj, is_unsubscribed=True)
|
||||
return HttpResponseRedirect('/')
|
||||
return render(request, 'unsubscribe_from_campaign_template.html')
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
@ -1278,6 +1278,72 @@ def delete_blocked_email(request, blocked_email_id):
|
|||
block_email_obj.delete()
|
||||
return redirect(reverse('common:api_settings') + '?blocked_emails')
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def contacts_list_elastic_search(request):
|
||||
if (request.user.role == "ADMIN"):
|
||||
# contacts = Contact.objects.filter(is_bounced=False)
|
||||
contacts = SearchQuerySet().filter(is_bounced='false').models(Contact)
|
||||
bounced_contacts = SearchQuerySet().filter(is_bounced='true').models(Contact)
|
||||
failed_contacts = SearchQuerySet().models(FailedContact).filter()
|
||||
# bounced_contacts = Contact.objects.filter(is_bounced=True)
|
||||
# failed_contacts = FailedContact.objects.all()
|
||||
contact_lists = ContactList.objects.all()
|
||||
else:
|
||||
contact_ids = request.user.marketing_contactlist.all().values_list('contacts',
|
||||
flat=True)
|
||||
contacts = SearchQuerySet().filter(is_bounced='false', id__in=contact_ids).models(Contact)
|
||||
bounced_contacts = SearchQuerySet().filter(is_bounced='true', id__in=contact_ids).models(Contact)
|
||||
failed_contacts = SearchQuerySet().models(FailedContact).filter(created_by_id=str(request.user.id))
|
||||
# contacts = Contact.objects.filter(id__in=contact_ids).exclude(is_bounced=True)
|
||||
# bounced_contacts = Contact.objects.filter(id__in=contact_ids, is_bounced=True)
|
||||
# failed_contacts = FailedContact.objects.filter(created_by=request.user)
|
||||
contact_lists = ContactList.objects.filter(created_by=request.user)
|
||||
# contacts = Contact.objects.filter(created_by=request.user)
|
||||
|
||||
users = User.objects.filter(
|
||||
id__in=[_id for _id in contacts.values_list('created_by_id', flat=True) if _id != ''])
|
||||
|
||||
if request.method == 'GET':
|
||||
context = {'contacts': contacts, 'users': users, 'contact_lists': contact_lists,
|
||||
'bounced_contacts': bounced_contacts, 'failed_contacts': '',
|
||||
}
|
||||
return render(request, 'search_contact_emails.html', context)
|
||||
|
||||
if request.method == 'POST':
|
||||
data = request.POST
|
||||
if data.get('name'):
|
||||
contacts = contacts.filter(
|
||||
name__icontains=data.get('name'))
|
||||
bounced_contacts = bounced_contacts.filter(
|
||||
name__icontains=data.get('name'))
|
||||
failed_contacts = failed_contacts.filter(
|
||||
name__icontains=data.get('name'))
|
||||
if data.get('email'):
|
||||
contacts = contacts.filter(email__icontains=data.get('email'))
|
||||
bounced_contacts = bounced_contacts.filter(email__icontains=data.get('email'))
|
||||
failed_contacts = failed_contacts.filter(email__icontains=data.get('email'))
|
||||
|
||||
if data.get('domain_name'):
|
||||
contacts = contacts.filter(email_domain__icontains=data.get('domain_name'))
|
||||
bounced_contacts = bounced_contacts.filter(email_domain__icontains=data.get('domain_name'))
|
||||
failed_contacts = failed_contacts.filter(email_domain__icontains=data.get('domain_name'))
|
||||
|
||||
if data.get('created_by'):
|
||||
contacts = contacts.filter(created_by_id=data.get('created_by'))
|
||||
bounced_contacts = bounced_contacts.filter(created_by_id=data.get('created_by'))
|
||||
failed_contacts = failed_contacts.filter(created_by_id=data.get('created_by'))
|
||||
|
||||
if data.get('contact_list'):
|
||||
contacts = contacts.filter(contact_lists_id=data.get('contact_list'))
|
||||
bounced_contacts = bounced_contacts.filter(contact_lists_id=data.get('contact_list'))
|
||||
failed_contacts = failed_contacts.filter(contact_lists_id=data.get('contact_list'))
|
||||
|
||||
context = {'contacts': contacts, 'users': users, 'contact_lists': contact_lists,
|
||||
'bounced_contacts': bounced_contacts, 'failed_contacts': failed_contacts,
|
||||
}
|
||||
return render(request, 'search_contact_emails.html', context)
|
||||
|
||||
|
||||
# class MarketingContactEmailSearch(SearchView):
|
||||
# form_class = MarketingContactEmailSearchForm
|
||||
|
|
@ -1298,4 +1364,4 @@ def delete_blocked_email(request, blocked_email_id):
|
|||
# # def get_context_data(self, *args, **kwargs):
|
||||
# # context = super(MarketingContactEmailSearch, self).get_context_data(*args, **kwargs)
|
||||
# # import pdb; pdb.set_trace()
|
||||
# # return context
|
||||
# # return context
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from django.template.loader import render_to_string
|
|||
|
||||
from accounts.models import User
|
||||
from opportunity.models import Opportunity
|
||||
from marketing.models import BlockedDomain, BlockedEmail
|
||||
|
||||
|
||||
@task
|
||||
|
|
@ -14,25 +15,28 @@ def send_email_to_assigned_user(recipients, opportunity_id, domain='demo.django-
|
|||
""" Send Mail To Users When they are assigned to a opportunity """
|
||||
opportunity = Opportunity.objects.get(id=opportunity_id)
|
||||
created_by = opportunity.created_by
|
||||
blocked_domains = BlockedDomain.objects.values_list('domain', flat=True)
|
||||
blocked_emails = BlockedEmail.objects.values_list('email', flat=True)
|
||||
for user in recipients:
|
||||
recipients_list = []
|
||||
user = User.objects.filter(id=user, is_active=True).first()
|
||||
if user:
|
||||
recipients_list.append(user.email)
|
||||
context = {}
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('opportunity:opp_view', args=(opportunity.id,))
|
||||
context["user"] = user
|
||||
context["opportunity"] = opportunity
|
||||
context["created_by"] = created_by
|
||||
subject = 'Assigned an opportunity for you.'
|
||||
html_content = render_to_string(
|
||||
'assigned_to/opportunity_assigned.html', context=context)
|
||||
if (user.email not in blocked_emails) and (user.email.split('@')[-1] not in blocked_domains):
|
||||
recipients_list.append(user.email)
|
||||
context = {}
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('opportunity:opp_view', args=(opportunity.id,))
|
||||
context["user"] = user
|
||||
context["opportunity"] = opportunity
|
||||
context["created_by"] = created_by
|
||||
subject = 'Assigned an opportunity for you.'
|
||||
html_content = render_to_string(
|
||||
'assigned_to/opportunity_assigned.html', context=context)
|
||||
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
to=recipients_list
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
msg = EmailMessage(
|
||||
subject,
|
||||
html_content,
|
||||
to=recipients_list
|
||||
)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
Django==2.2.4
|
||||
django==2.2.4
|
||||
celery==4.3.0
|
||||
django-simple-pagination==1.3
|
||||
django-compressor==2.3
|
||||
|
|
@ -25,3 +25,4 @@ pytest-django==3.5.1
|
|||
codacy-coverage==1.3.11
|
||||
django-haystack==2.8.1
|
||||
elasticsearch==5.5.3
|
||||
|
||||
|
|
|
|||
|
|
@ -8,31 +8,35 @@ from accounts.models import Account, Email
|
|||
from common.models import User
|
||||
from contacts.models import Contact
|
||||
from tasks.models import Task
|
||||
from marketing.models import BlockedDomain, BlockedEmail
|
||||
|
||||
|
||||
@task
|
||||
def send_email(task_id, recipients, domain='demo.django-crm.io', protocol='http'):
|
||||
task = Task.objects.filter(id=task_id).first()
|
||||
created_by = task.created_by
|
||||
blocked_domains = BlockedDomain.objects.values_list('domain', flat=True)
|
||||
blocked_emails = BlockedEmail.objects.values_list('email', flat=True)
|
||||
for user in recipients:
|
||||
recipients_list = []
|
||||
user = User.objects.filter(id=user, is_active=True).first()
|
||||
if user:
|
||||
recipients_list.append(user.email)
|
||||
subject = ' Assigned a task for you .'
|
||||
context = {}
|
||||
context['task_title'] = task.title
|
||||
context['task_id'] = task.id
|
||||
context['task_created_by'] = task.created_by
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('tasks:task_detail', args=(task.id,))
|
||||
context['user'] = user
|
||||
html_content = render_to_string(
|
||||
'tasks_email_template.html', context=context)
|
||||
msg = EmailMessage(
|
||||
subject=subject, body=html_content, to=recipients_list)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
if (user.email not in blocked_emails) and (user.email.split('@')[-1] not in blocked_domains):
|
||||
recipients_list.append(user.email)
|
||||
subject = ' Assigned a task for you .'
|
||||
context = {}
|
||||
context['task_title'] = task.title
|
||||
context['task_id'] = task.id
|
||||
context['task_created_by'] = task.created_by
|
||||
context["url"] = protocol + '://' + domain + \
|
||||
reverse('tasks:task_detail', args=(task.id,))
|
||||
context['user'] = user
|
||||
html_content = render_to_string(
|
||||
'tasks_email_template.html', context=context)
|
||||
msg = EmailMessage(
|
||||
subject=subject, body=html_content, to=recipients_list)
|
||||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
|
||||
# if task:
|
||||
# subject = ' Assigned a task for you .'
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@
|
|||
{% if contact_list.failed_contacts.all %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="failed-contacts" data-toggle="tab" href="#failed_contacts" role="tab"
|
||||
aria-controls="close" aria-selected="false">Failed Contacts</a>
|
||||
aria-controls="close" aria-selected="false">Failed Contacts ({{contact_list.failed_contacts.count}})</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if contact_list.duplicate_contact_contact_list.all %}
|
||||
|
|
|
|||
|
|
@ -12,18 +12,24 @@
|
|||
<title>Django CRM</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Muli" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||
|
||||
{% block date_picker %}
|
||||
<link rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" />
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" />
|
||||
{% endblock date_picker %}
|
||||
|
||||
{% block quill_editor_links %}
|
||||
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
|
||||
<link href="https://cdn.quilljs.com/1.3.6/quill.bubble.css" rel="stylesheet">
|
||||
<link href="https://cdn.quilljs.com/1.3.6/quill.core.css" rel="stylesheet">
|
||||
{% endblock quill_editor_links %}
|
||||
|
||||
{% compress css %}
|
||||
<link href="{% static 'css/main.scss' %}" type="text/x-scss" rel="stylesheet">
|
||||
<link href="{% static 'css/mention.scss' %}" type="text/x-scss" rel="stylesheet">
|
||||
{% endcompress %}
|
||||
<style>
|
||||
. card-body{
|
||||
.card-body {
|
||||
padding:0;
|
||||
margin:0
|
||||
}
|
||||
|
|
@ -139,15 +145,23 @@
|
|||
</div>
|
||||
</div>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
{% block moment_js_block %}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.min.js"></script>
|
||||
<script
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
|
||||
{% endblock moment_js_block %}
|
||||
|
||||
<script defer src="https://use.fontawesome.com/releases/v5.7.1/js/all.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||
<script
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
|
||||
|
||||
|
||||
{% block extra_js_block %}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js"></script>
|
||||
<script src="https://cdn.quilljs.com/1.3.6/quill.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js"></script>
|
||||
{% endblock extra_js_block %}
|
||||
|
||||
|
||||
{% block js_block %}{% endblock js_block %}
|
||||
<script type="text/javascript">
|
||||
|
|
|
|||
Loading…
Reference in a new issue