Skip to content

Commit

Permalink
added duplicate contacts tabs, fixed time format in marketing campaig…
Browse files Browse the repository at this point in the history
…n 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
  • Loading branch information
KingCSharp committed Sep 10, 2019
1 parent fae231f commit 547656d
Show file tree
Hide file tree
Showing 62 changed files with 3,083 additions and 759 deletions.
28 changes: 28 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -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 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions accounts/templates/accounts.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down Expand Up @@ -269,12 +269,12 @@ <h6 class="text-center">No Acccount Records Found</h6>
{% 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 %}
Expand Down
34 changes: 34 additions & 0 deletions accounts/tests_celery_tasks.py
Original file line number Diff line number Diff line change
@@ -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='[email protected]'
)
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)
8 changes: 4 additions & 4 deletions cases/templates/cases.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
16 changes: 16 additions & 0 deletions cases/tests_celery_tasks.py
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 15 additions & 2 deletions common/templates/create.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
8 changes: 4 additions & 4 deletions common/templates/doc_list_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
20 changes: 18 additions & 2 deletions common/templates/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ <h4><span class="glyphicon glyphicon-lock"></span> Change Password</h4>
</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>
Expand Down Expand Up @@ -184,7 +197,7 @@ <h4><span class="glyphicon glyphicon-lock"></span> Change Password</h4>
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>
Expand Down Expand Up @@ -264,7 +277,7 @@ <h6 class="text-center">No Active Users Found</h6>
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>
Expand Down Expand Up @@ -296,6 +309,9 @@ <h6 class="text-center">No Closed Acccount Records Found</h6>
$(".filter_toggle").click(function () {
$(".list_filter_row").toggle();
});
if ($('#id_user_status').val() === 'False') {
$('#close-tab').click()
}
});

$('.trash').click(function (e) {
Expand Down
Loading

0 comments on commit 547656d

Please sign in to comment.