diff --git a/common/tests.py b/common/tests.py
index 30ff4cd4..6cc41df2 100644
--- a/common/tests.py
+++ b/common/tests.py
@@ -108,8 +108,7 @@ class UserCreateTestCase(ObjectsCreation, TestCase):
'first_name': '',
'last_name': '',
'username': '',
- 'role': 'r',
- 'profile_pic': None})
+ 'role': 'ADMIN',})
self.assertEqual(response.status_code, 200)
diff --git a/invoices/templates/invoice_create_1.html b/invoices/templates/invoice_create_1.html
new file mode 100644
index 00000000..aeb2d58b
--- /dev/null
+++ b/invoices/templates/invoice_create_1.html
@@ -0,0 +1,324 @@
+{% extends 'sales/base.html' %}
+{% load staticfiles %}
+{% block breadcrumb %}
+{% block extralinks %}
+
+
+
+{% endblock %}
+
+
+ Invoices
+ {% if invoice_obj %}Edit{% else %}Create{% endif %}
+
+
+{% endblock %}
+{% block content %}
+
+
+ {% endblock %}
+
+ {% block js_block %}
+
+
+
+
+ {% endblock js_block %}
\ No newline at end of file
diff --git a/invoices/views.py b/invoices/views.py
index 4c2e1a2c..4c73a6d1 100644
--- a/invoices/views.py
+++ b/invoices/views.py
@@ -101,7 +101,7 @@ def invoices_create(request):
prefix='from')
context["to_address_form"] = InvoiceAddressForm(prefix='to')
- return render(request, 'invoices_create.html', context)
+ return render(request, 'invoice_create_1.html', context)
if request.method == 'POST':
form = InvoiceForm(request.POST, request_user=request.user)
@@ -166,7 +166,7 @@ def invoice_edit(request, invoice_id):
instance=invoice_obj.from_address)
context['to_address_form'] = InvoiceAddressForm(prefix='to',
instance=invoice_obj.to_address)
- return render(request, 'invoices_create.html', context)
+ return render(request, 'invoice_create_1.html', context)
if request.method == 'POST':
form = InvoiceForm(request.POST, instance=invoice_obj,
diff --git a/leads/tests.py b/leads/tests.py
index b48cd689..00b67a76 100644
--- a/leads/tests.py
+++ b/leads/tests.py
@@ -289,7 +289,7 @@ class UpdateLeadTestCase(TestLeadModel, TestCase):
'state': "California",
'postcode': "579", 'country': "AD",
'phone': "+917894563452",
- 'website': "www.gmail.com", 'status': None,
+ 'website': "www.gmail.com", 'status': '',
'source': "", 'opportunity_amount': "700",
'description': "Iam an Lead", 'created_by': self.user}
response = self.client.post(url, data)
diff --git a/marketing/migrations/0009_auto_20190618_1144.py b/marketing/migrations/0009_auto_20190618_1144.py
new file mode 100644
index 00000000..60c9d6cd
--- /dev/null
+++ b/marketing/migrations/0009_auto_20190618_1144.py
@@ -0,0 +1,36 @@
+# Generated by Django 2.1.7 on 2019-06-18 06:14
+
+from django.db import migrations, models
+import django.db.models.deletion
+import django.db.models.expressions
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('marketing', '0008_auto_20190612_1905'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='ContactUnsubscribedCampaign',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('is_unsubscribed', models.BooleanField(default=False)),
+ ],
+ ),
+ migrations.AlterModelOptions(
+ name='campaign',
+ options={'ordering': ('-created_on',)},
+ ),
+ migrations.AddField(
+ model_name='contactunsubscribedcampaign',
+ name='campaigns',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='campaign_is_unsubscribed', to='marketing.Campaign'),
+ ),
+ migrations.AddField(
+ model_name='contactunsubscribedcampaign',
+ name='contacts',
+ field=models.ForeignKey(on_delete=django.db.models.expressions.Case, related_name='contact_is_unsubscribed', to='marketing.Contact'),
+ ),
+ ]
diff --git a/marketing/models.py b/marketing/models.py
index b63ec2b4..10ed2305 100644
--- a/marketing/models.py
+++ b/marketing/models.py
@@ -260,6 +260,10 @@ class Campaign(models.Model):
return self.contact_lists.filter(contacts__is_unsubscribed=True
).exclude(contacts__email=None).values_list('contacts__email').count()
+ @property
+ def get_all_emails_subscribed_count(self):
+ return self.get_all_emails_count - self.get_all_email_bounces_count - self.get_all_emails_unsubscribed_count
+
@receiver(models.signals.pre_delete, sender=Campaign)
def comment_attachments_delete(sender, instance, **kwargs):
@@ -319,3 +323,14 @@ class CampaignCompleted(models.Model):
campaign = models.OneToOneField(
Campaign, on_delete=models.CASCADE, related_name='campaign_is_completed')
is_completed = models.BooleanField(default=False)
+
+
+class ContactUnsubscribedCampaign(models.Model):
+ """ This Model Is Used To Check If The Contact has Unsubscribed To a Particular Campaign
+ related name : contact_is_unsubscribed
+ """
+ campaigns = models.ForeignKey(
+ Campaign, on_delete=models.CASCADE, related_name='campaign_is_unsubscribed')
+ contacts = models.ForeignKey(
+ Contact, on_delete=models.Case, related_name='contact_is_unsubscribed')
+ is_unsubscribed = models.BooleanField(default=False)
diff --git a/marketing/tasks.py b/marketing/tasks.py
index 6b89ccd4..acff0e36 100644
--- a/marketing/tasks.py
+++ b/marketing/tasks.py
@@ -145,7 +145,8 @@ def run_campaign(campaign, domain='demo.django-crm.io', protocol='https'):
# title="company_logo"/>'
unsubscribe_from_campaign_url = reverse(
- 'marketing:unsubscribe_from_campaign', kwargs={'contact_id': each_contact.id, })
+ 'marketing:unsubscribe_from_campaign', kwargs={'contact_id': each_contact.id,
+ 'campaign_id': campaign.id})
unsubscribe_from_campaign_html = "
Unsubscribe ".format(
domain_url + unsubscribe_from_campaign_url)
names_dict = {'company_name': each_contact.company_name if each_contact.company_name else '',
diff --git a/marketing/templates/contact_detail.html b/marketing/templates/contact_detail.html
index 7db02519..02e4dbda 100644
--- a/marketing/templates/contact_detail.html
+++ b/marketing/templates/contact_detail.html
@@ -3,6 +3,12 @@
{% load paginate %}
{% block content %}
{{ block.super }}
+
+
+ Contacts
+ {{contact_obj.email}}
+
+
@@ -12,7 +18,7 @@
- Contact Detail
+ Contact Detail
@@ -21,7 +27,7 @@
Email{% if form.email.field.required %}* {% endif %}
-
+
{{contact_obj.email}}
@@ -30,7 +36,7 @@
First
Name{% if form.name.field.required %}* {% endif %}
-
+
{{contact_obj.name}}
@@ -39,7 +45,7 @@
Last
Name{% if form.last_name.field.required %}* {% endif %}
-
+
{{contact_obj.last_name}}
@@ -48,7 +54,7 @@
City
{% if form.city.field.required %}* {% endif %}
-
+
{{contact_obj.city}}
@@ -57,8 +63,8 @@