added duplicate contacts tabs, fixed time format in marketing campaign list page, added test cases in marketing, added contacts list filter in contacts page (#284)
* 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
This commit is contained in:
parent
df4fa9758e
commit
6b7dc3fe18
62 changed files with 3070 additions and 746 deletions
28
.coveragerc
Normal file
28
.coveragerc
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
[report]
|
||||
exclude_lines =
|
||||
# lines with this comment are not hit
|
||||
pragma: no cover
|
||||
|
||||
# Don't complain about missing debug-only code:
|
||||
def __unicode__
|
||||
def __repr__
|
||||
def __str__
|
||||
if self\.debug
|
||||
|
||||
# Don't complain if tests don't hit defensive assertion code:
|
||||
raise AssertionError
|
||||
raise NotImplementedError
|
||||
|
||||
# Don't complain if non-runnable code isn't run:
|
||||
if 0:
|
||||
if __name__ == .__main__.:
|
||||
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
|
||||
omit =
|
||||
*tests*
|
||||
./settings/*
|
||||
./*/migrations/*
|
||||
./*/apps.py
|
||||
./*/admin.py
|
||||
|
|
@ -4,8 +4,8 @@ Python 3.5.2:
|
|||
- virtualenv -p python3 env
|
||||
- source env/bin/activate
|
||||
- pip install --no-cache-dir -r requirements.txt
|
||||
- python manage.py test --noinput
|
||||
- coverage run --source=accounts,cases,common,contacts,emails,leads,opportunity,planner,tasks,invoices,events,teams manage.py test --noinput
|
||||
- python manage.py test --keepdb --noinput
|
||||
- coverage run --source=accounts,cases,common,contacts,leads,opportunity,tasks,invoices,events,teams,marketing manage.py test --keepdb --noinput
|
||||
- coverage report -m
|
||||
except:
|
||||
- tags
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ install:
|
|||
|
||||
# command to run tests
|
||||
script:
|
||||
- python manage.py test
|
||||
- coverage run --source=accounts,common manage.py test accounts common
|
||||
- python manage.py test --keepdb
|
||||
- coverage run --source=accounts,cases,common,contacts,leads,opportunity,tasks,invoices,events,teams,marketing manage.py test --keepdb --noinput
|
||||
- coverage xml
|
||||
- pytest
|
||||
- python-codacy-coverage -r coverage.xml
|
||||
|
|
|
|||
|
|
@ -173,16 +173,16 @@
|
|||
{% if each_account.contacts.all %}
|
||||
<a href="{% url 'accounts:create_mail' %}" class="btn btn-primary edit account_send_mail"
|
||||
data-account="{{each_account.id}}" data-account-email="{{each_account.email}}"
|
||||
data-toggle="modal" data-target="#send_email_to_contacts"><i
|
||||
class="fas fa-paper-plane"></i>
|
||||
data-toggle="modal" data-target="#send_email_to_contacts" title="Send Mail"><i
|
||||
class="fas fa-paper-plane" ></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="{% url 'accounts:view_account' each_account.id %}" class="btn btn-info edit"><i
|
||||
<a href="{% url 'accounts:view_account' each_account.id %}" class="btn btn-info edit" title="View"><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'accounts:edit_account' each_account.id %}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'accounts:edit_account' each_account.id %}" class="btn btn-success edit" title="Edit"><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'accounts:remove_account' each_account.id %}"
|
||||
class="btn btn-danger delete remove_account"><i class="fas fa-trash-alt"></i></a>
|
||||
class="btn btn-danger delete remove_account" title="Delete"><i class="fas fa-trash-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
@ -269,12 +269,12 @@
|
|||
{% endwith %}
|
||||
</td>
|
||||
<td class="actions">
|
||||
<a href="{% url 'accounts:view_account' each_account.id %}" class="btn btn-info edit"><i
|
||||
<a href="{% url 'accounts:view_account' each_account.id %}" class="btn btn-info edit" title="View"><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'accounts:edit_account' each_account.id %}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'accounts:edit_account' each_account.id %}" class="btn btn-success edit" title="Edit" ><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'accounts:remove_account' each_account.id %}"
|
||||
class="btn btn-danger delete remove_account"><i class="fas fa-trash-alt"></i></a>
|
||||
class="btn btn-danger delete remove_account" title="Delete" ><i class="fas fa-trash-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
|||
34
accounts/tests_celery_tasks.py
Normal file
34
accounts/tests_celery_tasks.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from accounts.models import Email
|
||||
from accounts.tasks import (send_email, send_email_to_assigned_user,
|
||||
send_scheduled_emails)
|
||||
from accounts.tests import AccountCreateTest
|
||||
|
||||
|
||||
class TestCeleryTasks(AccountCreateTest, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_celery_tasks(self):
|
||||
email_scheduled = Email.objects.create(
|
||||
message_subject='message subject', message_body='message body',
|
||||
scheduled_later=True, timezone='Asia/Kolkata',
|
||||
from_account=self.account,
|
||||
scheduled_date_time=(datetime.now() - timedelta(minutes=5)),
|
||||
from_email='from@email.com'
|
||||
)
|
||||
email_scheduled.recipients.add(self.contact.id, self.contact_user1.id)
|
||||
task = send_scheduled_emails.apply()
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = send_email.apply((email_scheduled.id,))
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = send_email_to_assigned_user.apply(
|
||||
([self.user.id, self.user1.id, ], self.account.id,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
|
@ -137,15 +137,15 @@
|
|||
<td>{{ case.priority }}</td>
|
||||
<td title="{{ case.created_on }}">{{ case.created_on_arrow }}</td>
|
||||
<td class="actions">
|
||||
<a href="{% url 'cases:view_case' case.id %}" class="btn btn-info view"><i
|
||||
<a href="{% url 'cases:view_case' case.id %}" class="btn btn-info view" title="View" ><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'cases:edit_case' case.id %}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'cases:edit_case' case.id %}" class="btn btn-success edit" title="Edit" ><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
{% if request.user == case.created_by or request.user.role == "ADMIN" or request.user.is_superuser %}
|
||||
<a href="{% url 'cases:remove_case' case.id %}" class="btn btn-danger delete remove_case"><i
|
||||
<a href="{% url 'cases:remove_case' case.id %}" class="btn btn-danger delete remove_case" title="Delete" ><i
|
||||
class="fas fa-trash-alt"></i></a>
|
||||
{% if case.status != 'Closed' %}
|
||||
<a onclick="close_case({{case.id}}, '{% url 'cases:close_case' %}')" class="btn btn-info"><i
|
||||
<a onclick="close_case({{case.id}}, '{% url 'cases:close_case' %}')" class="btn btn-info" title="Close"><i
|
||||
class="fas fa-times"></i> </a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
|
|
|||
16
cases/tests_celery_tasks.py
Normal file
16
cases/tests_celery_tasks.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from cases.tasks import send_email_to_assigned_user
|
||||
from cases.tests import CaseCreation
|
||||
|
||||
|
||||
class TestCeleryTasks(CaseCreation, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_celery_tasks(self):
|
||||
task = send_email_to_assigned_user.apply(
|
||||
([self.user.id, self.user1.id, ], self.case.id,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
|
@ -151,10 +151,23 @@
|
|||
</div>
|
||||
</div>
|
||||
<p style="color:red" id="forbiden_error"></p>
|
||||
{% comment %}
|
||||
{% if request.user.role == 'ADMIN' or request.user.is_superuser %}
|
||||
{% if request.user.id|slugify in request.path %}
|
||||
<h1>true</h1>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endcomment %}
|
||||
<div class="row marl buttons_row form_btn_row text-center">
|
||||
<button class="btn btn-default save" type="submit">Save</button>
|
||||
<a href="{% if not user_obj or request.user.is_superuser or request.user.role == 'ADMIN' %}{% url 'common:users_list' %}{% else %}{% url 'common:profile' %}{% endif %}"
|
||||
class="btn btn-default clear" id="create_user_cancel">Cancel</a>
|
||||
<a href="
|
||||
{% if request.META.HTTP_REFERER == request.scheme|add:'://'|add:request.get_host|add:'/profile/' %}
|
||||
{% url 'common:profile' %}
|
||||
{% elif not user_obj or request.user.is_superuser or request.user.role == 'ADMIN' %}
|
||||
{% url 'common:users_list' %}
|
||||
{% else %}
|
||||
{% url 'common:profile' %}
|
||||
{% endif %}" class="btn btn-default clear" id="create_user_cancel">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -232,15 +232,15 @@
|
|||
<span class="">
|
||||
<div class="actions">
|
||||
{% if request.user == document.created_by or request.user.role == 'ADMIN' %}
|
||||
<a href="{% url 'common:view_doc' document.id %}" class="view_icon"><i
|
||||
<a href="{% url 'common:view_doc' document.id %}" class="view_icon" title="View"><i
|
||||
class="fas fa-eye edit_delete_options"></i></a>
|
||||
<a href="{% url 'common:edit_doc' document.id %}" class="edit_icon"><i
|
||||
<a href="{% url 'common:edit_doc' document.id %}" class="edit_icon" title="Edit" ><i
|
||||
class="fas fa-pencil-alt edit_delete_options"></i></a>
|
||||
<a href="{% url 'common:remove_doc' document.id %}" class="delete_icon"><i
|
||||
<a href="{% url 'common:remove_doc' document.id %}" class="delete_icon" title="Delete" ><i
|
||||
class="fas fa-trash-alt edit_delete_options"></i></a>
|
||||
{% endif %}
|
||||
{% if request.user in document.shared_to.all or request.user == document.created_by or request.user.role == 'ADMIN' %}
|
||||
<a href="{% url 'common:download_document' document.id %}" class="download_icon"><i
|
||||
<a href="{% url 'common:download_document' document.id %}" class="download_icon" title="Download"><i
|
||||
class="fas fa-download edit_delete_options edit_delete_options"></i></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -75,6 +75,19 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">User Status</label>
|
||||
<select class="form-control" id="id_user_status" name="status">
|
||||
<option value="">--Select Status--</option>
|
||||
{% for value in status %}
|
||||
<option value="{{value.0}}" {% if request.POST.status %}
|
||||
{% ifequal value.0 request.POST.status %}selected{% endifequal %}{% endif %}>{{ value.1 }}
|
||||
</option>
|
||||
{% endfor%}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-lg-2">
|
||||
<div class="form-group buttons_row">
|
||||
<button class="btn btn-primary save" type="submit">Search</button>
|
||||
|
|
@ -184,7 +197,7 @@
|
|||
class="fas fa-trash-alt"></i>Delete</a>
|
||||
{% if user.email != admin_email and request.user != user %}
|
||||
<a style="color:black;margin-bottom: -11px;" data-id="{{user.id}}" href=""
|
||||
class="fa-passwd-reset fa-stack"><i class="fa fa-undo fa-stack-2x"></i><i
|
||||
class="fa-passwd-reset fa-stack" title="Change Password"><i class="fa fa-undo fa-stack-2x"></i><i
|
||||
class="fa fa-lock fa-stack-1x"></i></a>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -264,7 +277,7 @@
|
|||
class="fas fa-trash-alt"></i>Delete</a>
|
||||
{% if user.email != admin_email and request.user != user %}
|
||||
<a style="color:black;margin-bottom: -11px;" data-id="{{user.id}}" href=""
|
||||
class="fa-passwd-reset fa-stack"><i class="fa fa-undo fa-stack-2x"></i><i
|
||||
class="fa-passwd-reset fa-stack" title="Change Password"><i class="fa fa-undo fa-stack-2x"></i><i
|
||||
class="fa fa-lock fa-stack-1x"></i></a>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -296,6 +309,9 @@
|
|||
$(".filter_toggle").click(function () {
|
||||
$(".list_filter_row").toggle();
|
||||
});
|
||||
if ($('#id_user_status').val() === 'False') {
|
||||
$('#close-tab').click()
|
||||
}
|
||||
});
|
||||
|
||||
$('.trash').click(function (e) {
|
||||
|
|
|
|||
|
|
@ -1,90 +1,354 @@
|
|||
{% extends 'sales/base.html' %}
|
||||
{% load staticfiles %}
|
||||
{% load paginate %}
|
||||
{% load thumbnail %}
|
||||
{% block extralinks %}
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
|
||||
{% endblock extralinks %}
|
||||
{% block content %}
|
||||
|
||||
<!-- main_container starts here -->
|
||||
<div class="main_container">
|
||||
<!-- filter_row starts here -->
|
||||
<div class="row marl">
|
||||
<div class="col-lg-12 text-right">
|
||||
<span class="d-inline"><a href="{% url 'marketing:list_all_emails_for_campaigns' %}" class="btn primary_btn">Contacts</a></span>
|
||||
<span class="d-inline"><a href="{% url 'common:add_api_settings'%}" class="btn primary_btn"><i class="fa fa-plus"></i> Add New Setting</a></span>
|
||||
<span class="d-inline"><a href="{% url 'marketing:add_email_for_campaigns' %}" class="btn primary_btn"><i
|
||||
class="fa fa-plus"></i> Contacts</a></span>
|
||||
<span class="d-inline"><a href="{% url 'common:add_api_settings'%}" class="btn primary_btn"><i
|
||||
class="fa fa-plus"></i> Add New Setting</a></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- filter_row ends here -->
|
||||
<div class="table_container_row row marl">
|
||||
<!-- filter_row starts here -->
|
||||
|
||||
<!-- filter for settings -->
|
||||
<div class="filter_row list_filter_row row marl">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="card-title list text-right">
|
||||
<span class="float-left">Settings - {% if show_pageitems %} {% show_pageitems %}{% else %} {{ settings|length }}{% endif %}</span>
|
||||
<span class="filter_toggle">
|
||||
<a style="padding:0px 10px " href="#" class="primary_btn"></a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="table-responsive ">
|
||||
<table class="table table-bordered table-striped table-condensed">
|
||||
<thead>
|
||||
{% if settings|length > 0 %}
|
||||
<tr>
|
||||
<th width="20%">Title</th>
|
||||
<!-- <th width="20%">API Key</th> -->
|
||||
<th width="30%">Assign To</th>
|
||||
<th width="15%">User</th>
|
||||
<th width="10%">Actions</th>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if per_page %}
|
||||
{% paginate per_page settings %}
|
||||
{% else %}
|
||||
{% paginate 10 settings %}
|
||||
{% endif %}
|
||||
{% for setting in settings %}
|
||||
<tr class="text-center">
|
||||
<td><a href="{% url 'common:view_api_settings' setting.id %}">{{ setting.title }}</a></td>
|
||||
<!-- <td>{{ setting.apikey }}</td> -->
|
||||
<td>
|
||||
{% for user in setting.lead_assigned_to.all %}
|
||||
{{user.email}}{% if forloop.counter < setting.lead_assigned_to.all|length %}, {% endif %}
|
||||
{% empty %}
|
||||
Not Assigned Yet!
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>{% if setting.created_by %}{{ setting.created_by.email }}{% else %}No user!{% endif %}</td>
|
||||
<td class="actions">
|
||||
<!-- <a href="{% url 'common:view_api_settings' setting.id %}" class="btn btn-info view"><i class="fas fa-eye"></i>View</a> -->
|
||||
<a href="{% url 'common:update_api_settings' setting.id %}" class="btn btn-success edit action"><i class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'common:delete_api_settings' setting.id %}" class="btn btn-danger trash action"><i class="fas fa-trash-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% ifequal settings|length 0 %}
|
||||
<h6 class="text-center">No Settings Found!</h6>
|
||||
{% endifequal %}
|
||||
<div class="marl row text-center">
|
||||
{% show_pages %}
|
||||
</div>
|
||||
<form id="settings_filter" method="POST" action="" class="filter_form">
|
||||
<div class="card-body">
|
||||
<div class="card-title">Filter Settings</div>
|
||||
<div class="row marl">
|
||||
<div class="filter_col col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Title</label>
|
||||
<input type="text" class="form-control" placeholder="API Title" name="title"
|
||||
value="{{request.POST.title}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-2">
|
||||
<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 created_by_users %}
|
||||
<option value="{{user.id}}" {% if user.id|slugify == request.POST.created_by %} selected=""
|
||||
{% endif %}>
|
||||
{{user.email}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="tab_status" id="tab_status">
|
||||
<input type="hidden" name="api_settings" id="tab_status" value="api_settings">
|
||||
<div class="filter_col col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Assigned Users</label>
|
||||
<select class="assigned_users form-control" name="assigned_to" multiple="multiple">
|
||||
{% for user in assigned_users %}
|
||||
<option value="{{user.id}}" {% if user.id in assignedto_list %} selected="" {% endif %}>
|
||||
{{user.email}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-lg-2">
|
||||
<div class="form-group buttons_row">
|
||||
<button class="btn btn-primary save" type="submit">Search</button>
|
||||
<a href="{% url 'common:api_settings' %}" class="btn btn-default clear">Clear</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- filter for settings -->
|
||||
|
||||
<!-- filter for contacts -->
|
||||
<div class="filter_row list_filter_row_contacts row marl">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form id="contacts_filter" method="POST" action="" class="filter_form">
|
||||
<div class="card-body">
|
||||
<div class="card-title">Filter Contacts</div>
|
||||
<div class="row marl">
|
||||
<div class="filter_col col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Name</label>
|
||||
<input type="text" class="form-control" name="contact_name" value="{{request.POST.contact_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" name="contact_email" value="{{request.POST.contact_email}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Created By</label>
|
||||
<select name="contact_created_by" id="created_by" class="assigned_users_ form-control">
|
||||
<option value="">
|
||||
------------------</option>
|
||||
{% for user in created_by_users %}
|
||||
<option value="{{user.id}}" {% if user.id|slugify == request.POST.contact_created_by %}
|
||||
selected="" {% endif %}>
|
||||
{{user.email}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="tab_status" id="tab_status">
|
||||
<input type="hidden" name="filter_contacts" id="tab_status" value="filter_contacts">
|
||||
<div class="filter_col col-lg-2">
|
||||
<div class="form-group buttons_row">
|
||||
<button class="btn btn-primary save" type="submit">Search</button>
|
||||
<a href="{% url 'common:api_settings' %}" class="btn btn-default clear">Clear</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- filter for contacts -->
|
||||
|
||||
<!-- filter_row ends 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="close"
|
||||
aria-selected="false">Contacts - {% if show_pageitems %}
|
||||
{% show_pageitems %}{% else %}
|
||||
{{ contacts|length }}{% endif %}</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="close-tab" data-toggle="tab" href="#close" role="tab" aria-controls="open"
|
||||
aria-selected="true">Settings - {% if show_pageitems %} {% show_pageitems %}{% else %}
|
||||
{{ settings|length }}{% endif %}</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="card-title text-right">
|
||||
<span class="float-left">Contacts - {% if show_pageitems %}
|
||||
{% show_pageitems %}{% else %}
|
||||
{{ contacts|length }}{% endif %}</span>
|
||||
<span class="filter_toggle_contacts">
|
||||
<a href="#" class="primary_btn"><i class="fas fa-filter"></i></a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table ">
|
||||
<thead>
|
||||
{% if contacts|length > 0 %}
|
||||
<tr>
|
||||
<th width="5%">ID</th>
|
||||
<th width="15%"> Name</th>
|
||||
<th width="15%">Email</th>
|
||||
<th width="15%">Created by</th>
|
||||
<th width="15%">Created On</th>
|
||||
<th width="10%">Actions</th>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if per_page %}
|
||||
{% paginate per_page contacts %}
|
||||
{% else %}
|
||||
{% paginate 10 contacts %}
|
||||
{% endif %}
|
||||
{% for contact in contacts %}
|
||||
<tr class="text-center">
|
||||
<td scope="row">{{ forloop.counter }}</td>
|
||||
<td>{{ contact.name }}</td>
|
||||
<td class="">
|
||||
{{contact.email}}
|
||||
</td>
|
||||
<td>
|
||||
{% if contact.created_by %}
|
||||
{% if contact.created_by.profile_pic %}
|
||||
{% thumbnail contact.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
|
||||
title="{{ contact.created_by }}" style="border-radius: 50%" />
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}"
|
||||
style="width: 40px;height: 40px;border-radius: 50%;" title="{{ contact.created_by }}" />
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}"
|
||||
style="width: 40px;height: 40px;border-radius: 50%;" title="{{ contact.created_by }}" />
|
||||
{% endif %}
|
||||
</td>
|
||||
<td title="{{ contact.created_on }}">{{ contact.created_on_arrow }}</td>
|
||||
<td class="actions">
|
||||
{% if request.user.role == 'ADMIN' or reques.user.is_superuser %}
|
||||
<a href="{% url 'marketing:edit_email_for_campaigns' contact.id %}"
|
||||
class="btn btn-success edit" title="Edit"><i class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'marketing:delete_email_for_campaigns' contact.id %}"
|
||||
class="btn btn-danger delete remove_document" title="Delete"><i class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{%ifequal contacts|length 0%}
|
||||
<h6 class="text-center">No Contacts Found</h6>
|
||||
{%endifequal%}
|
||||
<div class="marl row text-center">
|
||||
{% show_pages %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="close" role="tabpanel" aria-labelledby="close">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="card-title list text-right">
|
||||
<span class="float-left">Settings - {% if show_pageitems %} {% show_pageitems %}{% else %}
|
||||
{{ settings|length }}{% endif %}</span>
|
||||
<span class="filter_toggle">
|
||||
<a href="#" class="primary_btn"><i class="fas fa-filter"></i></a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="table-responsive ">
|
||||
<table class="table table-bordered ">
|
||||
<thead>
|
||||
{% if settings|length > 0 %}
|
||||
<tr>
|
||||
<th width="20%">Title</th>
|
||||
<!-- <th width="20%">API Key</th> -->
|
||||
<th width="30%">Assign To</th>
|
||||
<th width="15%">User</th>
|
||||
<th width="10%">Actions</th>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if per_page %}
|
||||
{% paginate per_page settings %}
|
||||
{% else %}
|
||||
{% paginate 10 settings %}
|
||||
{% endif %}
|
||||
{% for setting in settings %}
|
||||
<tr class="text-center">
|
||||
<td><a href="{% url 'common:view_api_settings' setting.id %}">{{ setting.title }}</a></td>
|
||||
<!-- <td>{{ setting.apikey }}</td> -->
|
||||
<td>
|
||||
<!-- {% for user in setting.lead_assigned_to.all %}
|
||||
{{user.email}}{% if forloop.counter < setting.lead_assigned_to.all|length %}, {% endif %}
|
||||
{% empty %}
|
||||
Not Assigned Yet!
|
||||
{% endfor %} -->
|
||||
{% with lead_users=setting.lead_assigned_to.all %}
|
||||
{% for user in lead_users %}
|
||||
{% if user.profile_pic %}
|
||||
{% thumbnail user.profile_pic "40x40" crop="center" as im %}
|
||||
<a href="{% url 'common:view_user' user.id %}">
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
|
||||
title="{{ user.email }}">
|
||||
</a>
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<a href="{% url 'common:view_user' user.id %}">
|
||||
<img src="{% static 'images/user.png' %}" title="{{ user.email }}" width="40" height="40">
|
||||
</a>
|
||||
{% endif %}
|
||||
{% empty %}
|
||||
None
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
<td>{% if setting.created_by %}{{ setting.created_by.email }}{% else %}No user!{% endif %}
|
||||
</td>
|
||||
<td class="actions">
|
||||
<!-- <a href="{% url 'common:view_api_settings' setting.id %}" class="btn btn-info view"><i class="fas fa-eye"></i>View</a> -->
|
||||
<a href="{% url 'common:update_api_settings' setting.id %}"
|
||||
class="btn btn-success edit action" title="Edit"><i class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'common:delete_api_settings' setting.id %}"
|
||||
class="btn btn-danger trash action" title="Delete"><i class="fas fa-trash-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% ifequal settings|length 0 %}
|
||||
<h6 class="text-center">No Settings Found!</h6>
|
||||
{% endifequal %}
|
||||
<div class="marl row text-center">
|
||||
{% show_pages %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br clear="all">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- main_container ends here -->
|
||||
{% endblock %}
|
||||
{% block js_block %}
|
||||
<script type="text/javascript">
|
||||
$('.trash').click(function(e){
|
||||
$('.trash').click(function (e) {
|
||||
e.preventDefault()
|
||||
url = $(this).attr('href')
|
||||
if (!confirm('Are you sure you want to delete?'))
|
||||
return;
|
||||
window.location = $(this).attr('href')
|
||||
});
|
||||
</script>
|
||||
{% endblock js_block %}
|
||||
$('.assigned_users').select2();
|
||||
$(".list_filter_row_contacts").hide()
|
||||
$(".filter_toggle").click(function () {
|
||||
$(".list_filter_row").toggle();
|
||||
$(".list_filter_row_contacts").hide();
|
||||
});
|
||||
$(".filter_toggle_contacts").click(function () {
|
||||
$(".list_filter_row_contacts").toggle();
|
||||
$(".list_filter_row").hide();
|
||||
|
||||
});
|
||||
|
||||
$("#close a[rel='page']").click(function (e) {
|
||||
e.preventDefault();
|
||||
$('#settings_filter').attr("action", $(this).attr("href"));
|
||||
$('#settings_filter').submit();
|
||||
});
|
||||
|
||||
$("#open a[rel='page']").click(function (e) {
|
||||
e.preventDefault();
|
||||
$('#contacts_filter').attr("action", $(this).attr("href"));
|
||||
$('#contacts_filter').submit();
|
||||
});
|
||||
</script>
|
||||
{% endblock js_block %}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
{% load thumbnail %}
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{% url 'common:users_list' %}">Users</a></li>
|
||||
<li class="breadcrumb-item"><a href="{% url 'common:users_list' %}">Users</a></li>
|
||||
<li class="active breadcrumb-item">{{user_obj.username}}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
|
@ -18,14 +18,14 @@
|
|||
<div class="card">
|
||||
<div class="card-body" id="datashow">
|
||||
<div class="card-title text-right">
|
||||
<h5 >
|
||||
<h5>
|
||||
<span class="float-left title">Overview</span>
|
||||
<span class="" style="margin-top: 0px">
|
||||
<div class="dropdown buttons_row">
|
||||
<button class="btn primary_btn dropdown-toggle " type="button" data-toggle="dropdown">Actions
|
||||
<span class="caret"></span></button>
|
||||
<span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{% url 'common:edit_user' user_obj.id %}" >Edit</a></li>
|
||||
<li><a href="{% url 'common:edit_user' user_obj.id %}">Edit</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</span>
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
<div class="col-md-6">
|
||||
{% if user_obj.first_name %}
|
||||
<div class="filter_col col-md-12" id="iname">
|
||||
<div class="form-group" >
|
||||
<div class="form-group">
|
||||
<label class="acc_field_label" for="id_name" data-name="name">First Name</label>
|
||||
<div class="account_field" id="account_name" data-name="name">{{ user_obj.first_name }}</div>
|
||||
</div>
|
||||
|
|
@ -69,7 +69,7 @@
|
|||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="acc_field_label" for="id_industry" data-name="name">Role</label>
|
||||
<div class="account_field" id ="account_industry" data-name="name">{{ user_obj.role }}</div>
|
||||
<div class="account_field" id="account_industry" data-name="name">{{ user_obj.role }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
@ -89,6 +89,18 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% with teams=user_obj.user_teams.all %}
|
||||
{% if teams %}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="acc_field_label" for="id_industry" data-name="name">Teams</label>
|
||||
{% for team in teams %}
|
||||
<div class="account_field" id="account_industry" data-name="name">{{ team }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -106,11 +118,13 @@
|
|||
<div class="col-md-12">
|
||||
<form id="comment_form" method="POST" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<textarea class="form-control" textarea cols="40" rows="3" id="id_comments" name="comment" placeholder="Submit Your Comments Here"></textarea>
|
||||
<textarea class="form-control" textarea cols="40" rows="3" id="id_comments" name="comment"
|
||||
placeholder="Submit Your Comments Here"></textarea>
|
||||
<div><i id="CommentError" style="display:none; color:red"></i></div>
|
||||
</br>
|
||||
<div class="buttons_row">
|
||||
<button class="btn btn-default save" style="text-align: center;" id="comment_submit" type="submit">Submit</button>
|
||||
<button class="btn btn-default save" style="text-align: center;" id="comment_submit"
|
||||
type="submit">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" value="{{ user_obj.id }}" name="userid">
|
||||
|
|
@ -120,10 +134,12 @@
|
|||
<li class="list-group-item list-row" id="comment{{comment.id}}">
|
||||
{% if request.user.is_superuser or request.user.role == 'ADMIN' or request.user == comment.commented_by %}
|
||||
<div class="list-row-buttons btn-group float-right">
|
||||
<button class="btn primary_btn btn-sm dropdown-toggle" data-toggle="dropdown" type="button">Actions<span class="caret"></span></button>
|
||||
<button class="btn primary_btn btn-sm dropdown-toggle" data-toggle="dropdown"
|
||||
type="button">Actions<span class="caret"></span></button>
|
||||
<ul class="dropdown-menu text-center comment_actions">
|
||||
<li>
|
||||
<a class="action edit_comment" onclick="edit_comment({{comment.id}})" id="{% url 'common:edit_comment' comment.id %}">Edit</a>
|
||||
<a class="action edit_comment" onclick="edit_comment({{comment.id}})"
|
||||
id="{% url 'common:edit_comment' comment.id %}">Edit</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="action remove_comment" onclick="remove_comment({{comment.id}})">Remove</a>
|
||||
|
|
@ -143,17 +159,20 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="Comments_Accounts_Modal" role="dialog" data-keyboard="false" data-backdrop="static">
|
||||
<div class="modal fade" id="Comments_Accounts_Modal" role="dialog" data-keyboard="false"
|
||||
data-backdrop="static">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Update Your Comment</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
|
||||
</div>
|
||||
<form id="comment_edit_form" method="POST" >
|
||||
<form id="comment_edit_form" method="POST">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<textarea class="form-control" textarea cols="40" rows="3" id="id_editcomment" name="comment" placeholder="Submit Your Comments"></textarea><span><i id="CommentEditError" style="display:none; color:red"></i></span>
|
||||
<textarea class="form-control" textarea cols="40" rows="3" id="id_editcomment" name="comment"
|
||||
placeholder="Submit Your Comments"></textarea><span><i id="CommentEditError"
|
||||
style="display:none; color:red"></i></span>
|
||||
<input type="hidden" value="{{ user_obj.id }}" name="accountid">
|
||||
<input type="hidden" value="" name="commentid" id="commentid">
|
||||
</div>
|
||||
|
|
@ -182,10 +201,10 @@
|
|||
{% if accounts|length > 0 %}
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%" >S.No</th>
|
||||
<th width="25%" >Account Name</th>
|
||||
<th width="20%" >Phone</th>
|
||||
<th width="25%" >Email</th>
|
||||
<th width="5%">S.No</th>
|
||||
<th width="25%">Account Name</th>
|
||||
<th width="20%">Phone</th>
|
||||
<th width="25%">Email</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% endif %}
|
||||
|
|
@ -223,10 +242,10 @@
|
|||
{% if contacts|length > 0 %}
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%" >S.No</th>
|
||||
<th width="25%" >Contact Name</th>
|
||||
<th width="20%" >Phone</th>
|
||||
<th width="25%" >Email</th>
|
||||
<th width="5%">S.No</th>
|
||||
<th width="25%">Contact Name</th>
|
||||
<th width="20%">Phone</th>
|
||||
<th width="25%">Email</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% endif %}
|
||||
|
|
@ -234,7 +253,8 @@
|
|||
{% for contact in contacts %}
|
||||
<tr id="contacts_details{{contact.id}}" class="text-center">
|
||||
<td scope="row">{{ forloop.counter }}</td>
|
||||
<td><a href="{% url 'contacts:view_contact' contact.id %}">{{ contact.first_name }} {{ contact.last_name }}</a></td>
|
||||
<td><a href="{% url 'contacts:view_contact' contact.id %}">{{ contact.first_name }}
|
||||
{{ contact.last_name }}</a></td>
|
||||
<td>{{ contact.phone }}</td>
|
||||
<td>{{ contact.email }}</td>
|
||||
</tr>
|
||||
|
|
@ -341,108 +361,108 @@
|
|||
{% block js_block %}
|
||||
<script type="text/javascript">
|
||||
var assigned_to_list = "{{ assigned_data }}";
|
||||
assigned_to_list = JSON.parse(assigned_to_list.replace(/&(l|g|quo)t;/g, function(a,b){
|
||||
return {
|
||||
l : '<',
|
||||
g : '>',
|
||||
quo : '"'
|
||||
}[b];
|
||||
}));
|
||||
|
||||
/*Comment Add Js Start*/
|
||||
$("#comment_form").submit(function(e){
|
||||
e.preventDefault()
|
||||
var formData = new FormData($("#comment_form")[0]);
|
||||
$.ajax({
|
||||
url : "{% url 'common:add_comment' %}",
|
||||
type : "POST",
|
||||
data : formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function(data){
|
||||
if(data.error){
|
||||
for (var key in data.error) {
|
||||
$("#CommentError").html(data.error[key]).show()
|
||||
}
|
||||
} else {
|
||||
d = new Date(data.commented_on);
|
||||
$("#comments_div").prepend("<li class='list-group-item list-row' id='comment"+data.comment_id+"'>"+
|
||||
"<div class='float-right right-container'>"+
|
||||
"<div class='list-row-buttons btn-group float-right'>"+
|
||||
"<button class='btn primary_btn btn-sm dropdown-toggle' data-toggle='dropdown' type='button'><span class='caret'></span>Actions</button>"+
|
||||
"<ul class='dropdown-menu text-center'>"+
|
||||
"<li><a class='action' onclick='edit_comment("+data.comment_id+")'>Edit</a></li>"+
|
||||
"<li><a class='action' onclick='remove_comment("+data.comment_id+")''>Remove</a></li></ul></div></div>"+
|
||||
"<div class='stream-post-container' id='comment_name"+data.comment_id+"'><pre>"+data.comment+"</pre></div>"+
|
||||
"<div class='stream-container'><pre class='float-left'>"+data.commented_by+"</pre><pre class='float-right'>"+d.toLocaleString('en-US', { hour12: true })+"</pre></div>"
|
||||
)
|
||||
$("#id_comments").val("")
|
||||
alert("Comment Submitted")
|
||||
$("#CommentError").html("")
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function edit_comment(x) {
|
||||
$('#Comments_Accounts_Modal').modal('show');
|
||||
comment = $("#comment_name" + x).text()
|
||||
$("#commentid").val(x)
|
||||
$("#id_editcomment").val(comment)
|
||||
$("#edit_file_field").html($("#comment_file_div" + x).clone())
|
||||
}
|
||||
|
||||
$("#comment_edit").click(function (e) {
|
||||
e.preventDefault()
|
||||
var formData = new FormData($("#comment_edit_form")[0]);
|
||||
var commentid = $("#commentid").val()
|
||||
$.ajax({
|
||||
url: "{% url 'common:edit_comment' 123456 %}".replace(123456, commentid),
|
||||
type: "POST",
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
if (data.error) {
|
||||
$("#CommentEditError").html(data.error).show()
|
||||
} else {
|
||||
console.log($("#comment_name" + data.comment_id))
|
||||
$("#comment_name" + data.comment_id).html('<pre>' + data.comment + '</pre>')
|
||||
$('#Comments_Accounts_Modal').modal('hide');
|
||||
$("#id_editcomment").val("")
|
||||
$("#CommentEditError").html('')
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/*Comment Edit Js Ends*/
|
||||
|
||||
function HideError(e) {
|
||||
$("#CommentError").hide()
|
||||
$("#CommentEditError").hide()
|
||||
}
|
||||
|
||||
/*Comment Remove Js Start*/
|
||||
|
||||
function remove_comment(x) {
|
||||
var con = confirm("Do you want to Delete it for Sure!?")
|
||||
if (con == true) {
|
||||
$.post('{% url "common:remove_comment" %}', {
|
||||
"comment_id": x
|
||||
}, function (data) {
|
||||
if (data.error) {
|
||||
alert(data.error)
|
||||
} else {
|
||||
$("#comment" + data.cid).remove()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
assigned_to_list = JSON.parse(assigned_to_list.replace(/&(l|g|quo)t;/g, function (a, b) {
|
||||
return {
|
||||
l: '<',
|
||||
g: '>',
|
||||
quo: '"'
|
||||
}[b];
|
||||
}));
|
||||
|
||||
/*Comment Add Js Start*/
|
||||
$("#comment_form").submit(function (e) {
|
||||
e.preventDefault()
|
||||
var formData = new FormData($("#comment_form")[0]);
|
||||
$.ajax({
|
||||
url: "{% url 'common:add_comment' %}",
|
||||
type: "POST",
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
if (data.error) {
|
||||
for (var key in data.error) {
|
||||
$("#CommentError").html(data.error[key]).show()
|
||||
}
|
||||
} else {
|
||||
d = new Date(data.commented_on);
|
||||
$("#comments_div").prepend("<li class='list-group-item list-row' id='comment" + data.comment_id + "'>" +
|
||||
"<div class='float-right right-container'>" +
|
||||
"<div class='list-row-buttons btn-group float-right'>" +
|
||||
"<button class='btn primary_btn btn-sm dropdown-toggle' data-toggle='dropdown' type='button'><span class='caret'></span>Actions</button>" +
|
||||
"<ul class='dropdown-menu text-center'>" +
|
||||
"<li><a class='action' onclick='edit_comment(" + data.comment_id + ")'>Edit</a></li>" +
|
||||
"<li><a class='action' onclick='remove_comment(" + data.comment_id + ")''>Remove</a></li></ul></div></div>" +
|
||||
"<div class='stream-post-container' id='comment_name" + data.comment_id + "'><pre>" + data.comment + "</pre></div>" +
|
||||
"<div class='stream-container'><pre class='float-left'>" + data.commented_by + "</pre><pre class='float-right'>" + d.toLocaleString('en-US', { hour12: true }) + "</pre></div>"
|
||||
)
|
||||
$("#id_comments").val("")
|
||||
alert("Comment Submitted")
|
||||
$("#CommentError").html("")
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function edit_comment(x) {
|
||||
$('#Comments_Accounts_Modal').modal('show');
|
||||
comment = $("#comment_name" + x).text()
|
||||
$("#commentid").val(x)
|
||||
$("#id_editcomment").val(comment)
|
||||
$("#edit_file_field").html($("#comment_file_div" + x).clone())
|
||||
}
|
||||
|
||||
$("#comment_edit").click(function (e) {
|
||||
e.preventDefault()
|
||||
var formData = new FormData($("#comment_edit_form")[0]);
|
||||
var commentid = $("#commentid").val()
|
||||
$.ajax({
|
||||
url: "{% url 'common:edit_comment' 123456 %}".replace(123456, commentid),
|
||||
type: "POST",
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
if (data.error) {
|
||||
$("#CommentEditError").html(data.error).show()
|
||||
} else {
|
||||
console.log($("#comment_name" + data.comment_id))
|
||||
$("#comment_name" + data.comment_id).html('<pre>' + data.comment + '</pre>')
|
||||
$('#Comments_Accounts_Modal').modal('hide');
|
||||
$("#id_editcomment").val("")
|
||||
$("#CommentEditError").html('')
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/*Comment Edit Js Ends*/
|
||||
|
||||
function HideError(e) {
|
||||
$("#CommentError").hide()
|
||||
$("#CommentEditError").hide()
|
||||
}
|
||||
|
||||
/*Comment Remove Js Start*/
|
||||
|
||||
function remove_comment(x) {
|
||||
var con = confirm("Do you want to Delete it for Sure!?")
|
||||
if (con == true) {
|
||||
$.post('{% url "common:remove_comment" %}', {
|
||||
"comment_id": x
|
||||
}, function (data) {
|
||||
if (data.error) {
|
||||
alert(data.error)
|
||||
} else {
|
||||
$("#comment" + data.cid).remove()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<script src="{% static 'js/mention.js' %}"></script>
|
||||
{% endblock js_block %}
|
||||
|
|
@ -237,7 +237,7 @@ class UserListTestCase(ObjectsCreation, TestCase):
|
|||
def test_users_list_queryset(self):
|
||||
self.user = User.objects.all()
|
||||
data = {'first_name': 'john', 'username': 'johndoeAdmin',
|
||||
'email': 'johndoe@admin.com'}
|
||||
'email': 'johndoe@admin.com', 'role':'ADMIN', 'status':'True'}
|
||||
response = self.client.post('/users/list/', data)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'list.html')
|
||||
|
|
|
|||
223
common/tests_celery_tasks.py
Normal file
223
common/tests_celery_tasks.py
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from accounts.tests import AccountCreateTest
|
||||
from cases.tests import CaseCreation
|
||||
from common.models import User, Comment
|
||||
from common.tasks import (resend_activation_link_to_user,
|
||||
send_email_to_new_user, send_email_user_delete,
|
||||
send_email_user_mentions, send_email_user_status)
|
||||
from common.tests import ObjectsCreation
|
||||
from contacts.tests import ContactObjectsCreation
|
||||
from events.tests import EventObjectTest
|
||||
from invoices.tests import InvoiceCreateTest
|
||||
from leads.tests import TestLeadModel
|
||||
from opportunity.tests import OpportunityModel
|
||||
from tasks.tests import TaskCreateTest
|
||||
|
||||
|
||||
class TestCeleryTasks(ObjectsCreation, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_celery_tasks(self):
|
||||
task = send_email_to_new_user.apply((
|
||||
self.user1.email, self.user.email,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = send_email_user_status.apply((
|
||||
self.user1.id, self.user.id,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
self.user1.is_active = False
|
||||
self.user1.has_sales_access = False
|
||||
self.user1.has_marketing_access = True
|
||||
self.user1.save()
|
||||
|
||||
task = send_email_user_status.apply((
|
||||
self.user1.id,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
self.user1.is_active = True
|
||||
self.user1.has_sales_access = False
|
||||
self.user1.has_marketing_access = False
|
||||
self.user1.save()
|
||||
|
||||
task = send_email_user_status.apply((
|
||||
self.user1.id,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = send_email_user_delete.apply((
|
||||
self.user1.email,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = resend_activation_link_to_user.apply((
|
||||
self.user1.email,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = resend_activation_link_to_user.apply((
|
||||
self.user1.email,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
|
||||
class TestUserMentionsForAccountComments(AccountCreateTest, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_user_mentions_for_account_comment(self):
|
||||
self.user_comment = User.objects.create(
|
||||
first_name="johnComment", username='johnDoeComment', email='johnDoeComment@example.com', role='ADMIN')
|
||||
self.user_comment.set_password('password')
|
||||
self.user_comment.save()
|
||||
|
||||
self.comment.comment = 'content @{}'.format(self.user_comment.username)
|
||||
self.comment.account = self.account
|
||||
self.comment.save()
|
||||
|
||||
task = send_email_user_mentions.apply((
|
||||
self.comment.id, 'accounts',),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
|
||||
class TestUserMentionsForContactsComments(ContactObjectsCreation, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_user_mentions_for_contacts_comments(self):
|
||||
self.user_comment = User.objects.create(
|
||||
first_name="johnComment", username='johnDoeComment', email='johnDoeComment@example.com', role='ADMIN')
|
||||
self.user_comment.set_password('password')
|
||||
self.user_comment.save()
|
||||
|
||||
self.comment.comment = 'content @{}'.format(self.user_comment.username)
|
||||
self.comment.contact = self.contact
|
||||
self.comment.save()
|
||||
|
||||
task = send_email_user_mentions.apply((
|
||||
self.comment.id, 'contacts',),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
|
||||
class TestUserMentionsForLeadsComments(TestLeadModel, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_user_mentions_for_leads_comments(self):
|
||||
self.user_comment = User.objects.create(
|
||||
first_name="johnComment", username='johnDoeComment', email='johnDoeComment@example.com', role='ADMIN')
|
||||
self.user_comment.set_password('password')
|
||||
self.user_comment.save()
|
||||
|
||||
self.comment.comment = 'content @{}'.format(self.user_comment.username)
|
||||
self.comment.lead = self.lead
|
||||
self.comment.save()
|
||||
|
||||
task = send_email_user_mentions.apply((
|
||||
self.comment.id, 'leads',),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
|
||||
class TestUserMentionsForOpportunityComments(OpportunityModel, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_user_mentions_for_opportunity_comments(self):
|
||||
self.user_comment = User.objects.create(
|
||||
first_name="johnComment", username='johnDoeComment', email='johnDoeComment@example.com', role='ADMIN')
|
||||
self.user_comment.set_password('password')
|
||||
self.user_comment.save()
|
||||
|
||||
self.comment.comment = 'content @{}'.format(self.user_comment.username)
|
||||
self.comment.opportunity = self.opportunity
|
||||
self.comment.save()
|
||||
|
||||
task = send_email_user_mentions.apply((
|
||||
self.comment.id, 'opportunity',),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
|
||||
class TestUserMentionsForCasesComments(CaseCreation, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_user_mentions_for_cases_comments(self):
|
||||
self.user_comment = User.objects.create(
|
||||
first_name="johnComment", username='johnDoeComment', email='johnDoeComment@example.com', role='ADMIN')
|
||||
self.user_comment.set_password('password')
|
||||
self.user_comment.save()
|
||||
|
||||
self.comment.comment = 'content @{}'.format(self.user_comment.username)
|
||||
self.comment.case = self.case
|
||||
self.comment.save()
|
||||
|
||||
task = send_email_user_mentions.apply((
|
||||
self.comment.id, 'cases',),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
|
||||
class TestUserMentionsForTasksComments(TaskCreateTest, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_user_mentions_for_tasks_comments(self):
|
||||
self.user_comment = User.objects.create(
|
||||
first_name="johnComment", username='johnDoeComment', email='johnDoeComment@example.com', role='ADMIN')
|
||||
self.user_comment.set_password('password')
|
||||
self.user_comment.save()
|
||||
|
||||
self.comment.comment = 'content @{}'.format(self.user_comment.username)
|
||||
self.comment.task = self.task
|
||||
self.comment.save()
|
||||
|
||||
task = send_email_user_mentions.apply((
|
||||
self.comment.id, 'tasks',),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
|
||||
class TestUserMentionsForInvoiceComments(InvoiceCreateTest, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_user_mentions_for_invoice_comments(self):
|
||||
self.user_comment = User.objects.create(
|
||||
first_name="johnComment", username='johnDoeComment', email='johnDoeComment@example.com', role='ADMIN')
|
||||
self.user_comment.set_password('password')
|
||||
self.user_comment.save()
|
||||
|
||||
self.comment.comment = 'content @{}'.format(self.user_comment.username)
|
||||
self.comment.invoice = self.invoice
|
||||
self.comment.save()
|
||||
|
||||
task = send_email_user_mentions.apply((
|
||||
self.comment.id, 'invoices',),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
|
||||
class TestUserMentionsForEventsComments(EventObjectTest, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_user_mentions_for_events_comments(self):
|
||||
self.user_comment = User.objects.create(
|
||||
first_name="johnComment", username='johnDoeComment', email='johnDoeComment@example.com', role='ADMIN')
|
||||
self.user_comment.set_password('password')
|
||||
self.user_comment.save()
|
||||
|
||||
self.comment.comment = 'content @{}'.format(self.user_comment.username)
|
||||
self.comment.event = self.event
|
||||
self.comment.save()
|
||||
|
||||
task = send_email_user_mentions.apply((
|
||||
self.comment.id, 'events',),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
145
common/views.py
145
common/views.py
|
|
@ -1,53 +1,49 @@
|
|||
import os
|
||||
import json
|
||||
import requests
|
||||
import datetime
|
||||
from django.contrib.auth import logout, authenticate, login
|
||||
from django.db.models import Q
|
||||
from django.core.mail import EmailMessage
|
||||
from django.contrib.auth.hashers import check_password
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin, AccessMixin
|
||||
from django.http import (HttpResponseRedirect,
|
||||
JsonResponse, HttpResponse,
|
||||
Http404)
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.views.generic import (
|
||||
CreateView, UpdateView, DetailView, TemplateView, View, DeleteView)
|
||||
from common.models import (User, Document, Attachments,
|
||||
Comment,
|
||||
APISettings,
|
||||
Google, Profile)
|
||||
from common.forms import (
|
||||
UserForm, LoginForm,
|
||||
ChangePasswordForm, PasswordResetEmailForm,
|
||||
DocumentForm, UserCommentForm,
|
||||
APISettingsForm
|
||||
)
|
||||
from django.contrib.auth.views import PasswordResetView
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.urls import reverse_lazy, reverse
|
||||
from django.conf import settings
|
||||
from opportunity.models import Opportunity
|
||||
from cases.models import Case
|
||||
from contacts.models import Contact
|
||||
from accounts.models import Account, Tags
|
||||
from leads.models import Lead
|
||||
from django.template.loader import render_to_string
|
||||
from django.core.exceptions import PermissionDenied
|
||||
import json
|
||||
import os
|
||||
|
||||
import boto3
|
||||
import botocore
|
||||
|
||||
from common.utils import ROLES
|
||||
from common.tasks import send_email_user_status, send_email_user_delete, send_email_to_new_user, resend_activation_link_to_user
|
||||
from teams.models import Teams
|
||||
from common.access_decorators_mixins import (
|
||||
sales_access_required, marketing_access_required, SalesAccessRequiredMixin, MarketingAccessRequiredMixin)
|
||||
from common.token_generator import account_activation_token
|
||||
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
from django.utils import timezone
|
||||
import requests
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.hashers import check_password
|
||||
from django.contrib.auth.mixins import AccessMixin, LoginRequiredMixin
|
||||
from django.contrib.auth.views import PasswordResetView
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.mail import EmailMessage
|
||||
from django.db.models import Q
|
||||
from django.http import (Http404, HttpResponse, HttpResponseRedirect,
|
||||
JsonResponse)
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.template.loader import render_to_string
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.utils import timezone
|
||||
from django.utils.encoding import force_bytes, force_text
|
||||
from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode
|
||||
from django.views.generic import (CreateView, DeleteView, DetailView,
|
||||
TemplateView, UpdateView, View)
|
||||
|
||||
from accounts.models import Account, Tags
|
||||
from cases.models import Case
|
||||
from common.access_decorators_mixins import (MarketingAccessRequiredMixin,
|
||||
SalesAccessRequiredMixin, marketing_access_required, sales_access_required)
|
||||
from common.forms import (APISettingsForm, ChangePasswordForm, DocumentForm,
|
||||
LoginForm, PasswordResetEmailForm, UserCommentForm, UserForm)
|
||||
from common.models import (APISettings, Attachments, Comment, Document, Google,
|
||||
Profile, User)
|
||||
from common.tasks import (resend_activation_link_to_user,
|
||||
send_email_to_new_user, send_email_user_delete, send_email_user_status)
|
||||
from common.token_generator import account_activation_token
|
||||
from common.utils import ROLES
|
||||
from contacts.models import Contact
|
||||
from leads.models import Lead
|
||||
from opportunity.models import Opportunity
|
||||
from teams.models import Teams
|
||||
from marketing.models import ContactEmailCampaign
|
||||
|
||||
|
||||
def handler404(request, exception):
|
||||
|
|
@ -167,7 +163,6 @@ class LoginView(TemplateView):
|
|||
if user.is_active:
|
||||
user = authenticate(username=request.POST.get(
|
||||
'email'), password=request.POST.get('password'))
|
||||
|
||||
if user is not None:
|
||||
login(request, user)
|
||||
if user.has_sales_access:
|
||||
|
|
@ -243,6 +238,9 @@ class UsersListView(AdminRequiredMixin, TemplateView):
|
|||
if request_post.get('role'):
|
||||
queryset = queryset.filter(
|
||||
role=request_post.get('role'))
|
||||
if request_post.get('status'):
|
||||
queryset = queryset.filter(
|
||||
is_active=request_post.get('status'))
|
||||
|
||||
return queryset.order_by('username')
|
||||
|
||||
|
|
@ -255,6 +253,7 @@ class UsersListView(AdminRequiredMixin, TemplateView):
|
|||
context["per_page"] = self.request.POST.get('per_page')
|
||||
context['admin_email'] = settings.ADMIN_EMAIL
|
||||
context['roles'] = ROLES
|
||||
context['status'] = [('True', 'Active'), ('False', 'In Active')]
|
||||
return context
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
|
@ -663,7 +662,7 @@ def download_document(request, pk):
|
|||
raise Http404
|
||||
|
||||
|
||||
def download_attachment(request, pk):
|
||||
def download_attachment(request, pk): # pragma: no cover
|
||||
attachment_obj = Attachments.objects.filter(id=pk).last()
|
||||
if attachment_obj:
|
||||
if settings.STORAGE_TYPE == "normal":
|
||||
|
|
@ -765,8 +764,41 @@ def remove_comment(request):
|
|||
|
||||
def api_settings(request):
|
||||
api_settings = APISettings.objects.all()
|
||||
data = {'settings': api_settings}
|
||||
return render(request, 'settings/list.html', data)
|
||||
contacts = ContactEmailCampaign.objects.all()
|
||||
created_by_users = User.objects.filter(role='ADMIN')
|
||||
assigned_users = User.objects.all()
|
||||
|
||||
context = {
|
||||
'settings': api_settings,
|
||||
'contacts': contacts,
|
||||
'created_by_users':created_by_users,
|
||||
'assigned_users':assigned_users,
|
||||
}
|
||||
|
||||
if request.method == 'POST':
|
||||
settings = api_settings
|
||||
if request.POST.get('api_settings', None):
|
||||
if request.POST.get('title', None):
|
||||
settings = settings.filter(title__icontains=request.POST.get('title', None))
|
||||
if request.POST.get('created_by', None):
|
||||
settings = settings.filter(created_by_id=request.POST.get('created_by', None))
|
||||
if request.POST.get('assigned_to', None):
|
||||
settings = settings.filter(lead_assigned_to__id__in=request.POST.getlist('assigned_to', None))
|
||||
|
||||
context['settings']= settings.distinct()
|
||||
|
||||
if request.POST.get('filter_contacts', None):
|
||||
contacts_filter = contacts
|
||||
if request.POST.get('contact_name', None):
|
||||
contacts_filter = contacts_filter.filter(name__icontains=request.POST.get('contact_name', None))
|
||||
if request.POST.get('contact_created_by', None):
|
||||
contacts_filter = contacts_filter.filter(created_by_id=request.POST.get('contact_created_by', None))
|
||||
if request.POST.get('contact_email', None):
|
||||
contacts_filter = contacts_filter.filter(email__icontains=request.POST.get('contact_email', None))
|
||||
|
||||
context['contacts']= contacts_filter.distinct()
|
||||
|
||||
return render(request, 'settings/list.html', context)
|
||||
|
||||
|
||||
def add_api_settings(request):
|
||||
|
|
@ -884,7 +916,7 @@ def change_passsword_by_admin(request):
|
|||
raise PermissionDenied
|
||||
|
||||
|
||||
def google_login(request):
|
||||
def google_login(request): # pragma: no cover
|
||||
if 'code' in request.GET:
|
||||
params = {
|
||||
'grant_type': 'authorization_code',
|
||||
|
|
@ -978,7 +1010,7 @@ def google_login(request):
|
|||
return HttpResponseRedirect(rty)
|
||||
|
||||
|
||||
def create_lead_from_site(request):
|
||||
def create_lead_from_site(request): # pragma: no cover
|
||||
allowed_domains = ['micropyramid.com', 'test.microsite.com:8000', ]
|
||||
# add origin_domain = request.get_host() in the post body
|
||||
if (request.get_host() in ['sales.micropyramid.com', ] and request.POST.get('origin_domain') in allowed_domains):
|
||||
|
|
@ -992,18 +1024,19 @@ def create_lead_from_site(request):
|
|||
lead.assigned_to.add(*recipients)
|
||||
from leads.tasks import send_email_to_assigned_user
|
||||
send_email_to_assigned_user(
|
||||
recipients, lead.id, domain='sales.micropyramid.com')
|
||||
recipients, lead.id, domain='sales.micropyramid.com',
|
||||
source=request.POST.get('origin_domain'))
|
||||
return HttpResponse('Lead Created')
|
||||
from django.http import HttpResponseBadRequest
|
||||
return HttpResponseBadRequest('Bad Request')
|
||||
|
||||
|
||||
def activate_user(request, uidb64, token, activation_key):
|
||||
def activate_user(request, uidb64, token, activation_key): # pragma: no cover
|
||||
profile = get_object_or_404(Profile, activation_key=activation_key)
|
||||
if profile.user:
|
||||
if timezone.now() > profile.key_expires:
|
||||
resend_url = reverse('common:resend_activation_link', args=(profile.user.id,))
|
||||
link_content = '<a href="{}">click here</a> to resend the activation link.'.format(
|
||||
link_content = '<a href="{}">Click Here</a> to resend the activation link.'.format(
|
||||
resend_url)
|
||||
message_content = 'Your activation link has expired, {}'.format(
|
||||
link_content)
|
||||
|
|
@ -1030,7 +1063,7 @@ def activate_user(request, uidb64, token, activation_key):
|
|||
return HttpResponse('Activation link is invalid!')
|
||||
|
||||
|
||||
def resend_activation_link(request, userId):
|
||||
def resend_activation_link(request, userId): # pragma: no cover
|
||||
user = get_object_or_404(User, pk=userId)
|
||||
kwargs = {'user_email': user.email, 'domain': request.get_host(), 'protocol': request.scheme}
|
||||
resend_activation_link_to_user.delay(**kwargs)
|
||||
|
|
|
|||
|
|
@ -144,13 +144,13 @@
|
|||
</td>
|
||||
<td title="{{contact.created_on}}">{{contact.created_on_arrow}}</td>
|
||||
<td class="actions">
|
||||
<a href="{% url 'contacts:view_contact' contact.id %}" class="btn btn-info view"><i
|
||||
<a href="{% url 'contacts:view_contact' contact.id %}" class="btn btn-info view" title="View" ><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'contacts:edit_contact' contact.id%}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'contacts:edit_contact' contact.id%}" class="btn btn-success edit" title="Edit"><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
{% if request.user == contact.created_by or request.user.role == "ADMIN" or request.user.is_superuser %}
|
||||
<a href="{% url 'contacts:remove_contact' contact.id %}"
|
||||
class="btn btn-danger delete remove_account"><i class="fas fa-trash-alt"></i></a>
|
||||
class="btn btn-danger delete remove_account" title="Delete" ><i class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
18
contacts/tests_celery_tasks.py
Normal file
18
contacts/tests_celery_tasks.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from contacts.tasks import send_email_to_assigned_user
|
||||
from contacts.tests import ContactObjectsCreation
|
||||
|
||||
|
||||
class TestCeleryTasks(ContactObjectsCreation, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_celery_tasks(self):
|
||||
task = send_email_to_assigned_user.apply(
|
||||
([self.user.id, self.user_contacts_mp.id, ], self.contact.id,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
|
@ -26,7 +26,7 @@ You have been invited to the following event {{event_name}} created by {{event_c
|
|||
{% block button_link %}
|
||||
<div style="margin-bottom:20px">
|
||||
<a href="{{url}}"
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">click
|
||||
here</a>
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">Click
|
||||
Here</a>
|
||||
</div>
|
||||
{% endblock button_link %}
|
||||
|
|
@ -202,12 +202,12 @@
|
|||
</td>
|
||||
<td class="actions">
|
||||
{% if request.user == event.created_by or request.user.role == 'ADMIN' %}
|
||||
<a href="{% url 'events:detail_view' event.id %}" class="btn btn-info edit"><i
|
||||
<a href="{% url 'events:detail_view' event.id %}" class="btn btn-info edit" title="View"><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'events:event_update' event.id %}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'events:event_update' event.id %}" class="btn btn-success edit" title="Edit"><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'events:event_delete' event.id %}"
|
||||
class="btn btn-danger delete remove_document"><i class="fas fa-trash-alt"></i></a>
|
||||
class="btn btn-danger delete remove_document" title="Delete"><i class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
15
events/tests_celery_tasks.py
Normal file
15
events/tests_celery_tasks.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from events.tasks import send_email
|
||||
from events.tests import EventObjectTest
|
||||
|
||||
|
||||
class TestEventCeleryTasks(EventObjectTest, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_event_celery_tasks(self):
|
||||
task = send_email.apply((self.event.id,))
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
|
@ -13,6 +13,6 @@ Hello {{ user }}
|
|||
{% block button_link %}
|
||||
<div style="margin-bottom:20px">
|
||||
<a href="{{url}}"
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">click here</a>
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">Click Here</a>
|
||||
</div>
|
||||
{% endblock button_link %}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@
|
|||
{% block button_link %}
|
||||
<div style="margin-bottom:20px">
|
||||
<a href="{{url}}"
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">click
|
||||
here</a>
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">Click
|
||||
Here</a>
|
||||
</div>
|
||||
{% endblock button_link %}
|
||||
{% endcomment %}
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
{% block button_link %}
|
||||
<div style="margin-bottom:20px">
|
||||
<a href="{{url}}"
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">click
|
||||
here</a>
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">Click
|
||||
Here</a>
|
||||
</div>
|
||||
{% endblock button_link %}
|
||||
|
|
@ -195,19 +195,19 @@
|
|||
</td>
|
||||
<td title="{{ invoice.created_on }}">{{ invoice.created_on_arrow }}</td>
|
||||
<td class="actions">
|
||||
<a href="{% url 'invoices:invoice_edit' invoice.id %}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'invoices:invoice_edit' invoice.id %}" class="btn btn-success edit" title="Edit"><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
{% if request.user == invoice.created_by or request.user.role == "ADMIN" or request.user.is_superuser %}
|
||||
<a href="{% url 'invoices:invoice_details' invoice.id %}" class="btn btn-info edit"><i
|
||||
<a href="{% url 'invoices:invoice_details' invoice.id %}" class="btn btn-info edit" title="View"><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'invoices:invoice_delete' invoice.id %}"
|
||||
class="btn btn-danger delete remove_account"><i class="fas fa-trash-alt"></i></a>
|
||||
class="btn btn-danger delete remove_account" title="Delete" ><i class="fas fa-trash-alt"></i></a>
|
||||
{% if invoice.is_draft %}
|
||||
<a href="{% url 'invoices:invoice_send_mail' invoice.id %}" title="send mail"
|
||||
<a href="{% url 'invoices:invoice_send_mail' invoice.id %}" title="Send Mail"
|
||||
class="btn btn-info to_send_mail"><i class="fas fa-paper-plane"></i></a>
|
||||
{% endif %}
|
||||
{% if invoice.is_sent == True %}
|
||||
<a href="{% url 'invoices:invoice_send_mail' invoice.id %}" title="re send mail"
|
||||
<a href="{% url 'invoices:invoice_send_mail' invoice.id %}" title="Re Send Mail"
|
||||
class="btn btn-secondary to_re_send_mail"><i class="fas fa-paper-plane"></i></a>
|
||||
<a href="{% url 'invoices:invoice_change_status_paid' invoice.id %}" title="Paid"
|
||||
class="btn btn-info to_paid"><i class="fas fa-check-square"></i></a>
|
||||
|
|
@ -273,19 +273,19 @@
|
|||
</td>
|
||||
<td title="{{ invoice.created_on }}">{{ invoice.created_on_arrow }}</td>
|
||||
<td class="actions">
|
||||
<a href="{% url 'invoices:invoice_edit' invoice.id %}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'invoices:invoice_edit' invoice.id %}" class="btn btn-success edit" title="Edit"><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
{% if request.user == invoice.created_by or request.user.role == "ADMIN" or request.user.is_superuser %}
|
||||
<a href="{% url 'invoices:invoice_details' invoice.id %}" class="btn btn-info edit"><i
|
||||
<a href="{% url 'invoices:invoice_details' invoice.id %}" class="btn btn-info edit" title="View" ><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'invoices:invoice_delete' invoice.id %}"
|
||||
class="btn btn-danger delete remove_account"><i class="fas fa-trash-alt"></i></a>
|
||||
class="btn btn-danger delete remove_account" title="Delete"><i class="fas fa-trash-alt"></i></a>
|
||||
{% if invoice.is_draft %}
|
||||
<a href="{% url 'invoices:invoice_send_mail' invoice.id %}" title="send mail"
|
||||
<a href="{% url 'invoices:invoice_send_mail' invoice.id %}" title="Send Mail"
|
||||
class="btn btn-info to_send_mail"><i class="fas fa-paper-plane"></i></a>
|
||||
{% endif %}
|
||||
{% if invoice.is_sent == True %}
|
||||
<a href="{% url 'invoices:invoice_send_mail' invoice.id %}" title="re send mail"
|
||||
<a href="{% url 'invoices:invoice_send_mail' invoice.id %}" title="Re Send Mail"
|
||||
class="btn btn-secondary to_re_send_mail"><i class="fas fa-paper-plane"></i></a>
|
||||
<a href="{% url 'invoices:invoice_change_status_paid' invoice.id %}" title="Paid"
|
||||
class="btn btn-info to_paid"><i class="fas fa-check-square"></i></a>
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ class InvoiceCreateTest(object):
|
|||
to_address=self.to_address,
|
||||
)
|
||||
self.invoice.assigned_to.add(self.user1.id)
|
||||
self.invoice.accounts.add(self.account.id)
|
||||
|
||||
self.invoice_history = InvoiceHistory.objects.create(
|
||||
invoice_title='invoice title',
|
||||
|
|
|
|||
22
invoices/tests_celery_tasks.py
Normal file
22
invoices/tests_celery_tasks.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from invoices.tasks import (send_email, send_invoice_email,
|
||||
send_invoice_email_cancel)
|
||||
from invoices.tests import InvoiceCreateTest
|
||||
|
||||
|
||||
class TestSendMailOnInvoiceCreationTask(InvoiceCreateTest, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_send_mail_on_invoice_creation_task(self):
|
||||
task = send_email.apply((self.invoice.id,))
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = send_invoice_email.apply((self.invoice.id,))
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = send_invoice_email_cancel.apply((self.invoice.id,))
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
|
@ -65,9 +65,8 @@ def send_lead_assigned_emails(lead_id, new_assigned_to_list, site_address):
|
|||
send_email.delay(**mail_kwargs)
|
||||
|
||||
|
||||
|
||||
@task
|
||||
def send_email_to_assigned_user(recipients, lead_id, domain='demo.django-crm.io', protocol='http'):
|
||||
def send_email_to_assigned_user(recipients, lead_id, domain='demo.django-crm.io', protocol='http', source=''):
|
||||
""" Send Mail To Users When they are assigned to a lead """
|
||||
lead = Lead.objects.get(id=lead_id)
|
||||
created_by = lead.created_by
|
||||
|
|
@ -82,10 +81,10 @@ def send_email_to_assigned_user(recipients, lead_id, domain='demo.django-crm.io'
|
|||
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,
|
||||
|
|
@ -94,6 +93,7 @@ def send_email_to_assigned_user(recipients, lead_id, domain='demo.django-crm.io'
|
|||
msg.content_subtype = "html"
|
||||
msg.send()
|
||||
|
||||
|
||||
@task
|
||||
def create_lead_from_file(validated_rows, invalid_rows, user_id):
|
||||
"""Parameters : validated_rows, invalid_rows, user_id.
|
||||
|
|
|
|||
|
|
@ -236,13 +236,13 @@
|
|||
<td>{{ lead.country }}</td>
|
||||
<td title="{{ lead.created_on }}">{{ lead.created_on_arrow }}</td>
|
||||
<td class="actions">
|
||||
<a href="{% url 'leads:view_lead' lead.id %}" class="btn btn-info edit"><i
|
||||
<a href="{% url 'leads:view_lead' lead.id %}" class="btn btn-info edit" title="View"><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'leads:edit_lead' lead.id %}" class="btn btn-success edit"><i
|
||||
<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"><i class="fas fa-trash-alt"></i></a>
|
||||
class="btn btn-danger delete remove_account" title="Delete" ><i class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -347,13 +347,13 @@
|
|||
<td>{{ lead.country }}</td>
|
||||
<td title="{{ lead.created_on_arrow }}">{{ lead.created_on_arrow }}</td>
|
||||
<td class="actions">
|
||||
<a href="{% url 'leads:view_lead' lead.id %}" class="btn btn-info edit"><i
|
||||
<a href="{% url 'leads:view_lead' lead.id %}" class="btn btn-info edit" title="View"><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'leads:edit_lead' lead.id %}" class="btn btn-success edit"><i
|
||||
<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 %}
|
||||
{% 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"><i class="fas fa-trash-alt"></i></a>
|
||||
class="btn btn-danger delete remove_account" title="Delete"><i class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ class TestLeadModel(object):
|
|||
description="lead description",
|
||||
created_by=self.user,
|
||||
account_name="account",
|
||||
phone="+91-123-456-7890")
|
||||
phone="+91-123-456-7890",
|
||||
is_active=True)
|
||||
|
||||
self.lead1 = Lead.objects.create(
|
||||
title="jane doe lead", created_by=self.user3)
|
||||
|
|
|
|||
50
leads/tests_celery_tasks.py
Normal file
50
leads/tests_celery_tasks.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from leads.tasks import (create_lead_from_file, send_email,
|
||||
send_email_to_assigned_user,
|
||||
send_lead_assigned_emails)
|
||||
from leads.tests import TestLeadModel
|
||||
|
||||
|
||||
class TestCeleryTasks(TestLeadModel, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_celery_tasks(self):
|
||||
task = send_email_to_assigned_user.apply(
|
||||
([self.user.id, self.user1.id, ], self.lead.id,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = send_lead_assigned_emails.apply(
|
||||
(self.lead.id, [self.user.id, self.user1.id, self.user2.id, ], 'https://www.example.com',),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = send_email.apply(
|
||||
('mail subject', 'html content',), {'recipients': [self.user.id, self.user1.id, self.user2.id, ], },)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = send_lead_assigned_emails.apply(
|
||||
(self.lead1.id, [self.user.id, self.user1.id, self.user2.id, ], 'https://www.example.com',),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
valid_rows = [
|
||||
{'title': 'lead1 csv', 'first name': 'john', 'last name': 'doe', 'website': 'www.example.com',
|
||||
'phone': '911234567890', 'email': 'user1@email.com', 'address': 'address for lead1'},
|
||||
{'title': 'lead2 csv', 'first name': 'jane', 'last name': 'doe', 'website': 'www.website.com',
|
||||
'phone': '911234567891', 'email': 'user2@email.com', 'address': 'address for lead2'},
|
||||
{'title': 'lead3 csv', 'first name': 'joe', 'last name': 'doe', 'website': 'www.test.com',
|
||||
'phone': '911234567892', 'email': 'user3@email.com', 'address': 'address for lead3'},
|
||||
{'title': 'lead4 csv', 'first name': 'john', 'last name': 'doe', 'website': 'www.sample.com',
|
||||
'phone': '911234567893', 'email': 'user4@email.com', 'address': 'address for lead4'}
|
||||
]
|
||||
invalid_rows = [
|
||||
{'title': 'lead5 csv', 'first name': 'joe', 'last name': 'doe', 'website': 'www.test.com',
|
||||
'phone': '911234567892', 'email': 'useremail.com', 'address': 'address for lead3'},
|
||||
{'title': 'lead6 csv', 'first name': 'john', 'last name': 'doe', 'website': 'www.sample.com',
|
||||
'phone': '911234567893', 'email': 'user4@email', 'address': 'address for lead4'}
|
||||
]
|
||||
task = create_lead_from_file.apply(
|
||||
(valid_rows, invalid_rows, self.user.id),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
|
@ -1,32 +1,36 @@
|
|||
import json
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.mail import EmailMessage
|
||||
from django.db.models import Q
|
||||
from django.forms.models import modelformset_factory
|
||||
from django.http import HttpResponseRedirect, JsonResponse, HttpResponse
|
||||
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.template.loader import render_to_string
|
||||
from django.urls import reverse
|
||||
from django.views.generic import (
|
||||
CreateView, DetailView, ListView, TemplateView, View)
|
||||
from django.views.generic import (CreateView, DetailView, ListView,
|
||||
TemplateView, View)
|
||||
|
||||
from accounts.models import Account, Tags
|
||||
from common.models import User, Comment, Attachments, APISettings
|
||||
from common.utils import LEAD_STATUS, LEAD_SOURCE, COUNTRIES
|
||||
from common import status
|
||||
from contacts.models import Contact
|
||||
from leads.models import Lead
|
||||
from leads.forms import LeadCommentForm, LeadForm, LeadAttachmentForm, LeadListForm
|
||||
from planner.models import Event, Reminder
|
||||
from planner.forms import ReminderForm
|
||||
from leads.tasks import send_lead_assigned_emails
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from common.access_decorators_mixins import (MarketingAccessRequiredMixin,
|
||||
SalesAccessRequiredMixin,
|
||||
marketing_access_required,
|
||||
sales_access_required)
|
||||
from common.models import APISettings, Attachments, Comment, User
|
||||
from common.tasks import send_email_user_mentions
|
||||
from leads.tasks import send_email_to_assigned_user, create_lead_from_file
|
||||
from common.access_decorators_mixins import (
|
||||
sales_access_required, marketing_access_required, SalesAccessRequiredMixin, MarketingAccessRequiredMixin)
|
||||
from common.utils import COUNTRIES, LEAD_SOURCE, LEAD_STATUS
|
||||
from contacts.models import Contact
|
||||
from leads.forms import (LeadAttachmentForm, LeadCommentForm, LeadForm,
|
||||
LeadListForm)
|
||||
from leads.models import Lead
|
||||
from leads.tasks import (create_lead_from_file, send_email_to_assigned_user,
|
||||
send_lead_assigned_emails)
|
||||
from planner.forms import ReminderForm
|
||||
from planner.models import Event, Reminder
|
||||
from teams.models import Teams
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from django import forms
|
|||
from common.models import User
|
||||
from marketing.models import Campaign, Contact, ContactList, EmailTemplate, Tag, ContactEmailCampaign
|
||||
|
||||
email_regex = '^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,4})$'
|
||||
email_regex = r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"
|
||||
|
||||
|
||||
def csv_doc_validate(document):
|
||||
|
|
@ -217,7 +217,7 @@ def import_document_validator(document):
|
|||
except Exception as e:
|
||||
print(e)
|
||||
print('xls')
|
||||
return {"error": True, "message": "Not a valid CSV/XLS file"}
|
||||
return {"error": True, "message": "Not a valid CSV/XLS, XLSX file"}
|
||||
|
||||
|
||||
class ContactListForm(forms.ModelForm):
|
||||
|
|
@ -269,24 +269,24 @@ class ContactListForm(forms.ModelForm):
|
|||
# raise forms.ValidationError('Uploaded file is not valid.')
|
||||
return document
|
||||
|
||||
def clean_visible_to(self):
|
||||
visible_to_data = json.loads(self.data['visible_to'])
|
||||
if len(visible_to_data) > 0:
|
||||
instance_visible_to = []
|
||||
if self.instance and self.instance.id is not None:
|
||||
instance_visible_to = list(
|
||||
set(self.instance.visible_to.all().values_list(
|
||||
'email', flat=True)))
|
||||
for each in visible_to_data:
|
||||
visible_to = User.objects.filter(email=each)
|
||||
if instance_visible_to:
|
||||
visible_to = visible_to.exclude(
|
||||
email__in=instance_visible_to)
|
||||
if visible_to:
|
||||
raise forms.ValidationError(
|
||||
str(each) + ' User aleady existed')
|
||||
return self.data['visible_to']
|
||||
raise forms.ValidationError("Select any of the users")
|
||||
# def clean_visible_to(self):
|
||||
# visible_to_data = json.loads(self.data['visible_to'])
|
||||
# if len(visible_to_data) > 0:
|
||||
# instance_visible_to = []
|
||||
# if self.instance and self.instance.id is not None:
|
||||
# instance_visible_to = list(
|
||||
# set(self.instance.visible_to.all().values_list(
|
||||
# 'email', flat=True)))
|
||||
# for each in visible_to_data:
|
||||
# visible_to = User.objects.filter(email=each)
|
||||
# if instance_visible_to:
|
||||
# visible_to = visible_to.exclude(
|
||||
# email__in=instance_visible_to)
|
||||
# if visible_to:
|
||||
# raise forms.ValidationError(
|
||||
# str(each) + ' User aleady existed')
|
||||
# return self.data['visible_to']
|
||||
# raise forms.ValidationError("Select any of the users")
|
||||
|
||||
|
||||
class ContactForm(forms.ModelForm):
|
||||
|
|
@ -334,39 +334,39 @@ class ContactForm(forms.ModelForm):
|
|||
# return contact_list
|
||||
|
||||
|
||||
class ContactsCSVUploadForm(forms.Form):
|
||||
contacts_file = forms.FileField()
|
||||
contact_list = forms.CharField(max_length=5000)
|
||||
# class ContactsCSVUploadForm(forms.Form):
|
||||
# contacts_file = forms.FileField()
|
||||
# contact_list = forms.CharField(max_length=5000)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ContactsCSVUploadForm, self).__init__(*args, **kwargs)
|
||||
self.fields['contacts_file'].widget.attrs.update({
|
||||
"accept": ".csv,.xls,.xlsx,.xlsm,.xlsb,.xml",
|
||||
})
|
||||
self.fields['contacts_file'].required = True
|
||||
# def __init__(self, *args, **kwargs):
|
||||
# super(ContactsCSVUploadForm, self).__init__(*args, **kwargs)
|
||||
# self.fields['contacts_file'].widget.attrs.update({
|
||||
# "accept": ".csv,.xls,.xlsx,.xlsm,.xlsb,.xml",
|
||||
# })
|
||||
# self.fields['contacts_file'].required = True
|
||||
|
||||
def clean_contacts_file(self):
|
||||
document = self.cleaned_data.get("contacts_file")
|
||||
data = import_document_validator(document)
|
||||
if data.get("error"):
|
||||
raise forms.ValidationError(data.get("message"))
|
||||
else:
|
||||
self.validated_rows = data.get("validated_rows")
|
||||
return document
|
||||
# def clean_contacts_file(self):
|
||||
# document = self.cleaned_data.get("contacts_file")
|
||||
# data = import_document_validator(document)
|
||||
# if data.get("error"):
|
||||
# raise forms.ValidationError(data.get("message"))
|
||||
# else:
|
||||
# self.validated_rows = data.get("validated_rows")
|
||||
# return document
|
||||
|
||||
def clean_contact_list(self):
|
||||
contact_list = self.cleaned_data.get("contact_list")
|
||||
if not contact_list or contact_list == '[]' or\
|
||||
json.loads(contact_list) == []:
|
||||
raise forms.ValidationError(
|
||||
"Please choose any of the Contact List")
|
||||
else:
|
||||
for each in json.loads(contact_list):
|
||||
if not ContactList.objects.filter(id=each).first():
|
||||
raise forms.ValidationError(
|
||||
"Please choose a valid Contact List")
|
||||
# def clean_contact_list(self):
|
||||
# contact_list = self.cleaned_data.get("contact_list")
|
||||
# if not contact_list or contact_list == '[]' or\
|
||||
# json.loads(contact_list) == []:
|
||||
# raise forms.ValidationError(
|
||||
# "Please choose any of the Contact List")
|
||||
# else:
|
||||
# for each in json.loads(contact_list):
|
||||
# if not ContactList.objects.filter(id=each).first():
|
||||
# raise forms.ValidationError(
|
||||
# "Please choose a valid Contact List")
|
||||
|
||||
return contact_list
|
||||
# return contact_list
|
||||
|
||||
|
||||
class EmailTemplateForm(forms.ModelForm):
|
||||
|
|
@ -402,7 +402,7 @@ class SendCampaignForm(forms.ModelForm):
|
|||
|
||||
def clean_schedule_date_time(self):
|
||||
schedule_date_time = self.cleaned_data.get('schedule_date_time')
|
||||
if self.cleaned_data.get('schedule_later') == 'true':
|
||||
if self.cleaned_data.get('schedule_later') == True:
|
||||
schedule_date_time = datetime.datetime.strptime(
|
||||
schedule_date_time, '%Y-%m-%d %H:%M')
|
||||
if schedule_date_time < datetime.datetime.now():
|
||||
|
|
|
|||
26
marketing/migrations/0011_auto_20190904_1143.py
Normal file
26
marketing/migrations/0011_auto_20190904_1143.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Generated by Django 2.2.4 on 2019-09-04 06:13
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('marketing', '0010_auto_20190805_1038'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='contactemailcampaign',
|
||||
options={'ordering': ('created_on',)},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='DuplicateContacts',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('contact_list', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='duplicate_contact_contact_list', to='marketing.ContactList')),
|
||||
('contacts', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='duplicate_contact', to='marketing.Contact')),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
|
@ -71,16 +71,16 @@ class ContactList(models.Model):
|
|||
def created_on_format(self):
|
||||
return self.created_on.strftime('%b %d, %Y %I:%M %p')
|
||||
|
||||
@property
|
||||
def created_on_since(self):
|
||||
now = datetime.now()
|
||||
difference = now.replace(tzinfo=None) - \
|
||||
self.created_on.replace(tzinfo=None)
|
||||
# @property
|
||||
# def created_on_since(self):
|
||||
# now = datetime.now()
|
||||
# difference = now.replace(tzinfo=None) - \
|
||||
# self.created_on.replace(tzinfo=None)
|
||||
|
||||
if difference <= timedelta(minutes=1):
|
||||
return 'just now'
|
||||
return '%(time)s ago' % {
|
||||
'time': timesince(self.created_on).split(', ')[0]}
|
||||
# if difference <= timedelta(minutes=1):
|
||||
# return 'just now'
|
||||
# return '%(time)s ago' % {
|
||||
# 'time': timesince(self.created_on).split(', ')[0]}
|
||||
|
||||
@property
|
||||
def tags_data(self):
|
||||
|
|
@ -102,12 +102,12 @@ class ContactList(models.Model):
|
|||
def bounced_contacts(self):
|
||||
return self.contacts.filter(is_bounced=True).count()
|
||||
|
||||
@property
|
||||
def no_of_clicks(self):
|
||||
clicks = CampaignLog.objects.filter(
|
||||
contact__contact_list__in=[self]).aggregate(Sum(
|
||||
'no_of_clicks'))['no_of_clicks__sum']
|
||||
return clicks
|
||||
# @property
|
||||
# def no_of_clicks(self):
|
||||
# clicks = CampaignLog.objects.filter(
|
||||
# contact__contact_list__in=[self]).aggregate(Sum(
|
||||
# 'no_of_clicks'))['no_of_clicks__sum']
|
||||
# return clicks
|
||||
|
||||
@property
|
||||
def created_on_arrow(self):
|
||||
|
|
@ -226,31 +226,31 @@ class Campaign(models.Model):
|
|||
class Meta:
|
||||
ordering = ('-created_on', )
|
||||
|
||||
@property
|
||||
def no_of_unsubscribers(self):
|
||||
unsubscribers = self.campaign_contacts.filter(
|
||||
contact__is_unsubscribed=True).count()
|
||||
return unsubscribers
|
||||
# @property
|
||||
# def no_of_unsubscribers(self):
|
||||
# unsubscribers = self.campaign_contacts.filter(
|
||||
# contact__is_unsubscribed=True).count()
|
||||
# return unsubscribers
|
||||
|
||||
@property
|
||||
def no_of_bounces(self):
|
||||
bounces = self.campaign_contacts.filter(
|
||||
contact__is_bounced=True).count()
|
||||
return bounces
|
||||
# @property
|
||||
# def no_of_bounces(self):
|
||||
# bounces = self.campaign_contacts.filter(
|
||||
# contact__is_bounced=True).count()
|
||||
# return bounces
|
||||
|
||||
@property
|
||||
def no_of_clicks(self):
|
||||
clicks = self.marketing_links.aggregate(Sum('clicks'))['clicks__sum']
|
||||
return clicks
|
||||
|
||||
@property
|
||||
def no_of_sent_emails(self):
|
||||
contacts = self.campaign_contacts.count()
|
||||
return contacts
|
||||
# @property
|
||||
# def no_of_sent_emails(self):
|
||||
# contacts = self.campaign_contacts.count()
|
||||
# return contacts
|
||||
|
||||
@property
|
||||
def created_on_format(self):
|
||||
return self.created_on.strftime('%b %d, %Y %I:%M %p')
|
||||
# @property
|
||||
# def created_on_format(self):
|
||||
# return self.created_on.strftime('%b %d, %Y %I:%M %p')
|
||||
|
||||
@property
|
||||
def sent_on_format(self):
|
||||
|
|
@ -273,14 +273,16 @@ class Campaign(models.Model):
|
|||
def get_all_email_bounces_count(self):
|
||||
# return self.contact_lists.filter(contacts__is_bounced=True
|
||||
# ).exclude(contacts__email=None).values_list('contacts__email').count()
|
||||
email_count = CampaignLog.objects.filter(campaign=self,contact__is_bounced=True).count()
|
||||
email_count = CampaignLog.objects.filter(
|
||||
campaign=self, contact__is_bounced=True).count()
|
||||
return email_count
|
||||
|
||||
@property
|
||||
def get_all_emails_unsubscribed_count(self):
|
||||
# return self.contact_lists.filter(contacts__is_unsubscribed=True
|
||||
# ).exclude(contacts__email=None).values_list('contacts__email').count()
|
||||
email_count = CampaignLog.objects.filter(campaign=self,contact__is_unsubscribed=True).count()
|
||||
email_count = CampaignLog.objects.filter(
|
||||
campaign=self, contact__is_unsubscribed=True).count()
|
||||
return email_count
|
||||
|
||||
@property
|
||||
|
|
@ -383,6 +385,7 @@ class ContactUnsubscribedCampaign(models.Model):
|
|||
Contact, on_delete=models.Case, related_name='contact_is_unsubscribed')
|
||||
is_unsubscribed = models.BooleanField(default=False)
|
||||
|
||||
|
||||
class ContactEmailCampaign(models.Model):
|
||||
"""
|
||||
send all campaign emails to this contact
|
||||
|
|
@ -396,4 +399,20 @@ class ContactEmailCampaign(models.Model):
|
|||
created_on = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def created_on_arrow(self):
|
||||
return arrow.get(self.created_on).humanize()
|
||||
return arrow.get(self.created_on).humanize()
|
||||
|
||||
class Meta:
|
||||
ordering = ('created_on',)
|
||||
|
||||
|
||||
class DuplicateContacts(models.Model):
|
||||
"""
|
||||
this model is used to store duplicate contacts
|
||||
"""
|
||||
contacts = models.ForeignKey(
|
||||
Contact, related_name='duplicate_contact', on_delete=models.SET_NULL, null=True)
|
||||
contact_list = models.ForeignKey(
|
||||
ContactList, related_name='duplicate_contact_contact_list', on_delete=models.SET_NULL, null=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ('id', )
|
||||
|
|
@ -11,8 +11,9 @@ from django.shortcuts import reverse
|
|||
from django.template import Context, Template
|
||||
|
||||
from common.utils import convert_to_custom_timezone
|
||||
from marketing.models import (Campaign, CampaignLog, Contact, ContactList,
|
||||
FailedContact, CampaignCompleted, ContactEmailCampaign)
|
||||
from marketing.models import (Campaign, CampaignCompleted, CampaignLog,
|
||||
Contact, ContactEmailCampaign, ContactList,
|
||||
FailedContact, DuplicateContacts)
|
||||
|
||||
|
||||
@task
|
||||
|
|
@ -47,6 +48,13 @@ def upload_csv_file(data, invalid_data, user, contact_lists):
|
|||
if each.get("state", None):
|
||||
contact.state = each['state']
|
||||
contact.save()
|
||||
else:
|
||||
if not DuplicateContacts.objects.filter(
|
||||
contacts=contact,
|
||||
contact_list=ContactList.objects.get(id=int(contact_lists[0]))).exists():
|
||||
DuplicateContacts.objects.create(
|
||||
contacts=contact,
|
||||
contact_list=ContactList.objects.get(id=int(contact_lists[0])))
|
||||
for contact_list in contact_lists:
|
||||
contact.contact_list.add(
|
||||
ContactList.objects.get(id=int(contact_list)))
|
||||
|
|
@ -266,7 +274,7 @@ def send_campaign_email_to_admin_contact(campaign, domain='demo.django-crm.io',
|
|||
else:
|
||||
from_email = campaign.created_by.email
|
||||
reply_to_email = str(from_email) + ' <' + \
|
||||
str(message_id + '@' + domain_name + '') + '>'
|
||||
str(settings.EMAIL_HOST_USER + '@' + domain_name + '') + '>'
|
||||
|
||||
# domain_url = settings.URL_FOR_LINKS
|
||||
domain_url = protocol + '://' + domain
|
||||
|
|
@ -302,4 +310,4 @@ def send_campaign_email_to_admin_contact(campaign, domain='demo.django-crm.io',
|
|||
subject, mail_html, from_email, to_email, [], [reply_to_email], attachments)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
pass
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
{% block breadcrumb %}
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{% url 'common:api_settings' %}">Campaign Emails</a></li>
|
||||
<li class="breadcrumb-item"><a href="{% url 'marketing:list_all_emails_for_campaigns' %}">Campaign Emails</a></li>
|
||||
<li class="breadcrumb-item active">
|
||||
{% if edit_obj %}
|
||||
Edit
|
||||
|
|
@ -60,7 +60,7 @@
|
|||
<div class="col-md-12">
|
||||
<div class="row marl buttons_row text-center form_btn_row">
|
||||
<button class="btn btn-default save" type="submit">Save</button>
|
||||
<a href="{% url 'marketing:list_all_emails_for_campaigns' %}" class="btn btn-default clear"
|
||||
<a href="{% url 'common:api_settings' %}" class="btn btn-default clear"
|
||||
id="create_lead_cancel">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ NUM_PAGES_OUTSIDE_RANGE = 0
|
|||
ADJACENT_PAGES = 2
|
||||
|
||||
|
||||
def digg_paginator(context):
|
||||
def digg_paginator(context): # pragma: no cover
|
||||
'''
|
||||
To be used in conjunction with the object_list generic view.
|
||||
|
||||
|
|
|
|||
1170
marketing/tests.py
1170
marketing/tests.py
File diff suppressed because it is too large
Load diff
66
marketing/tests_celery_tasks.py
Normal file
66
marketing/tests_celery_tasks.py
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from marketing.tasks import (delete_multiple_contacts_tasks,
|
||||
list_all_bounces_unsubscribes, run_all_campaigns,
|
||||
run_campaign,
|
||||
send_campaign_email_to_admin_contact,
|
||||
send_scheduled_campaigns, upload_csv_file)
|
||||
from marketing.tests import TestMarketingModel
|
||||
|
||||
|
||||
class TestCeleryTasks(TestMarketingModel, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_celery_tasks(self):
|
||||
task = run_campaign.apply((self.campaign.id,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
self.campaign.reply_to_email = None
|
||||
self.campaign.save()
|
||||
|
||||
task = run_campaign.apply((self.campaign.id,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
self.campaign.schedule_date_time = datetime.now()
|
||||
self.campaign.save()
|
||||
|
||||
task = run_all_campaigns.apply()
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = list_all_bounces_unsubscribes.apply()
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = send_scheduled_campaigns.apply()
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = delete_multiple_contacts_tasks.apply((self.contact_list.id,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
task = send_campaign_email_to_admin_contact.apply((self.campaign.id,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
||||
valid_rows = [
|
||||
{'company name': 'company_name_1', 'email': 'user1@email.com', 'first name': 'first_name',
|
||||
'last name': 'last_name', 'city': 'Hyderabad', 'state': 'Telangana'},
|
||||
{'company name': 'company_name_2', 'email': 'user2@email.com', 'first name': 'first_name',
|
||||
'last name': 'last_name', 'city': 'Hyderabad', 'state': 'Telangana'},
|
||||
{'company name': 'company_name_3', 'email': 'user3@email.com', 'first name': 'first_name',
|
||||
'last name': 'last_name', 'city': 'Hyderabad', 'state': 'Telangana'},
|
||||
{'company name': 'company_name_4', 'email': 'user4@email.com', 'first name': 'first_name',
|
||||
'last name': 'last_name', 'city': 'Hyderabad', 'state': 'Telangana'}
|
||||
]
|
||||
|
||||
invalid_rows = [
|
||||
{'company name': 'company_name_1', 'email': 'useremail.com', 'first name': 'first_name',
|
||||
'last name': 'last_name', 'city': 'Hyderabad', 'state': 'Telangana'},
|
||||
{'company name': 'company_name_2', 'email': 'user2@email', 'first name': 'first_name',
|
||||
'last name': 'last_name', 'city': 'Hyderabad', 'state': 'Telangana'},
|
||||
]
|
||||
task = upload_csv_file.apply(
|
||||
(valid_rows, invalid_rows, self.user.id, [self.contact_list.id, ],),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
|
@ -1,13 +1,19 @@
|
|||
from django.urls import path
|
||||
from .views import (
|
||||
dashboard, contact_lists, contacts_list, contact_list_new, contacts_list_new, contact_list_detail, edit_contact,
|
||||
dashboard, contact_lists, contacts_list, contact_list_new, contact_list_detail, edit_contact,
|
||||
email_template_list, email_template_new, email_template_edit, email_template_delete,
|
||||
email_template_detail, campaign_list, campaign_new, campaign_edit, campaign_details, campaign_delete,
|
||||
edit_contact_list, delete_contact_list, failed_contact_list_detail, failed_contact_list_download_delete,
|
||||
email_template_detail, campaign_list, campaign_new, campaign_details, campaign_delete,
|
||||
edit_contact_list, failed_contact_list_download_delete,
|
||||
campaign_link_click, campaign_open, demo_file_download, delete_contact, unsubscribe_from_campaign, contact_detail,
|
||||
edit_failed_contact, delete_failed_contact, download_contacts_for_campaign, create_campaign_from_template,
|
||||
download_contacts_for_campaign, create_campaign_from_template,
|
||||
download_links_clicked, delete_multiple_contacts, download_failed_contacts, delete_all_contacts,
|
||||
add_email_for_campaigns, list_all_emails_for_campaigns, edit_email_for_campaigns, delete_email_for_campaigns
|
||||
add_email_for_campaigns, list_all_emails_for_campaigns, edit_email_for_campaigns, delete_email_for_campaigns,
|
||||
# contacts_list_new
|
||||
# delete_contact_list
|
||||
# campaign_edit
|
||||
# edit_failed_contact
|
||||
# delete_failed_contact
|
||||
# failed_contact_list_detail
|
||||
)
|
||||
|
||||
app_name = 'marketing'
|
||||
|
|
@ -20,11 +26,11 @@ urlpatterns = [
|
|||
path('contacts/<int:pk>/delete/', delete_contact, name='delete_contact'),
|
||||
path('contacts/', contacts_list, 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('cl/list/cnew/', contacts_list_new, name='contacts_list_new'),
|
||||
path('contact-list/<int:pk>/detail/', contact_list_detail, name='contact_list_detail'),
|
||||
path('contact-list/<int:pk>/failed/', failed_contact_list_detail, name='failed_contact_list_detail'),
|
||||
path('contact-list/<int:pk>/failed/edit/', edit_failed_contact, name='edit_failed_contact'),
|
||||
path('contact-list/<int:pk>/failed/delete/', delete_failed_contact, name='delete_failed_contact'),
|
||||
# path('contact-list/<int:pk>/failed/', failed_contact_list_detail, name='failed_contact_list_detail'),
|
||||
# path('contact-list/<int:pk>/failed/edit/', edit_failed_contact, name='edit_failed_contact'),
|
||||
# path('contact-list/<int:pk>/failed/delete/', delete_failed_contact, name='delete_failed_contact'),
|
||||
path('contact-list/<int:pk>/failed/download/',
|
||||
failed_contact_list_download_delete, name='failed_contact_list_download_delete'),
|
||||
path('contact-list/<int:pk>/edit/', edit_contact_list, name='edit_contact_list'),
|
||||
|
|
@ -38,7 +44,7 @@ urlpatterns = [
|
|||
|
||||
path('campaigns/', campaign_list, name='campaign_list'),
|
||||
path('campaigns/create/', campaign_new, name='campaign_new'),
|
||||
path('cm/<int:pk>/edit/', campaign_edit, name='campaign_edit'),
|
||||
# path('cm/<int:pk>/edit/', campaign_edit, name='campaign_edit'),
|
||||
path('campaigns/<int:pk>/details/', campaign_details, name='campaign_details'),
|
||||
path('campaigns/<int:pk>/delete/', campaign_delete, name='campaign_delete'),
|
||||
path('cm/link/<int:link_id>/e/<int:email_id>/', campaign_link_click, name='campaign_link_click'),
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@ from common.access_decorators_mixins import marketing_access_required, Marketing
|
|||
TIMEZONE_CHOICES = [(tz, tz) for tz in pytz.common_timezones]
|
||||
|
||||
|
||||
def get_exact_match(query, m2m_field, ids):
|
||||
# query = tasks_list.annotate(count=Count(m2m_field))\
|
||||
# .filter(count=len(ids))
|
||||
query = query
|
||||
for _id in ids:
|
||||
query = query.filter(**{m2m_field: _id})
|
||||
return query
|
||||
# def get_exact_match(query, m2m_field, ids):
|
||||
# # query = tasks_list.annotate(count=Count(m2m_field))\
|
||||
# # .filter(count=len(ids))
|
||||
# query = query
|
||||
# for _id in ids:
|
||||
# query = query.filter(**{m2m_field: _id})
|
||||
# return query
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
|
|
@ -123,16 +123,18 @@ def contact_lists(request):
|
|||
def contacts_list(request):
|
||||
if (request.user.role == "ADMIN"):
|
||||
contacts = Contact.objects.all()
|
||||
contact_lists = ContactList.objects.all()
|
||||
else:
|
||||
contact_ids = request.user.marketing_contactlist.all().values_list('contacts',
|
||||
flat=True)
|
||||
contacts = Contact.objects.filter(id__in=contact_ids)
|
||||
contact_lists = ContactList.objects.filter(created_by=request.user)
|
||||
# contacts = Contact.objects.filter(created_by=request.user)
|
||||
users = User.objects.filter(
|
||||
id__in=contacts.values_list('created_by_id', flat=True))
|
||||
|
||||
if request.method == 'GET':
|
||||
context = {'contacts': contacts, 'users': users}
|
||||
context = {'contacts': contacts, 'users': users, 'contact_lists': contact_lists}
|
||||
return render(request, 'marketing/lists/all.html', context)
|
||||
|
||||
if request.method == 'POST':
|
||||
|
|
@ -147,7 +149,11 @@ def contacts_list(request):
|
|||
if data.get('created_by'):
|
||||
contacts = contacts.filter(created_by=data.get('created_by'))
|
||||
|
||||
context = {'contacts': contacts, 'users': User.objects.all()}
|
||||
if data.get('contact_list'):
|
||||
contacts = contacts.filter(contact_list=data.get('contact_list'))
|
||||
|
||||
context = {'contacts': contacts, 'users': User.objects.all(),
|
||||
'contact_lists': contact_lists}
|
||||
return render(request, 'marketing/lists/all.html', context)
|
||||
|
||||
|
||||
|
|
@ -188,15 +194,10 @@ def contact_list_new(request):
|
|||
@marketing_access_required
|
||||
def edit_contact_list(request, pk):
|
||||
user = request.user
|
||||
try:
|
||||
contact_list = ContactList.objects.get(pk=pk)
|
||||
except ContactList.DoesNotExist:
|
||||
contact_list = ContactList.objects.none()
|
||||
return JsonResponse({}, status=status.HTTP_404_NOT_FOUND)
|
||||
|
||||
contact_list = get_object_or_404(ContactList, pk=pk)
|
||||
if request.method == 'GET':
|
||||
# contact_lists = ContactList.objects.filter(company=request.company)
|
||||
if (user.is_superuser):
|
||||
if (user.is_superuser or request.user.role == 'ADMIN'):
|
||||
contact_lists = ContactList.objects.all()
|
||||
else:
|
||||
contact_lists = ContactList.objects.filter(created_by=request.user)
|
||||
|
|
@ -225,65 +226,65 @@ def edit_contact_list(request, pk):
|
|||
'errors': form.errors}, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def view_contact_list(request, pk):
|
||||
contact_list = get_object_or_404(ContactList, pk=pk)
|
||||
contacts = Contact.objects.filter(contact_list__in=[contact_list])
|
||||
if request.POST and request.POST.get("search"):
|
||||
contacts = contacts.filter(
|
||||
Q(name__icontains=request.POST['search']) |
|
||||
Q(email__icontains=request.POST['search']))
|
||||
# @login_required(login_url='/login')
|
||||
# @marketing_access_required
|
||||
# def view_contact_list(request, pk):
|
||||
# contact_list = get_object_or_404(ContactList, pk=pk)
|
||||
# contacts = Contact.objects.filter(contact_list__in=[contact_list])
|
||||
# if request.POST and request.POST.get("search"):
|
||||
# contacts = contacts.filter(
|
||||
# Q(name__icontains=request.POST['search']) |
|
||||
# Q(email__icontains=request.POST['search']))
|
||||
|
||||
per_page = request.GET.get("per_page", 10)
|
||||
paginator = Paginator(contacts.order_by('id'), per_page)
|
||||
page = request.GET.get('page', 1)
|
||||
try:
|
||||
contacts = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
contacts = paginator.page(1)
|
||||
except EmptyPage:
|
||||
contacts = paginator.page(paginator.num_pages)
|
||||
# per_page = request.GET.get("per_page", 10)
|
||||
# paginator = Paginator(contacts.order_by('id'), per_page)
|
||||
# page = request.GET.get('page', 1)
|
||||
# try:
|
||||
# contacts = paginator.page(page)
|
||||
# except PageNotAnInteger:
|
||||
# contacts = paginator.page(1)
|
||||
# except EmptyPage:
|
||||
# contacts = paginator.page(paginator.num_pages)
|
||||
|
||||
data = {'contact_list': contact_list, "contacts": contacts}
|
||||
template_name = "marketing/lists/all.html"
|
||||
return render(request, template_name, data)
|
||||
# data = {'contact_list': contact_list, "contacts": contacts}
|
||||
# template_name = "marketing/lists/all.html"
|
||||
# return render(request, template_name, data)
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def delete_contact_list(request, pk):
|
||||
contact_list_obj = get_object_or_404(ContactList, pk=pk)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or contact_list_obj.created_by == request.user):
|
||||
raise PermissionDenied
|
||||
# @login_required(login_url='/login')
|
||||
# @marketing_access_required
|
||||
# def delete_contact_list(request, pk):
|
||||
# contact_list_obj = get_object_or_404(ContactList, pk=pk)
|
||||
# if not (request.user.role == 'ADMIN' or request.user.is_superuser or contact_list_obj.created_by == request.user):
|
||||
# raise PermissionDenied
|
||||
|
||||
contact_list_obj.delete()
|
||||
redirect_to = reverse('marketing:contact_lists')
|
||||
return HttpResponseRedirect(redirect_to)
|
||||
# contact_list_obj.delete()
|
||||
# redirect_to = reverse('marketing:contact_lists')
|
||||
# return HttpResponseRedirect(redirect_to)
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def contacts_list_new(request):
|
||||
if request.POST:
|
||||
form = ContactForm(request.POST)
|
||||
if form.is_valid():
|
||||
instance = form.save(commit=False)
|
||||
instance.created_by = request.user
|
||||
instance.save()
|
||||
for each in json.loads(request.POST['contact_list']):
|
||||
instance.contact_list.add(ContactList.objects.get(id=each))
|
||||
# return JsonResponse(form.data, status=status.HTTP_201_CREATED)
|
||||
return reverse('marketing:contact_list')
|
||||
else:
|
||||
data = {'error': True, 'errors': form.errors}
|
||||
else:
|
||||
if (request.user.is_superuser):
|
||||
queryset = ContactList.objects.all()
|
||||
else:
|
||||
queryset = ContactList.objects.filter(created_by=request.user)
|
||||
data = {"contact_list": queryset}
|
||||
return render(request, 'marketing/lists/cnew.html', data)
|
||||
# @login_required(login_url='/login')
|
||||
# @marketing_access_required
|
||||
# def contacts_list_new(request):
|
||||
# if request.POST:
|
||||
# form = ContactForm(request.POST)
|
||||
# if form.is_valid():
|
||||
# instance = form.save(commit=False)
|
||||
# instance.created_by = request.user
|
||||
# instance.save()
|
||||
# for each in json.loads(request.POST['contact_list']):
|
||||
# instance.contact_list.add(ContactList.objects.get(id=each))
|
||||
# # return JsonResponse(form.data, status=status.HTTP_201_CREATED)
|
||||
# return reverse('marketing:contact_list')
|
||||
# else:
|
||||
# data = {'error': True, 'errors': form.errors}
|
||||
# else:
|
||||
# if (request.user.is_superuser):
|
||||
# queryset = ContactList.objects.all()
|
||||
# else:
|
||||
# queryset = ContactList.objects.filter(created_by=request.user)
|
||||
# data = {"contact_list": queryset}
|
||||
# return render(request, 'marketing/lists/cnew.html', data)
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
|
|
@ -362,6 +363,7 @@ def contact_list_detail(request, pk):
|
|||
contacts_list_count = contact_list.contacts.filter(is_bounced=False).count()
|
||||
bounced_contacts_list = contact_list.contacts.filter(is_bounced=True)
|
||||
bounced_contacts_list_count = contact_list.contacts.filter(is_bounced=True).count()
|
||||
duplicate_contacts = contact_list.duplicate_contact_contact_list.all()
|
||||
if request.POST:
|
||||
if request.POST.get('name'):
|
||||
contacts_list = contacts_list.filter(
|
||||
|
|
@ -394,19 +396,20 @@ def contact_list_detail(request, pk):
|
|||
"bounced_contacts_list":bounced_contacts_list,
|
||||
'bounced_contacts_list_count': bounced_contacts_list_count,
|
||||
'contacts_list_count': contacts_list_count,
|
||||
'duplicate_contacts': duplicate_contacts,
|
||||
# these two are added for digg pagintor
|
||||
'paginator':paginator,'page_obj': bounced_contacts_list,}
|
||||
return render(request, 'marketing/lists/detail.html', data)
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def failed_contact_list_detail(request, pk):
|
||||
contact_list = get_object_or_404(ContactList, pk=pk)
|
||||
failed_contacts_list = contact_list.failed_contacts.all()
|
||||
data = {'contact_list': contact_list,
|
||||
"failed_contacts_list": failed_contacts_list}
|
||||
return render(request, 'marketing/lists/failed_detail.html', data)
|
||||
# @login_required(login_url='/login')
|
||||
# @marketing_access_required
|
||||
# def failed_contact_list_detail(request, pk):
|
||||
# contact_list = get_object_or_404(ContactList, pk=pk)
|
||||
# failed_contacts_list = contact_list.failed_contacts.all()
|
||||
# data = {'contact_list': contact_list,
|
||||
# "failed_contacts_list": failed_contacts_list}
|
||||
# return render(request, 'marketing/lists/failed_detail.html', data)
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
|
|
@ -427,14 +430,14 @@ def failed_contact_list_download_delete(request, pk):
|
|||
failed_contacts_list.delete()
|
||||
return response
|
||||
else:
|
||||
return HttpResponseRedirect(reverse('marketing:contact_lists', kwargs={"pk": pk}))
|
||||
return HttpResponseRedirect(reverse('marketing:contact_list_detail', kwargs={"pk": pk}))
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def email_template_list(request):
|
||||
# users = User.objects.all()
|
||||
if (request.user.is_admin or request.user.is_superuser):
|
||||
if (request.user.role == 'ADMIN' or request.user.is_superuser):
|
||||
queryset = EmailTemplate.objects.all()
|
||||
else:
|
||||
queryset = EmailTemplate.objects.filter(
|
||||
|
|
@ -475,6 +478,9 @@ def email_template_new(request):
|
|||
def email_template_edit(request, pk):
|
||||
email_template = get_object_or_404(EmailTemplate, pk=pk)
|
||||
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or request.user == email_template.created_by):
|
||||
raise PermissionDenied
|
||||
|
||||
if request.method == 'GET':
|
||||
data = {'email_template': email_template}
|
||||
return render(request, 'marketing/email_template/new.html', data)
|
||||
|
|
@ -492,6 +498,8 @@ def email_template_edit(request, pk):
|
|||
@marketing_access_required
|
||||
def email_template_detail(request, pk):
|
||||
queryset = get_object_or_404(EmailTemplate, id=pk)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or request.user == queryset.created_by):
|
||||
raise PermissionDenied
|
||||
data = {'email_template': queryset}
|
||||
return render(request, 'marketing/email_template/details.html', data)
|
||||
|
||||
|
|
@ -499,11 +507,11 @@ def email_template_detail(request, pk):
|
|||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def email_template_delete(request, pk):
|
||||
try:
|
||||
EmailTemplate.objects.get(id=pk).delete()
|
||||
redirect_to = reverse('marketing:email_template_list')
|
||||
except ContactList.DoesNotExist:
|
||||
redirect_to = reverse('marketing:email_template_list')
|
||||
email_template_obj = get_object_or_404(EmailTemplate, pk=pk)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or request.user == email_template_obj.created_by):
|
||||
raise PermissionDenied
|
||||
email_template_obj.delete()
|
||||
redirect_to = reverse('marketing:email_template_list')
|
||||
return HttpResponseRedirect(redirect_to)
|
||||
|
||||
|
||||
|
|
@ -536,12 +544,12 @@ def campaign_list(request):
|
|||
@marketing_access_required
|
||||
def campaign_new(request):
|
||||
if request.method == 'GET':
|
||||
if request.user.is_admin or request.user.is_superuser:
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser:
|
||||
email_templates = EmailTemplate.objects.all()
|
||||
else:
|
||||
email_templates = EmailTemplate.objects.filter(
|
||||
created_by=request.user)
|
||||
if request.user.is_admin or request.user.is_superuser:
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser:
|
||||
contact_lists = ContactList.objects.all()
|
||||
else:
|
||||
contact_lists = ContactList.objects.filter(
|
||||
|
|
@ -638,22 +646,20 @@ def campaign_new(request):
|
|||
return JsonResponse({'error': True, 'errors': form.errors}, status=status.HTTP_200_OK)
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def campaign_edit(request):
|
||||
return render(request, 'marketing/campaign/edit.html')
|
||||
# @login_required(login_url='/login')
|
||||
# @marketing_access_required
|
||||
# def campaign_edit(request):
|
||||
# return render(request, 'marketing/campaign/edit.html')
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def campaign_details(request, pk):
|
||||
try:
|
||||
campaign = Campaign.objects.get(pk=pk)
|
||||
except Campaign.DoesNotExist:
|
||||
return redirect(reverse('marketing:campaign_list'))
|
||||
|
||||
campaign = get_object_or_404(Campaign, pk=pk)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or request.user == campaign.created_by):
|
||||
raise PermissionDenied
|
||||
contact_lists = campaign.contact_lists.all()
|
||||
if (request.user.is_admin or request.user.is_superuser):
|
||||
if (request.user.role == 'ADMIN' or request.user.is_superuser):
|
||||
contact_lists = contact_lists
|
||||
else:
|
||||
# contact_lists = contact_lists.filter(
|
||||
|
|
@ -679,96 +685,96 @@ def campaign_details(request, pk):
|
|||
read_contacts = Contact.objects.filter(id__in=contact_ids)
|
||||
sent_contacts = contacts.exclude(
|
||||
Q(is_bounced=True) | Q(is_unsubscribed=True))
|
||||
if request.POST:
|
||||
contacts = contacts.filter(Q(name__icontains=request.POST['search']))
|
||||
# if request.POST:
|
||||
# contacts = contacts.filter(Q(name__icontains=request.POST['search']))
|
||||
|
||||
tab = request.GET.get('tab', 'contacts')
|
||||
per_page = request.GET.get("per_page", 10)
|
||||
page = request.GET.get('page', 1)
|
||||
|
||||
contacts_paginator = Paginator(contacts.order_by('id'), per_page)
|
||||
if (tab == "contacts"):
|
||||
page = page
|
||||
else:
|
||||
page = 1
|
||||
try:
|
||||
contacts = contacts_paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
contacts = contacts_paginator.page(1)
|
||||
except EmptyPage:
|
||||
contacts = contacts_paginator.page(contacts_paginator.num_pages)
|
||||
# contacts_paginator = Paginator(contacts.order_by('id'), per_page)
|
||||
# if (tab == "contacts"):
|
||||
# page = page
|
||||
# else:
|
||||
# page = 1
|
||||
# try:
|
||||
# contacts = contacts_paginator.page(page)
|
||||
# except PageNotAnInteger:
|
||||
# contacts = contacts_paginator.page(1)
|
||||
# except EmptyPage:
|
||||
# contacts = contacts_paginator.page(contacts_paginator.num_pages)
|
||||
|
||||
unsubscribe_contacts_paginator = Paginator(
|
||||
unsubscribe_contacts.order_by('id'), per_page)
|
||||
if (tab == "unsubscribe_contacts"):
|
||||
page = page
|
||||
else:
|
||||
page = 1
|
||||
# unsubscribe_contacts_paginator = Paginator(
|
||||
# unsubscribe_contacts.order_by('id'), per_page)
|
||||
# if (tab == "unsubscribe_contacts"):
|
||||
# page = page
|
||||
# else:
|
||||
# page = 1
|
||||
|
||||
try:
|
||||
unsubscribe_contacts = unsubscribe_contacts_paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
unsubscribe_contacts = unsubscribe_contacts_paginator.page(1)
|
||||
except EmptyPage:
|
||||
unsubscribe_contacts = unsubscribe_contacts_paginator.page(
|
||||
unsubscribe_contacts_paginator.num_pages)
|
||||
# try:
|
||||
# unsubscribe_contacts = unsubscribe_contacts_paginator.page(page)
|
||||
# except PageNotAnInteger:
|
||||
# unsubscribe_contacts = unsubscribe_contacts_paginator.page(1)
|
||||
# except EmptyPage:
|
||||
# unsubscribe_contacts = unsubscribe_contacts_paginator.page(
|
||||
# unsubscribe_contacts_paginator.num_pages)
|
||||
|
||||
bounced_contacts_paginator = Paginator(
|
||||
bounced_contacts.order_by('id'), per_page)
|
||||
if (tab == "bounced_contacts"):
|
||||
page = page
|
||||
else:
|
||||
page = 1
|
||||
# bounced_contacts_paginator = Paginator(
|
||||
# bounced_contacts.order_by('id'), per_page)
|
||||
# if (tab == "bounced_contacts"):
|
||||
# page = page
|
||||
# else:
|
||||
# page = 1
|
||||
|
||||
try:
|
||||
bounced_contacts = bounced_contacts_paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
bounced_contacts = bounced_contacts_paginator.page(1)
|
||||
except EmptyPage:
|
||||
bounced_contacts = bounced_contacts_paginator.page(
|
||||
bounced_contacts_paginator.num_pages)
|
||||
# try:
|
||||
# bounced_contacts = bounced_contacts_paginator.page(page)
|
||||
# except PageNotAnInteger:
|
||||
# bounced_contacts = bounced_contacts_paginator.page(1)
|
||||
# except EmptyPage:
|
||||
# bounced_contacts = bounced_contacts_paginator.page(
|
||||
# bounced_contacts_paginator.num_pages)
|
||||
|
||||
sent_contacts_paginator = Paginator(sent_contacts.order_by('id'), per_page)
|
||||
if (tab == "sent_contacts"):
|
||||
page = page
|
||||
else:
|
||||
page = 1
|
||||
# sent_contacts_paginator = Paginator(sent_contacts.order_by('id'), per_page)
|
||||
# if (tab == "sent_contacts"):
|
||||
# page = page
|
||||
# else:
|
||||
# page = 1
|
||||
|
||||
try:
|
||||
sent_contacts = sent_contacts_paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
sent_contacts = sent_contacts_paginator.page(1)
|
||||
except EmptyPage:
|
||||
sent_contacts = sent_contacts_paginator.page(
|
||||
sent_contacts_paginator.num_pages)
|
||||
# try:
|
||||
# sent_contacts = sent_contacts_paginator.page(page)
|
||||
# except PageNotAnInteger:
|
||||
# sent_contacts = sent_contacts_paginator.page(1)
|
||||
# except EmptyPage:
|
||||
# sent_contacts = sent_contacts_paginator.page(
|
||||
# sent_contacts_paginator.num_pages)
|
||||
|
||||
all_contacts_paginator = Paginator(all_contacts.order_by('id'), per_page)
|
||||
if (tab == "all_contacts"):
|
||||
page = page
|
||||
else:
|
||||
page = 1
|
||||
# all_contacts_paginator = Paginator(all_contacts.order_by('id'), per_page)
|
||||
# if (tab == "all_contacts"):
|
||||
# page = page
|
||||
# else:
|
||||
# page = 1
|
||||
|
||||
try:
|
||||
all_contacts = all_contacts_paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
all_contacts = all_contacts_paginator.page(1)
|
||||
except EmptyPage:
|
||||
all_contacts = all_contacts_paginator.page(
|
||||
all_contacts_paginator.num_pages)
|
||||
# try:
|
||||
# all_contacts = all_contacts_paginator.page(page)
|
||||
# except PageNotAnInteger:
|
||||
# all_contacts = all_contacts_paginator.page(1)
|
||||
# except EmptyPage:
|
||||
# all_contacts = all_contacts_paginator.page(
|
||||
# all_contacts_paginator.num_pages)
|
||||
|
||||
read_contacts_paginator = Paginator(read_contacts.order_by('id'), per_page)
|
||||
if (tab == "read_contacts"):
|
||||
page = page
|
||||
else:
|
||||
page = 1
|
||||
# read_contacts_paginator = Paginator(read_contacts.order_by('id'), per_page)
|
||||
# if (tab == "read_contacts"):
|
||||
# page = page
|
||||
# else:
|
||||
# page = 1
|
||||
|
||||
try:
|
||||
read_contacts = read_contacts_paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
read_contacts = read_contacts_paginator.page(1)
|
||||
except EmptyPage:
|
||||
read_contacts = read_contacts_paginator.page(
|
||||
read_contacts_paginator.num_pages)
|
||||
# try:
|
||||
# read_contacts = read_contacts_paginator.page(page)
|
||||
# except PageNotAnInteger:
|
||||
# read_contacts = read_contacts_paginator.page(1)
|
||||
# except EmptyPage:
|
||||
# read_contacts = read_contacts_paginator.page(
|
||||
# read_contacts_paginator.num_pages)
|
||||
|
||||
data = {'contact_lists': contact_lists, "campaign": campaign,
|
||||
"contacts": contacts, 'unsubscribe_contacts': unsubscribe_contacts,
|
||||
|
|
@ -781,12 +787,11 @@ def campaign_details(request, pk):
|
|||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def campaign_delete(request, pk):
|
||||
try:
|
||||
campaign = Campaign.objects.get(id=pk)
|
||||
campaign.delete()
|
||||
redirect_url = reverse('marketing:campaign_list')
|
||||
except Campaign.DoesNotExist:
|
||||
redirect_url = reverse('marketing:campaign_list')
|
||||
campaign = get_object_or_404(Campaign, pk=pk)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or request.user == campaign.created_by):
|
||||
raise PermissionDenied
|
||||
campaign.delete()
|
||||
redirect_url = reverse('marketing:campaign_list')
|
||||
return redirect(redirect_url)
|
||||
|
||||
|
||||
|
|
@ -819,7 +824,7 @@ def campaign_link_click(request, link_id, email_id):
|
|||
return redirect(url)
|
||||
|
||||
|
||||
def campaign_open(request, campaign_log_id, email_id):
|
||||
def campaign_open(request, campaign_log_id, email_id): # pragma: no cover
|
||||
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
|
||||
|
||||
if x_forwarded_for:
|
||||
|
|
@ -884,36 +889,36 @@ def contact_detail(request, contact_id):
|
|||
return render(request, 'contact_detail.html', {'contact_obj': contact_obj})
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def edit_failed_contact(request, pk):
|
||||
contact_obj = get_object_or_404(FailedContact, pk=pk)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or contact_obj.created_by == request.user):
|
||||
raise PermissionDenied
|
||||
if request.method == 'GET':
|
||||
form = ContactForm(instance=contact_obj)
|
||||
return render(request, 'marketing/lists/edit_contact.html', {'form': form})
|
||||
# @login_required(login_url='/login')
|
||||
# @marketing_access_required
|
||||
# def edit_failed_contact(request, pk):
|
||||
# contact_obj = get_object_or_404(FailedContact, pk=pk)
|
||||
# if not (request.user.role == 'ADMIN' or request.user.is_superuser or contact_obj.created_by == request.user):
|
||||
# raise PermissionDenied
|
||||
# if request.method == 'GET':
|
||||
# form = ContactForm(instance=contact_obj)
|
||||
# return render(request, 'marketing/lists/edit_contact.html', {'form': form})
|
||||
|
||||
if request.method == 'POST':
|
||||
form = ContactForm(request.POST, instance=contact_obj)
|
||||
if form.is_valid():
|
||||
contact = form.save(commit=False)
|
||||
contact.save()
|
||||
form.save_m2m()
|
||||
return JsonResponse({'error': False, 'success_url': reverse('marketing:contacts_list')})
|
||||
else:
|
||||
return JsonResponse({'error': True, 'errors': form.errors, })
|
||||
# if request.method == 'POST':
|
||||
# form = ContactForm(request.POST, instance=contact_obj)
|
||||
# if form.is_valid():
|
||||
# contact = form.save(commit=False)
|
||||
# contact.save()
|
||||
# form.save_m2m()
|
||||
# return JsonResponse({'error': False, 'success_url': reverse('marketing:contacts_list')})
|
||||
# else:
|
||||
# return JsonResponse({'error': True, 'errors': form.errors, })
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def delete_failed_contact(request, pk):
|
||||
contact_obj = get_object_or_404(FailedContact, pk=pk)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or contact_obj.created_by == request.user):
|
||||
raise PermissionDenied
|
||||
if request.method == 'GET':
|
||||
contact_obj.delete()
|
||||
return redirect('marketing:contacts_list')
|
||||
# @login_required(login_url='/login')
|
||||
# @marketing_access_required
|
||||
# def delete_failed_contact(request, pk):
|
||||
# contact_obj = get_object_or_404(FailedContact, pk=pk)
|
||||
# if not (request.user.role == 'ADMIN' or request.user.is_superuser or contact_obj.created_by == request.user):
|
||||
# raise PermissionDenied
|
||||
# if request.method == 'GET':
|
||||
# contact_obj.delete()
|
||||
# return redirect('marketing:contacts_list')
|
||||
|
||||
|
||||
@login_required
|
||||
|
|
@ -948,7 +953,14 @@ def download_contacts_for_campaign(request, compaign_id):
|
|||
'company name,email,first name,last name,city,state\n',
|
||||
]
|
||||
for contact in contacts:
|
||||
data.append((', '.join(contact.values()) + '\n'))
|
||||
data.append(
|
||||
str(contact.get('company_name')) + ',' +
|
||||
str(contact.get('email')) + ',' +
|
||||
str(contact.get('name')) + ',' +
|
||||
str(contact.get('last_name')) + ',' +
|
||||
str(contact.get('city')) + ',' +
|
||||
str(contact.get('state')) + '\n'
|
||||
)
|
||||
response = HttpResponse(
|
||||
data, content_type='text/plain')
|
||||
response['Content-Disposition'] = 'attachment; filename={}'.format(
|
||||
|
|
@ -976,16 +988,16 @@ def download_links_clicked(request, campaign_id):
|
|||
if campaign_link_click_objects:
|
||||
for campaign_link_click_object in campaign_link_click_objects:
|
||||
data.append(
|
||||
campaign_link_click_object.contact.email + ',' +
|
||||
campaign_link_click_object.contact.company_name + ',' +
|
||||
campaign_link_click_object.contact.name + ',' +
|
||||
campaign_link_click_object.contact.last_name + ',' +
|
||||
campaign_link_click_object.contact.city + ',' +
|
||||
campaign_link_click_object.contact.state + ',' +
|
||||
campaign_link_click_object.link.original + ',' +
|
||||
str(campaign_link_click_object.contact.email) + ',' +
|
||||
str(campaign_link_click_object.contact.company_name) + ',' +
|
||||
str(campaign_link_click_object.contact.name) + ',' +
|
||||
str(campaign_link_click_object.contact.last_name) + ',' +
|
||||
str(campaign_link_click_object.contact.city) + ',' +
|
||||
str(campaign_link_click_object.contact.state) + ',' +
|
||||
str(campaign_link_click_object.link.original) + ',' +
|
||||
str(campaign_link_click_object.link.unique) + ',' +
|
||||
str(campaign_link_click_object.link.clicks) + ',' +
|
||||
campaign_link_click_object.link.campaign.title + '\n'
|
||||
str(campaign_link_click_object.link.campaign.title) + '\n'
|
||||
)
|
||||
response = HttpResponse(data, content_type='text/plain')
|
||||
response['Content-Disposition'] = 'attachment; filename={}'.format('data_downloads.csv')
|
||||
|
|
@ -995,7 +1007,6 @@ def download_links_clicked(request, campaign_id):
|
|||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def delete_multiple_contacts(request):
|
||||
|
||||
contacts_list = Contact.objects.filter(id__in=request.POST.getlist('selected_list[]'))
|
||||
shared_contact_lists = request.user.marketing_contactlist.all().values_list('contacts', flat=True)
|
||||
cannot_be_deleted = []
|
||||
|
|
@ -1011,14 +1022,24 @@ def delete_multiple_contacts(request):
|
|||
if contact_obj.contact_list.count() == 1:
|
||||
contact_obj.delete()
|
||||
else:
|
||||
contact_list_obj = get_object_or_404(ContactList, pk=request.POST.get('from_contact'))
|
||||
contact_obj.contact_list.remove(contact_list_obj)
|
||||
if request.POST.get('duplicate_contacts', None) == 'true':
|
||||
contact_list_obj = get_object_or_404(ContactList, pk=request.POST.get('from_contact'))
|
||||
contact_obj.contact_list.remove(contact_list_obj)
|
||||
|
||||
contact_list_duplicates = contact_list_obj.duplicate_contact_contact_list.all()
|
||||
contacts_list_ids = contacts_list.values_list('id', flat=True)
|
||||
contact_list_duplicates.filter(contacts__id__in=contacts_list_ids).delete()
|
||||
else:
|
||||
contact_list_obj = get_object_or_404(ContactList, pk=request.POST.get('from_contact'))
|
||||
contact_obj.contact_list.remove(contact_list_obj)
|
||||
|
||||
return JsonResponse({'error':False, 'refresh': True})
|
||||
else:
|
||||
message = "You don't have permission to delete {}".format(', '.join(cannot_be_deleted))
|
||||
return JsonResponse({'error': True, 'message' : message })
|
||||
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def delete_all_contacts(request, contact_list_id):
|
||||
|
|
@ -1030,13 +1051,26 @@ def delete_all_contacts(request, contact_list_id):
|
|||
bounced = True
|
||||
else:
|
||||
bounced = False
|
||||
contacts_objs = contacts_list_obj.contacts.filter(is_bounced=bounced)
|
||||
if contacts_objs:
|
||||
for contact_obj in contacts_objs:
|
||||
if contact_obj.contact_list.count() > 1:
|
||||
contact_obj.contact_list.remove(contacts_list_obj)
|
||||
else:
|
||||
contact_obj.delete()
|
||||
if request.GET.get('duplicate_contacts', '') == 'true':
|
||||
contact_list_duplicates = contacts_list_obj.duplicate_contact_contact_list.all()
|
||||
if contact_list_duplicates:
|
||||
for dup_contact_obj in contact_list_duplicates:
|
||||
if dup_contact_obj.contacts.contact_list.count() > 1:
|
||||
contact = dup_contact_obj.contacts
|
||||
contact.contact_list.remove(contacts_list_obj)
|
||||
dup_contact_obj.delete()
|
||||
# dup_contact_obj.contacts.contact_list.remove(contacts_list_obj)
|
||||
# else:
|
||||
# dup_contact_obj.contacts.delete()
|
||||
else:
|
||||
contacts_objs = contacts_list_obj.contacts.filter(is_bounced=bounced)
|
||||
if contacts_objs:
|
||||
for contact_obj in contacts_objs:
|
||||
if contact_obj.contact_list.count() > 1:
|
||||
contact_obj.contact_list.remove(contacts_list_obj)
|
||||
else:
|
||||
contact_obj.delete()
|
||||
|
||||
# delete_multiple_contacts_tasks.delay(contact_list_id, bounced)
|
||||
redirect_to = reverse('marketing:contact_list_detail', args=(contact_list_id,))
|
||||
return HttpResponseRedirect(redirect_to)
|
||||
|
|
@ -1056,7 +1090,14 @@ def download_failed_contacts(request, contact_list_id):
|
|||
'company name,email,first name,last name,city,state\n',
|
||||
]
|
||||
for contact in failed_contacts:
|
||||
data.append((', '.join(contact.values()) + '\n'))
|
||||
data.append(
|
||||
str(contact.get('company_name')) + ',' +
|
||||
str(contact.get('email')) + ',' +
|
||||
str(contact.get('name')) + ',' +
|
||||
str(contact.get('last_name')) + ',' +
|
||||
str(contact.get('city')) + ',' +
|
||||
str(contact.get('state')) + '\n'
|
||||
)
|
||||
response = HttpResponse(
|
||||
data, content_type='text/plain')
|
||||
response['Content-Disposition'] = 'attachment; filename={}'.format(
|
||||
|
|
@ -1091,7 +1132,7 @@ def add_email_for_campaigns(request):
|
|||
obj = form.save(commit=False)
|
||||
obj.created_by = request.user
|
||||
obj.save()
|
||||
return JsonResponse({'error':False, 'success_url':reverse('marketing:list_all_emails_for_campaigns')})
|
||||
return JsonResponse({'error':False, 'success_url':reverse('common:api_settings')})
|
||||
else:
|
||||
return JsonResponse({'error':True, 'errors':form.errors})
|
||||
|
||||
|
|
@ -1111,7 +1152,7 @@ def edit_email_for_campaigns(request, pk):
|
|||
if form.is_valid():
|
||||
obj = form.save(commit=False)
|
||||
obj.save()
|
||||
return JsonResponse({'error':False, 'success_url':reverse('marketing:list_all_emails_for_campaigns')})
|
||||
return JsonResponse({'error':False, 'success_url':reverse('common:api_settings')})
|
||||
else:
|
||||
return JsonResponse({'error':True, 'errors':form.errors})
|
||||
|
||||
|
|
@ -1123,4 +1164,4 @@ def delete_email_for_campaigns(request, pk):
|
|||
context = {}
|
||||
if request.method == 'GET':
|
||||
contact_obj.delete()
|
||||
return HttpResponseRedirect(reverse('marketing:list_all_emails_for_campaigns'))
|
||||
return HttpResponseRedirect(reverse('common:api_settings'))
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from opportunity.models import Opportunity
|
|||
def send_email_to_assigned_user(recipients, opportunity_id, domain='demo.django-crm.io', protocol='http'):
|
||||
""" Send Mail To Users When they are assigned to a opportunity """
|
||||
opportunity = Opportunity.objects.get(id=opportunity_id)
|
||||
created_by = opportunity.created_by
|
||||
for user in recipients:
|
||||
recipients_list = []
|
||||
user = User.objects.filter(id=user, is_active=True).first()
|
||||
|
|
|
|||
|
|
@ -197,13 +197,13 @@
|
|||
<td>{% if opportunity.lead_source %}{{ opportunity.lead_source }}{% else %}Not Specified{% endif %}
|
||||
</td>
|
||||
<td class="actions">
|
||||
<a href="{% url 'opportunities:opp_view' opportunity.id %}" class="btn btn-info view"><i
|
||||
<a href="{% url 'opportunities:opp_view' opportunity.id %}" class="btn btn-info view" title="View"><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'opportunities:opp_edit' opportunity.id %}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'opportunities:opp_edit' opportunity.id %}" class="btn btn-success edit" title="Edit" ><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
{% if request.user == opportunity.created_by or request.user.role == "ADMIN" or request.user.is_superuser %}
|
||||
<a href="{% url 'opportunities:opp_remove' opportunity.id %}"
|
||||
class="btn btn-danger delete remove_account"><i class="fas fa-trash-alt"></i></a>
|
||||
class="btn btn-danger delete remove_account" title="Delete"><i class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
16
opportunity/tests_celery_tasks.py
Normal file
16
opportunity/tests_celery_tasks.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from opportunity.tasks import send_email_to_assigned_user
|
||||
from opportunity.tests import OpportunityModel
|
||||
|
||||
|
||||
class TestCeleryTasks(OpportunityModel, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_celery_tasks(self):
|
||||
task = send_email_to_assigned_user.apply(
|
||||
([self.user.id, self.user1.id, ], self.opportunity.id,),)
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
|
@ -1,19 +1,56 @@
|
|||
Django
|
||||
celery
|
||||
django-simple-pagination==1.3
|
||||
django-compressor
|
||||
amqp==2.5.0
|
||||
arrow==0.14.2
|
||||
atomicwrites==1.3.0
|
||||
attrs==19.1.0
|
||||
Babel==2.7.0
|
||||
billiard==3.6.0.0
|
||||
boto==2.49.0
|
||||
boto3==1.9.94
|
||||
botocore==1.12.196
|
||||
celery==4.3.0
|
||||
certifi==2019.6.16
|
||||
chardet==3.0.4
|
||||
codacy-coverage==1.3.11
|
||||
coverage==4.5.3
|
||||
cssselect==1.0.3
|
||||
Django==2.2.3
|
||||
django-appconf==1.0.3
|
||||
django-compressor==2.2
|
||||
django-phonenumber-field==2.2.0
|
||||
django-storages
|
||||
psycopg2-binary
|
||||
arrow
|
||||
django-simple-pagination==1.3
|
||||
django-storages==1.7.1
|
||||
docutils==0.14
|
||||
et-xmlfile==1.0.1
|
||||
idna==2.8
|
||||
importlib-metadata==0.18
|
||||
jdcal==1.4.1
|
||||
jmespath==0.9.4
|
||||
kombu==4.6.3
|
||||
lxml==4.3.2
|
||||
more-itertools==7.2.0
|
||||
openpyxl==2.6.0
|
||||
pdfkit==0.6.1
|
||||
phonenumbers==8.10.4
|
||||
requests
|
||||
boto3
|
||||
lxml
|
||||
cssselect
|
||||
openpyxl
|
||||
xlrd
|
||||
pdfkit
|
||||
redis
|
||||
coverage
|
||||
raven
|
||||
Pillow==5.4.1
|
||||
pluggy==0.12.0
|
||||
psycopg2-binary==2.7.7
|
||||
py==1.8.0
|
||||
pytest==4.1.1
|
||||
pytest-cov==2.6.1
|
||||
pytest-django==3.4.5
|
||||
python-dateutil==2.8.0
|
||||
pytz==2018.9
|
||||
raven==6.10.0
|
||||
rcssmin==1.0.6
|
||||
redis==3.2.1
|
||||
requests==2.22.0
|
||||
rjsmin==1.0.12
|
||||
s3transfer==0.2.1
|
||||
six==1.12.0
|
||||
sorl-thumbnail==12.5.0
|
||||
sqlparse==0.3.0
|
||||
urllib3==1.25.3
|
||||
vine==1.3.0
|
||||
xlrd==1.2.0
|
||||
xlwt==1.3.0
|
||||
zipp==0.5.2
|
||||
|
|
|
|||
|
|
@ -1,19 +1,23 @@
|
|||
django==2.2.4
|
||||
celery==4.3.0
|
||||
django-2.2.4
|
||||
celery-4.3.0
|
||||
django-simple-pagination==1.3
|
||||
django-compressor==2.3
|
||||
django-compressor-2.3
|
||||
sorl-thumbnail==12.5.0
|
||||
django-phonenumber-field==2.2.0
|
||||
django-storages==1.7.1
|
||||
phonenumbers==8.10.4
|
||||
django-storages==1.7
|
||||
psycopg2-binary==2.8.3
|
||||
arrow==0.14.5
|
||||
phonenumbers==8.10.4
|
||||
requests==2.22.0
|
||||
boto3==1.9.207
|
||||
boto3==1.9.212
|
||||
lxml==4.4.1
|
||||
cssselect==1.1.0
|
||||
openpyxl==2.6.2
|
||||
xlrd==1.2.0
|
||||
xlwt==1.3.0
|
||||
openpyxl==2.6.3
|
||||
pdfkit==0.6.1
|
||||
redis==3.3.7
|
||||
redis==3.3.8
|
||||
coverage==4.5.4
|
||||
raven==6.10.0
|
||||
pytest==5.1.1
|
||||
pytest-django==3.5.1
|
||||
codacy-coverage==1.3.11
|
||||
|
|
|
|||
|
|
@ -155,15 +155,14 @@
|
|||
{% if task_obj %}
|
||||
$('#id_due_date').datetimepicker({
|
||||
'format': 'YYYY-MM-DD',
|
||||
minDate: today
|
||||
})
|
||||
{% else %}
|
||||
var date = new Date();
|
||||
var today = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
||||
$('#id_due_date').datetimepicker({
|
||||
'format': 'YYYY-MM-DD',
|
||||
minDate: today
|
||||
})
|
||||
var date = new Date();
|
||||
var today = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -170,11 +170,11 @@
|
|||
<td title="{{task.created_on}}">{{task.created_on_arrow}}</td>
|
||||
<td class="actions">
|
||||
{% if request.user == task.created_by or request.user.role == 'ADMIN' %}
|
||||
<a href="{% url 'tasks:task_detail' task.id %}" class="btn btn-info edit"><i
|
||||
<a href="{% url 'tasks:task_detail' task.id %}" class="btn btn-info edit" title="View" ><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'tasks:task_edit' task.id %}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'tasks:task_edit' task.id %}" class="btn btn-success edit" title="Edit" ><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'tasks:task_delete' task.id %}" class="btn btn-danger delete remove_document"><i
|
||||
<a href="{% url 'tasks:task_delete' task.id %}" class="btn btn-danger delete remove_document" title="Delete" ><i
|
||||
class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
@ -233,11 +233,11 @@
|
|||
<td title="{{task.created_on}}">{{task.created_on_arrow}}</td>
|
||||
<td class="actions">
|
||||
{% if request.user == task.created_by or request.user.role == 'ADMIN' %}
|
||||
<a href="{% url 'tasks:task_detail' task.id %}" class="btn btn-info edit"><i
|
||||
<a href="{% url 'tasks:task_detail' task.id %}" class="btn btn-info edit" title="View"><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'tasks:task_edit' task.id %}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'tasks:task_edit' task.id %}" class="btn btn-success edit" title="Edit" ><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'tasks:task_delete' task.id %}" class="btn btn-danger delete remove_document"><i
|
||||
<a href="{% url 'tasks:task_delete' task.id %}" class="btn btn-danger delete remove_document" title="Delete" ><i
|
||||
class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
@ -295,11 +295,11 @@
|
|||
<td title="{{task.created_on}}">{{task.created_on_arrow}}</td>
|
||||
<td class="actions">
|
||||
{% if request.user == task.created_by or request.user.role == 'ADMIN' %}
|
||||
<a href="{% url 'tasks:task_detail' task.id %}" class="btn btn-info edit"><i
|
||||
<a href="{% url 'tasks:task_detail' task.id %}" class="btn btn-info edit" title="View"><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'tasks:task_edit' task.id %}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'tasks:task_edit' task.id %}" class="btn btn-success edit" title="Edit"><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'tasks:task_delete' task.id %}" class="btn btn-danger delete remove_document"><i
|
||||
<a href="{% url 'tasks:task_delete' task.id %}" class="btn btn-danger delete remove_document" title="Delete"><i
|
||||
class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
|
|||
15
tasks/tests_celery_tasks.py
Normal file
15
tasks/tests_celery_tasks.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from tasks.celery_tasks import send_email
|
||||
from tasks.tests import TaskCreateTest
|
||||
|
||||
|
||||
class TestEventCeleryTasks(TaskCreateTest, TestCase):
|
||||
|
||||
@override_settings(CELERY_EAGER_PROPAGATES_EXCEPTIONS=True,
|
||||
CELERY_ALWAYS_EAGER=True,
|
||||
BROKER_BACKEND='memory')
|
||||
def test_event_celery_tasks(self):
|
||||
task = send_email.apply((self.task.id,))
|
||||
self.assertEqual('SUCCESS', task.state)
|
||||
|
|
@ -172,12 +172,12 @@
|
|||
<td title="{{ team.created_on }}">{{ team.created_on_arrow }}</td>
|
||||
<td class="actions">
|
||||
{% if request.user == team.created_by or request.user.role == 'ADMIN' or reques.user.is_superuser %}
|
||||
<a href="{% url 'teams:team_detail' team.id %}" class="btn btn-info edit"><i
|
||||
<a href="{% url 'teams:team_detail' team.id %}" class="btn btn-info edit" title="View"><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'teams:team_edit' team.id %}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'teams:team_edit' team.id %}" class="btn btn-success edit" title="Edit"><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'teams:team_delete' team.id %}"
|
||||
class="btn btn-danger delete remove_document"><i class="fas fa-trash-alt"></i></a>
|
||||
class="btn btn-danger delete remove_document" title="Delete"><i class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@ Hi {{ user.get_username }}
|
|||
{% block button_link %}
|
||||
<div style="margin-bottom:20px">
|
||||
<a href="{{url}}"
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">click here</a>
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">Click Here</a>
|
||||
</div>
|
||||
{% endblock button_link %}
|
||||
|
|
@ -13,6 +13,6 @@ Hello {{ user.get_username }}
|
|||
{% block button_link %}
|
||||
<div style="margin-bottom:20px">
|
||||
<a href="{{url}}"
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">click here</a>
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">Click Here</a>
|
||||
</div>
|
||||
{% endblock button_link %}
|
||||
|
|
@ -13,6 +13,6 @@ Hi {{ user.get_username }}
|
|||
{% block button_link %}
|
||||
<div style="margin-bottom:20px">
|
||||
<a href="{{url}}"
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">click here</a>
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">Click Here</a>
|
||||
</div>
|
||||
{% endblock button_link %}
|
||||
|
|
@ -7,12 +7,26 @@ Hi {{ user.get_username }}
|
|||
|
||||
|
||||
{% block content_body %}
|
||||
|
||||
{% if created_by %}
|
||||
{{created_by}} assigned a lead for you - {{ lead.title }}<br>
|
||||
{% else %}
|
||||
A lead has been assigned for you - {{ lead.title }}<br>
|
||||
|
||||
{% if source %}
|
||||
<p style="font-size: 15px; margin-right: 20em; margin-top: 2em;">
|
||||
Source: {{ source }} <br>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endblock content_body %}
|
||||
|
||||
{% block button_link %}
|
||||
<div style="margin-bottom:20px">
|
||||
<a href="{{url}}"
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">click here</a>
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">Click
|
||||
Here</a>
|
||||
</div>
|
||||
{% endblock button_link %}
|
||||
|
|
@ -13,6 +13,6 @@ Hello {{ user.get_username }}
|
|||
{% block button_link %}
|
||||
<div style="margin-bottom:20px">
|
||||
<a href="{{url}}"
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">click here</a>
|
||||
style="display:inline-block;width:170px;background:#38abdd;padding:10px;text-align:center;color:#fff;font-size:1rem;font-weight:600;margin:0px auto;margin-bottom:20px;border-radius:5px;text-decoration:none;display:block">Click Here</a>
|
||||
</div>
|
||||
{% endblock button_link %}
|
||||
|
|
@ -129,13 +129,10 @@
|
|||
{% endif %}
|
||||
</td>
|
||||
<td class="actions text-center">
|
||||
<a href="{% url 'marketing:campaign_details' campaign.id %}" class="btn btn-success view"><i
|
||||
<a href="{% url 'marketing:campaign_details' campaign.id %}" class="btn btn-success view" title="View"><i
|
||||
class="fas fa-eye"></i></a>
|
||||
<!--
|
||||
<a href="{% url 'marketing:campaign_edit' campaign.id %}" class="btn btn-success edit"><i class="fas fa-edit"></i></a>
|
||||
-->
|
||||
<a href="{% url 'marketing:campaign_delete' campaign.id %}"
|
||||
class="btn btn-danger delete remove_account"><i class="fas fa-trash"></i></a>
|
||||
class="btn btn-danger delete remove_account" title="Delete"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
|
|
|
|||
|
|
@ -101,11 +101,11 @@
|
|||
class="fas fa-eye"></i> View Template</a></td> -->
|
||||
<td class="actions text-center">
|
||||
<a href="{% url 'marketing:email_template_detail' email_template.id %}"
|
||||
class="btn btn-info edit"><i class="fas fa-eye"></i></a>
|
||||
class="btn btn-info edit" title="View" ><i class="fas fa-eye"></i></a>
|
||||
<a href="{% url 'marketing:email_template_edit' email_template.id %}"
|
||||
class="btn btn-success edit"><i class="fas fa-edit"></i></a>
|
||||
class="btn btn-success edit" title="Edit" ><i class="fas fa-edit"></i></a>
|
||||
<a href="{% url 'marketing:email_template_delete' email_template.id %}"
|
||||
class="btn btn-danger delete remove_account"><i class="fas fa-trash"></i></a>
|
||||
class="btn btn-danger delete remove_account" title="Delete"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
<div class="card-body ">
|
||||
<div class="card-title">Filters</div>
|
||||
<div class="row marl">
|
||||
<div class="filter_col col-md-3">
|
||||
<div class="filter_col col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Name</label>
|
||||
<input type="text" class="form-control" placeholder="Contact Name" name="contact_name"
|
||||
|
|
@ -40,13 +40,27 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-3">
|
||||
<div class="filter_col col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Email</label>
|
||||
<input type="text" class="form-control" placeholder="Contact Email" name="contact_email"
|
||||
value="{{request.POST.contact_email}}" minlength="2">
|
||||
</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">
|
||||
|
|
@ -117,7 +131,9 @@
|
|||
<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_list.all|length}}'><i
|
||||
data-other-contacts-lists='{{contact.contact_list.all|length}}'
|
||||
title="Delete"
|
||||
><i
|
||||
class="fas fa-trash-alt"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -81,10 +81,16 @@
|
|||
</li>
|
||||
{% if contact_list.failed_contacts.all %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="close-tab" data-toggle="tab" href="#failed_contacts" role="tab"
|
||||
<a class="nav-link" id="failed-contacts" data-toggle="tab" href="#failed_contacts" role="tab"
|
||||
aria-controls="close" aria-selected="false">Failed Contacts</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if contact_list.duplicate_contact_contact_list.all %}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="duplicate-contacts" data-toggle="tab" href="#duplicate_contacts" role="tab"
|
||||
aria-controls="close" aria-selected="false">Duplicate Contacts</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="open" role="tabpanel" aria-labelledby="open">
|
||||
|
|
@ -140,12 +146,12 @@
|
|||
<td> <a href="{% url 'marketing:contact_detail' contact.id %}">{{ contact.email }}</a> </td>
|
||||
<td class="actions">
|
||||
<a href="{% url 'marketing:edit_contact' contact.id %}?from_contact={{contact_list.id}}"
|
||||
class="btn btn-success edit edit_contact"
|
||||
class="btn btn-success edit edit_contact" title="Edit"
|
||||
data-other-contacts-lists='{{contact.contact_list.all|length}}'><i
|
||||
class="fas fa-edit"></i></a>
|
||||
<!-- <a href="/contacts/1/edit/" class="btn btn-info duplicate"><i class="fas fa-copy"></i></a> -->
|
||||
<a href="{% url 'marketing:delete_contact' contact.id %}?from_contact={{contact_list.id}}"
|
||||
class="btn btn-danger delete remove_account"
|
||||
class="btn btn-danger delete remove_account" title="Delete"
|
||||
data-other-contacts-lists='{{contact.contact_list.all|length}}'><i
|
||||
class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
|
|
@ -216,12 +222,12 @@
|
|||
<td> <a href="{% url 'marketing:contact_detail' contact.id %}">{{ contact.email }}</a> </td>
|
||||
<td class="actions">
|
||||
<a href="{% url 'marketing:edit_contact' contact.id %}?from_contact={{contact_list.id}}"
|
||||
class="btn btn-success edit edit_contact"
|
||||
class="btn btn-success edit edit_contact" title="Edit"
|
||||
data-other-contacts-lists='{{contact.contact_list.all|length}}'><i
|
||||
class="fas fa-edit"></i></a>
|
||||
<!-- <a href="/contacts/1/edit/" class="btn btn-info duplicate"><i class="fas fa-copy"></i></a> -->
|
||||
<a href="{% url 'marketing:delete_contact' contact.id %}?from_contact={{contact_list.id}}"
|
||||
class="btn btn-danger delete remove_account"
|
||||
class="btn btn-danger delete remove_account" title="Delete"
|
||||
data-other-contacts-lists='{{contact.contact_list.all|length}}'><i
|
||||
class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
|
|
@ -264,6 +270,83 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="duplicate_contacts" 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 %}{{duplicate_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_duplicate" style="background:black; color: white;">Delete
|
||||
Selected</button>
|
||||
<button href="#" class="primary_btn" id="delete_all_complete_duplicate"
|
||||
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_duplicate" id="check_all_duplicate">
|
||||
</th>
|
||||
<th width="5%">ID</th>
|
||||
<th width="20%">Name</th>
|
||||
<th width="20%">Email</th>
|
||||
<th width="10%">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<span><b>Tags : </b></span>
|
||||
{% for tag in contact_list.tags.all %}
|
||||
<span class="text-left color{{forloop.counter}} tag_class_cl" id="list_tag"
|
||||
data-link="{{tag.id}}" style="cursor: pointer;">{{tag.name}}</span>
|
||||
{% empty %}
|
||||
<span class="text-left">No Tags</span>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% if per_page %}
|
||||
{% paginate per_page duplicate_contacts %}
|
||||
{% else%}
|
||||
{% paginate 10 duplicate_contacts %}
|
||||
{% endif %}
|
||||
{% for contact in duplicate_contacts %}
|
||||
<tr style="text-align:center;">
|
||||
<td>
|
||||
<input type="checkbox" class="check_delete_duplicate" name="{{contact.contacts.email}}" id="{{contact.id}}"
|
||||
value="{{contact.contacts.id}}">
|
||||
</td>
|
||||
<td scope="row">{{ forloop.counter }}</td>
|
||||
<td>{{ contact.contacts.name }}</td>
|
||||
<td> <a href="{% url 'marketing:contact_detail' contact.contacts.id %}">{{ contact.contacts.email }}</a> </td>
|
||||
<td class="actions">
|
||||
<a href="{% url 'marketing:edit_contact' contact.contacts.id %}?from_contact={{contact.contact_list.id}}"
|
||||
class="btn btn-success edit edit_contact" title="Edit"
|
||||
data-other-contacts-lists='{{contact.contact_list.all|length}}'><i
|
||||
class="fas fa-edit"></i></a>
|
||||
<!-- <a href="/contacts/1/edit/" class="btn btn-info duplicate"><i class="fas fa-copy"></i></a> -->
|
||||
<a href="{% url 'marketing:delete_contact' contact.id %}?from_contact={{contact.contact_list.id}}"
|
||||
class="btn btn-danger delete remove_account" title="Delete"
|
||||
data-other-contacts-lists='{{contact.contact_list.all|length}}'><i
|
||||
class="fas fa-trash"></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>
|
||||
<br clear="all">
|
||||
</div>
|
||||
|
|
@ -291,6 +374,8 @@
|
|||
$('#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')
|
||||
|
|
@ -322,7 +407,7 @@
|
|||
}
|
||||
})
|
||||
|
||||
$('#delete_all_complete').click(function(){
|
||||
$('#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)
|
||||
|
|
@ -394,7 +479,7 @@
|
|||
}
|
||||
})
|
||||
|
||||
$('#delete_all_bounced_complete').click(function(){
|
||||
$('#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)
|
||||
|
|
@ -443,6 +528,80 @@
|
|||
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
window.location.href = "{% url 'marketing:delete_all_contacts' contact_list.id %}?duplicate_contacts=true"
|
||||
})
|
||||
|
||||
$('#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')
|
||||
|
|
@ -487,12 +646,16 @@
|
|||
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')) {
|
||||
//active the tab
|
||||
// $('#open-tab').removeClass('active')
|
||||
// $('#close-tab').addClass('active')
|
||||
$('#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 %}
|
||||
|
|
@ -85,13 +85,15 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th width="5%">S. No</th>
|
||||
<th width="20%">Name</th>
|
||||
<th width="10%">Name</th>
|
||||
<th width="10%">No. of Contacts</th>
|
||||
<th width="15%">No. of Bounced Contacts</th>
|
||||
<th width="15%">No. of Failed Contacts</th>
|
||||
<th width="15%">No. of Duplicates Contacts</th>
|
||||
<th width="20%" class="text-center">Created by</th>
|
||||
<th width="10%">Last Activity</th>
|
||||
<th width="15%" class="text-center">Tags</th>
|
||||
<th width="10%">Actions</th>
|
||||
<th width="5%">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% endif %}
|
||||
|
|
@ -115,6 +117,16 @@
|
|||
{{ contact_list.bounced_contacts }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'marketing:contact_list_detail' contact_list.id %}?failed_contacts">
|
||||
{{ contact_list.failed_contacts.count }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="{% url 'marketing:contact_list_detail' contact_list.id %}?duplicate_contacts">
|
||||
{{ contact_list.duplicate_contact_contact_list.count }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="text-center">{{ contact_list.created_by }}</td>
|
||||
<td title="{{ contact_list.updated_on }}">
|
||||
{{ contact_list.updated_on_arrow }}
|
||||
|
|
@ -127,7 +139,7 @@
|
|||
{% endfor %}
|
||||
</td>
|
||||
<td class="actions text-center">
|
||||
<a href="{% url 'marketing:edit_contact_list' contact_list.id %}" class="btn btn-success edit"><i
|
||||
<a href="{% url 'marketing:edit_contact_list' contact_list.id %}" class="btn btn-success edit" title="Edit"><i
|
||||
class="fas fa-edit"></i></a>
|
||||
<!-- <a href="/contacts/1/edit/" class="btn btn-info duplicate"><i class="fas fa-copy"></i></a> -->
|
||||
{% comment %}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,18 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% with teams=user_obj.user_teams.all %}
|
||||
{% if teams %}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="acc_field_label" for="id_industry" data-name="name">Teams</label>
|
||||
{% for team in teams %}
|
||||
<div class="account_field" id="account_industry" data-name="name">{{ team }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="profile_pic">
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
</tr>
|
||||
|
||||
<tr>
|
||||
<td style="text-align:center;font-weight: 300;padding:25px 75px;color:#000;font-size:20px;">
|
||||
<td style="text-align:center;font-weight: 300;padding:25px 75px;color:#000;font-size:18px;">
|
||||
<!-- You Have been invited to organisation in DjangoCrm. -->
|
||||
|
||||
{% block content_body %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue