Merge pull request #359 from ashwin31/ashwin

added docs
This commit is contained in:
Ashwin Kumar 2020-02-23 17:15:48 +05:30 committed by GitHub
commit 209a4869ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
140 changed files with 3369 additions and 1581 deletions

View file

@ -23,7 +23,7 @@ class AccountForm(forms.ModelForm):
self.fields['status'].required = False
for key, value in self.fields.items():
if key == 'phone':
value.widget.attrs['placeholder'] = "+91-123-456-7890"
value.widget.attrs['placeholder'] = "+911234567890"
else:
value.widget.attrs['placeholder'] = value.label

View file

@ -15,7 +15,7 @@
</nav>
{% endblock %}
{% block content %}
{% if contact_count %}
{% if contact_count or edit_view%}
<form id="formid" action='' method="POST" novalidate enctype="multipart/form-data">
<div class="overview_form_block row marl justify-content-center">
<div class="col-md-9">
@ -187,14 +187,14 @@
<select name="assigned_to" id="id_assigned_to" class="assigned_users form-control" multiple>
{% for user in users %}
{% if user.is_active %}
<option value="{{user.id}}" {% if user in account_obj.assigned_to.all %} selected="" {% endif %}>
<option value="{{user.id}}" {% if user in account_obj.get_assigned_users_not_in_teams %} selected="" {% endif %}>
{{user.email}}</option>
{% endif %}
{% endfor %}
</select>
<input type="hidden" id="id_assigned_to_hidden" name="assigned_to_">
<span class="error" id="id__assigned_to">{{ account_form.assigned_to.errors }}</span>
<span class="error" id="error_id_assigned_to">{{ account_form.assigned_to.errors }}</span>
<!-- <label for="id_sattus">Assign To{% if account_form.assigned_to.field.required %}<span
class="error">*</span>{% endif %}</label>
@ -383,44 +383,171 @@
console.log($value);
});
function find_dict(dict, id){
var index = dict.map(function(o) { return o.team; }).indexOf(parseInt(id));
return dict[index]['users']
}
$("#id_teams").change(function (e) {
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
if (!users) {
// users = []
} else {
users = users.concat(_data.split(','))
}
})
// users = $('option:selected', this).attr('data-users')
// if (!users) {
// users = []
// } else {
// users = users.split(',')
// }
console.log('selected users teams data', users)
var existingUsers = $('#id_assigned_to').val();
var allUsers = users.concat(existingUsers)
console.log(existingUsers)
if (users.length) {
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
var teams = []
var all_users = []
var selected_teams = []
var selected_users = []
var assigned_users = []
$.get("{% url 'accounts:get_teams_and_users' %}", function(data){
// console.log(data)
if(($('#id_teams').val()).length==0){
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2().trigger('change');
}
teams = data['teams']
all_users = data['users']
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
selected_teams.push($(this).val())
selected_users.push(find_dict(teams, $(this).val()))
// console.log("s_users", selected_users)
var un_select_users = [].concat.apply([], selected_users)
// console.log('un select users', un_select_users);
$('#id_assigned_to option').each(function () {
if($.inArray(parseInt($(this).val()), un_select_users) != -1){
$(this).attr('disabled', 'disabled')
$('#id_assigned_to').select2();
}
else{
$(this).show()
$(this).removeAttr('disabled')
$('#id_assigned_to').select2();
}
}
)
if (!selected_teams) {
users = []
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2();
} else {
users = users.concat(_data.split(','))
}
});
$('#id_teams option').each(function () {
if ($(this).is(':selected')) {
_data = $(this).attr('data-users').split(',')
// console.log(' selected', $(this).attr('data-users').split(','))
// console.log('selected', $(this).attr('data-users'))
}
else {
_unselected = $(this).attr('data-users').split(',')
// console.log('un selected', $(this).attr('data-users').split(','))
}
});
// console.log('selected users teams data', users)
var existingUsers = $('#id_assigned_to').val();
var allUsers = users
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
if (users.length) {
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val([]).trigger('change');
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val(existingUsers).trigger('change');
}
})
});
// $('#call_save').click(function (e) {
// e.preventDefault()
// console.log($('#formid').serialize())
// console.log($('#formid').serializeArray())
// })
$(document).ready(function($) {
var teams = []
var all_users = []
var selected_teams = []
var selected_users = []
var assigned_users = []
$.get("{% url 'accounts:get_teams_and_users' %}", function(data){
if(($('#id_teams').val()).length==0){
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
// $('#id_assigned_to').select2().val([]).trigger('change');
}
teams = data['teams']
all_users = data['users']
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
selected_teams.push($(this).val())
selected_users.push(find_dict(teams, $(this).val()))
var un_select_users = [].concat.apply([], selected_users)
$('#id_assigned_to option').each(function () {
if($.inArray(parseInt($(this).val()), un_select_users) != -1){
// $(this).attr('disabled', 'disabled')
$(this).attr('disabled', 'disabled')
$('#id_assigned_to').select2();
}
else{
$(this).show()
$(this).removeAttr('disabled')
$('#id_assigned_to').select2();
}
}
)
if (!selected_teams) {
users = []
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2();
} else {
users = users.concat(_data.split(','))
}
});
$('#id_teams option').each(function () {
if ($(this).is(':selected')) {
_data = $(this).attr('data-users').split(',')
}
else {
_unselected = $(this).attr('data-users').split(',')
}
});
var existingUsers = $('#id_assigned_to').val();
// var allUsers = users.concat(existingUsers)
var allUsers = users
// console.log(existingUsers)
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
if (users.length) {
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val([]).trigger('change');
}
})
});
</script>
{% endblock js_block %}

View file

@ -527,7 +527,7 @@ class test_account_views_list(AccountCreateTest, TestCase):
self.client.login(email='johnAccount@example.com', password='password')
response = self.client.post(reverse('accounts:new_account'), {
'name': "account", 'email': "johndoe@example.com",
'phone': "+91-123-456-7894",
'phone': "+911234567894",
'billing_address_line': "address line",
'billing_street': "billing street",
'billing_city': "billing city",
@ -544,7 +544,7 @@ class test_account_views_list(AccountCreateTest, TestCase):
response = self.client.post(reverse('accounts:new_account'), {
'name': "account", 'email': "johndoe@example.com",
'phone': "+91-123-456-7894",
'phone': "+911234567894",
'billing_address_line': "address line",
'billing_street': "billing street",
'billing_city': "billing city",
@ -561,7 +561,7 @@ class test_account_views_list(AccountCreateTest, TestCase):
response = self.client.post(reverse('accounts:new_account'), {
'name': "account", 'email': "johndoe@example.com",
'phone': "+91-123-456-7894",
'phone': "+911234567894",
'billing_address_line': "address line",
'billing_street': "billing street",
'billing_city': "billing city",
@ -579,7 +579,7 @@ class test_account_views_list(AccountCreateTest, TestCase):
response = self.client.post(reverse('accounts:new_account'), {
'name': "account", 'email': "johndoe@example.com",
'phone': "+91-123-456-789",
'phone': "+91123456789",
'billing_address_line': "address line",
'billing_street': "billing street",
'billing_city': "billing city",

View file

@ -3,7 +3,8 @@ from accounts.views import (
AccountsListView, CreateAccountView, AccountDetailView, AccountUpdateView,
AccountDeleteView, AddCommentView, UpdateCommentView, DeleteCommentView,
AddAttachmentView, DeleteAttachmentsView, create_mail, # get_account_details,
get_contacts_for_account, get_email_data_for_account
get_contacts_for_account, get_email_data_for_account,
get_teams_and_users
)
app_name = 'accounts'
@ -29,6 +30,8 @@ urlpatterns = [
name="get_contacts_for_account"),
path('get_email_data_for_account/', get_email_data_for_account,
name="get_email_data_for_account"),
path('get_teams_and_users/',
get_teams_and_users, name="get_teams_and_users"),
# path('get-account-details/<int:account_id>/', get_account_details, name="get_account_details"),
]

View file

@ -30,6 +30,17 @@ from opportunity.models import SOURCES, STAGES, Opportunity
from teams.models import Teams
@login_required
def get_teams_and_users(request):
data = {}
teams = Teams.objects.all()
teams_data = [{'team': team.id, 'users': [user.id for user in team.users.all()]} for team in teams]
users = User.objects.all().values_list("id", flat=True)
data['teams'] = teams_data
data['users'] = list(users)
return JsonResponse(data)
class AccountsListView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateView):
model = Account
context_object_name = "accounts_list"
@ -390,6 +401,7 @@ class AccountUpdateView(SalesAccessRequiredMixin, LoginRequiredMixin, UpdateView
context["industries"] = INDCHOICES
context["countries"] = COUNTRIES
context["contact_count"] = Contact.objects.count()
context['edit_view'] = True
if self.request.user.role == 'ADMIN':
context["leads"] = Lead.objects.exclude(
status__in=['converted', 'closed'])

View file

@ -113,7 +113,7 @@
<select class="assigned_users form-control" name="assigned_to" multiple="multiple"
id="id_assigned_to">
{% for user in users %}
<option value="{{user.id}}" {% if user in case_obj.assigned_to.all or user.id in assignedto_list %}
<option value="{{user.id}}" {% if user in case_obj.get_assigned_users_not_in_teams or user.id in assignedto_list %}
selected="" {% endif %}>{{user.email}}</option>
{% endfor %}
</select>
@ -310,36 +310,170 @@
}
}
$("#id_teams").change(function (e) {
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
if (!users) {
// users = []
} else {
users = users.concat(_data.split(','))
}
})
// users = $('option:selected', this).attr('data-users')
// if (!users) {
// users = []
// } else {
// users = users.split(',')
// }
console.log('selected users teams data', users)
var existingUsers = $('#id_assigned_to').val();
var allUsers = users.concat(existingUsers)
console.log(existingUsers)
if (users.length) {
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
function find_dict(dict, id){
var index = dict.map(function(o) { return o.team; }).indexOf(parseInt(id));
return dict[index]['users']
}
$("#id_teams").change(function (e) {
var teams = []
var all_users = []
var selected_teams = []
var selected_users = []
var assigned_users = []
$.get("{% url 'cases:get_teams_and_users' %}", function(data){
// console.log(data)
if(($('#id_teams').val()).length==0){
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2().trigger('change');
}
teams = data['teams']
all_users = data['users']
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
selected_teams.push($(this).val())
selected_users.push(find_dict(teams, $(this).val()))
// console.log("s_users", selected_users)
var un_select_users = [].concat.apply([], selected_users)
// console.log('un select users', un_select_users);
$('#id_assigned_to option').each(function () {
if($.inArray(parseInt($(this).val()), un_select_users) != -1){
$(this).attr('disabled', 'disabled')
$('#id_assigned_to').select2();
}
else{
$(this).show()
$(this).removeAttr('disabled')
$('#id_assigned_to').select2();
}
}
)
if (!selected_teams) {
users = []
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2();
} else {
users = users.concat(_data.split(','))
}
});
$('#id_teams option').each(function () {
if ($(this).is(':selected')) {
_data = $(this).attr('data-users').split(',')
// console.log(' selected', $(this).attr('data-users').split(','))
// console.log('selected', $(this).attr('data-users'))
}
else {
_unselected = $(this).attr('data-users').split(',')
// console.log('un selected', $(this).attr('data-users').split(','))
}
});
// console.log('selected users teams data', users)
var existingUsers = $('#id_assigned_to').val();
var allUsers = users
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
if (users.length) {
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val([]).trigger('change');
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val(existingUsers).trigger('change');
}
})
});
$(document).ready(function($) {
var teams = []
var all_users = []
var selected_teams = []
var selected_users = []
var assigned_users = []
$.get("{% url 'cases:get_teams_and_users' %}", function(data){
if(($('#id_teams').val()).length==0){
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
// $('#id_assigned_to').select2().val([]).trigger('change');
}
teams = data['teams']
all_users = data['users']
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
selected_teams.push($(this).val())
selected_users.push(find_dict(teams, $(this).val()))
var un_select_users = [].concat.apply([], selected_users)
$('#id_assigned_to option').each(function () {
if($.inArray(parseInt($(this).val()), un_select_users) != -1){
// $(this).attr('disabled', 'disabled')
$(this).attr('disabled', 'disabled')
$('#id_assigned_to').select2();
}
else{
$(this).show()
$(this).removeAttr('disabled')
$('#id_assigned_to').select2();
}
}
)
if (!selected_teams) {
users = []
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2();
} else {
users = users.concat(_data.split(','))
}
});
$('#id_teams option').each(function () {
if ($(this).is(':selected')) {
_data = $(this).attr('data-users').split(',')
}
else {
_unselected = $(this).attr('data-users').split(',')
}
});
var existingUsers = $('#id_assigned_to').val();
// var allUsers = users.concat(existingUsers)
var allUsers = users
// console.log(existingUsers)
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
if (users.length) {
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val([]).trigger('change');
}
})
});
</script>

View file

@ -2,7 +2,7 @@ from django.urls import path
from cases.views import (
CasesListView, create_case, CaseDetailView, update_case, RemoveCaseView,
CloseCaseView, select_contact, GetCasesView, AddCommentView,
UpdateCommentView, DeleteCommentView,
UpdateCommentView, DeleteCommentView, get_teams_and_users,
AddAttachmentView, DeleteAttachmentsView)
app_name = 'cases'
@ -28,4 +28,6 @@ urlpatterns = [
AddAttachmentView.as_view(), name="add_attachment"),
path('attachment/remove/', DeleteAttachmentsView.as_view(),
name="remove_attachment"),
path('get_teams_and_users/', get_teams_and_users,
name="get_teams_and_users"),
]

View file

@ -25,6 +25,17 @@ from common.access_decorators_mixins import (
from teams.models import Teams
@login_required
def get_teams_and_users(request):
data = {}
teams = Teams.objects.all()
teams_data = [{'team': team.id, 'users': [user.id for user in team.users.all()]} for team in teams]
users = User.objects.all().values_list("id", flat=True)
data['teams'] = teams_data
data['users'] = list(users)
return JsonResponse(data)
class CasesListView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateView):
model = Case
context_object_name = "cases"

View file

@ -87,7 +87,7 @@
<select class="assigned_users form-control" name="shared_to" multiple="multiple" id="id_assigned_to">
{% for user in users %}
{% if user != request.user %}
<option value="{{user.id}}" {% if user in doc_obj.shared_to.all or user.id in sharedto_list %}
<option value="{{user.id}}" {% if user in doc_obj.get_assigned_users_not_in_teams or user.id in sharedto_list %}
selected="" {% endif %}>{{user.email}}</option>
{% endif %}
{% endfor %}
@ -200,38 +200,171 @@
$('#submit_btn').attr('disabled', 'disabled')
}
$("#id_teams").change(function (e) {
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
if (!users) {
// users = []
} else {
users = users.concat(_data.split(','))
}
})
// users = $('option:selected', this).attr('data-users')
// if (!users) {
// users = []
// } else {
// users = users.split(',')
// }
console.log('selected users teams data', users)
var existingUsers = $('#id_assigned_to').val();
var allUsers = users.concat(existingUsers)
console.log(existingUsers)
if (users.length) {
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
function find_dict(dict, id){
var index = dict.map(function(o) { return o.team; }).indexOf(parseInt(id));
return dict[index]['users']
}
$("#id_teams").change(function (e) {
var teams = []
var all_users = []
var selected_teams = []
var selected_users = []
var assigned_users = []
$.get("{% url 'common:get_teams_and_users' %}", function(data){
// console.log(data)
if(($('#id_teams').val()).length==0){
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2().trigger('change');
}
teams = data['teams']
all_users = data['users']
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
selected_teams.push($(this).val())
selected_users.push(find_dict(teams, $(this).val()))
// console.log("s_users", selected_users)
var un_select_users = [].concat.apply([], selected_users)
// console.log('un select users', un_select_users);
$('#id_assigned_to option').each(function () {
if($.inArray(parseInt($(this).val()), un_select_users) != -1){
$(this).attr('disabled', 'disabled')
$('#id_assigned_to').select2();
}
else{
$(this).show()
$(this).removeAttr('disabled')
$('#id_assigned_to').select2();
}
}
)
if (!selected_teams) {
users = []
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2();
} else {
users = users.concat(_data.split(','))
}
});
$('#id_teams option').each(function () {
if ($(this).is(':selected')) {
_data = $(this).attr('data-users').split(',')
// console.log(' selected', $(this).attr('data-users').split(','))
// console.log('selected', $(this).attr('data-users'))
}
else {
_unselected = $(this).attr('data-users').split(',')
// console.log('un selected', $(this).attr('data-users').split(','))
}
});
// console.log('selected users teams data', users)
var existingUsers = $('#id_assigned_to').val();
var allUsers = users
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
if (users.length) {
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val([]).trigger('change');
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val(existingUsers).trigger('change');
}
})
});
$(document).ready(function($) {
var teams = []
var all_users = []
var selected_teams = []
var selected_users = []
var assigned_users = []
$.get("{% url 'common:get_teams_and_users' %}", function(data){
if(($('#id_teams').val()).length==0){
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
// $('#id_assigned_to').select2().val([]).trigger('change');
}
teams = data['teams']
all_users = data['users']
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
selected_teams.push($(this).val())
selected_users.push(find_dict(teams, $(this).val()))
var un_select_users = [].concat.apply([], selected_users)
$('#id_assigned_to option').each(function () {
if($.inArray(parseInt($(this).val()), un_select_users) != -1){
// $(this).attr('disabled', 'disabled')
$(this).attr('disabled', 'disabled')
$('#id_assigned_to').select2();
}
else{
$(this).show()
$(this).removeAttr('disabled')
$('#id_assigned_to').select2();
}
}
)
if (!selected_teams) {
users = []
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2();
} else {
users = users.concat(_data.split(','))
}
});
$('#id_teams option').each(function () {
if ($(this).is(':selected')) {
_data = $(this).attr('data-users').split(',')
}
else {
_unselected = $(this).attr('data-users').split(',')
}
});
var existingUsers = $('#id_assigned_to').val();
// var allUsers = users.concat(existingUsers)
var allUsers = users
// console.log(existingUsers)
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
if (users.length) {
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val([]).trigger('change');
}
})
});
</script>
{% endblock js_block %}

View file

@ -146,7 +146,7 @@
{% endwith %}
</td>
<td class="actions">
{% if request.user == document.created_by or request.user.role == 'ADMIN' %}
{% if request.user == document.created_by or request.user.role == 'ADMIN' or request.user.has_sales_access %}
<a href="{% url 'common:view_doc' document.id %}" class="btn btn-info edit"><i
class="fas fa-eye"></i></a>
<a href="{% url 'common:edit_doc' document.id %}" class="btn btn-success edit"><i

View file

@ -81,7 +81,7 @@
<select class="assigned_users form-control" name="shared_to" multiple="multiple">
{% for user in users %}
<option value="{{user.id}}" {% if user.id in sharedto_list %} selected="" {% endif %}>
{{user.email}}</option>
{% if user.username %}{{user.username}}{% else %}{{user.email}}{% endif %}</option>
{% endfor %}
</select>
</div>
@ -231,12 +231,12 @@
<div class="col-6 offset-6" style="margin-left: 60%; margin-bottom: -1em;">
<span class="">
<div class="actions">
{% if request.user == document.created_by or request.user.role == 'ADMIN' %}
{% if request.user == document.created_by or request.user.role == 'ADMIN' or request.user.has_sales_access%}
<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" title="Edit" ><i
class="fas fa-pencil-alt edit_delete_options"></i></a>
<a href="{% url 'common:remove_doc' document.id %}" class="delete_icon" title="Delete" ><i
<a href="{% url 'common:remove_doc' document.id %}" class="delete_icon remove_document" 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' %}
@ -436,4 +436,4 @@
$('#docs_filter').submit();
});
</script>
{% endblock js_block %}
{% endblock js_block %}

View file

@ -134,6 +134,7 @@
{% if active_users|length > 0 %}
<tr>
<th width="20%">Username</th>
<th width="20%">Created</th>
<th width="20%">Email Address</th>
<th width="8%">User Role</th>
<th width="8%">Permissions</th>
@ -151,6 +152,7 @@
{% for user in active_users %}
<tr class="text-center">
<td><a href="{% url 'common:view_user' user.id %}">{{ user.username }}</a></td>
<td data-toggle="tooltip" title="{{user.date_joined}}">{{user.date_joined.date|timesince}}
<td>{{ user.email }}</td>
<td class="user_role">{% if user.is_superuser %} ADMIN {% else %} {{user.role}} {% endif %}
</td>
@ -192,13 +194,14 @@
<a href="{% url 'common:edit_user' user.id %}" class="btn btn-success edit action"><i
class="fas fa-pencil-alt"></i>Edit</a>
{% endif %}
<a href="{% url 'common:remove_user' user.id %}" class="btn btn-danger trash action"
<a href="{% url 'common:remove_user' user.id %}" class="btn btn-danger remove_active_user trash action"
{% if request.user.email == user.email %} style="visibility: hidden;" {% endif %}><i
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" title="Change Password"><i class="fa fa-undo fa-stack-2x"></i><i
class="fa fa-lock fa-stack-1x"></i></a>{% endif %}
class="fa fa-lock fa-stack-1x"></i></a>
{% endif %}
</td>
</tr>
{% endfor %}
@ -272,10 +275,11 @@
<a href="{% url 'common:edit_user' user.id %}" class="btn btn-success edit action"><i
class="fas fa-pencil-alt"></i>Edit</a>
{% endif %}
<a href="{% url 'common:remove_user' user.id %}" class="btn btn-danger trash action"
<a href="{% url 'common:remove_user' user.id %}" class="btn btn-danger remove_inactive_user trash action"
{% if request.user.email == user.email %} style="visibility: hidden;" {% endif %}><i
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" title="Change Password"><i class="fa fa-undo fa-stack-2x"></i><i
class="fa fa-lock fa-stack-1x"></i></a>{% endif %}
@ -286,7 +290,7 @@
</table>
</div>
{% ifequal inactive_users|length 0 %}
<h6 class="text-center">No Closed Acccount Records Found</h6>
<h6 class="text-center">There are no users</h6>
{% endifequal %}
<div class="text-center row marl">
{% show_pages %}
@ -304,6 +308,11 @@
<!-- main_container ends here -->
{% endblock %}
{% block js_block %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
<!-- <link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-tagsinput/1.3.6/jquery.tagsinput.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-tagsinput/1.3.6/jquery.tagsinput.min.js"></script> -->
<script src="{% static 'js/ajaxForm.js' %}"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".filter_toggle").click(function () {
@ -314,13 +323,22 @@
}
});
$('.trash').click(function (e) {
$('.remove_active_user').click(function (e) {
e.preventDefault()
url = $(this).attr('href')
if (!confirm('Are you sure you want to delete?'))
return;
window.location = $(this).attr('href')
});
$('.remove_inactive_user').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>
<script>
$(document).ready(function () {
@ -331,6 +349,9 @@
$("#password_eror").text("");
$("#pass_change_div").modal();
});
$("#submit_password").click(function (e) {
e.preventDefault();
if ($("#new_passwoord").val().length < 4) {
@ -349,4 +370,4 @@
});
});
</script>
{% endblock js_block %}
{% endblock js_block %}

View file

@ -276,11 +276,11 @@
</td>
<td title="{{ contact.created_on }}">{{ contact.created_on_arrow }}</td>
<td class="actions">
{% if request.user.role == 'ADMIN' or reques.user.is_superuser %}
{% if request.user.role == 'ADMIN' or request.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="btn btn-danger delete contacts_delete" title="Delete"><i
class="fas fa-trash-alt"></i></a>
{% endif %}
</td>
@ -353,11 +353,11 @@
</td>
<td title="{{ domain.created_on }}">{{ domain.created_on_arrow }}</td>
<td class="actions">
{% if request.user.role == 'ADMIN' or reques.user.is_superuser %}
{% if request.user.role == 'ADMIN' or request.user.is_superuser %}
<a href="{% url 'marketing:edit_blocked_domain' domain.id %}" class="btn btn-success edit"
title="Edit"><i class="fas fa-pencil-alt"></i></a>
<a href="{% url 'marketing:delete_blocked_domain' domain.id %}"
class="btn btn-danger delete remove_document" title="Delete"><i
class="btn btn-danger blocked_domain_delete remove_document" title="Delete"><i
class="fas fa-trash-alt"></i></a>
{% endif %}
</td>
@ -431,11 +431,11 @@
</td>
<td title="{{ email.created_on }}">{{ email.created_on_arrow }}</td>
<td class="actions">
{% if request.user.role == 'ADMIN' or reques.user.is_superuser %}
{% if request.user.role == 'ADMIN' or request.user.is_superuser %}
<a href="{% url 'marketing:edit_blocked_email' email.id %}" class="btn btn-success edit"
title="Edit"><i class="fas fa-pencil-alt"></i></a>
<a href="{% url 'marketing:delete_blocked_email' email.id %}"
class="btn btn-danger delete remove_document" title="Delete"><i
class="btn btn-danger blocked_email_delete remove_document" title="Delete"><i
class="fas fa-trash-alt"></i></a>
{% endif %}
</td>
@ -468,6 +468,8 @@
<script type="text/javascript">
var queryParams = (window.location.search).replace('?', '').split('&').map(param => param.split('=')).reduce((values, [key, value]) => { values[key] = value; return values; }, {})
if (queryParams.hasOwnProperty('contacts')) {
$('#open-tab').trigger('click')
}
@ -494,8 +496,32 @@
if (tab_clicked_emails.length > 1) {
$('#emails-tab').trigger('click')
}
// Javascript to enable link to tab
var url = document.location.toString();
if (url.match('#')) {
$('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show');
}
$('.trash').click(function (e) {
// Change hash for page-reload
$('.nav-tabs a').on('shown.bs.tab', function (e) {
window.location.hash = e.target.hash;
})
$('.contacts_delete').click(function (e) {
e.preventDefault()
url = $(this).attr('href')
if (!confirm('Are you sure you want to delete?'))
return;
window.location = $(this).attr('href')
});
$('.blocked_domain_delete').click(function (e) {
e.preventDefault()
url = $(this).attr('href')
if (!confirm('Are you sure you want to delete?'))
return;
window.location = $(this).attr('href')
});
$('.blocked_email_delete').click(function (e) {
e.preventDefault()
url = $(this).attr('href')
if (!confirm('Are you sure you want to delete?'))
@ -551,4 +577,4 @@
</script>
{% endblock js_block %}
{% endblock js_block %}

View file

@ -7,20 +7,24 @@ def is_document_file_image(ext):
'tga', 'thm', 'tif', 'tiff', 'yuv']
return ext.lower() in image_ext_list
def is_document_file_audio(ext):
audio_ext_list = ['aif', 'iff', 'm3u', 'm4a', 'mid', 'mp3',
'mpa', 'wav', 'wma']
return ext.lower() in audio_ext_list
def is_document_file_video(ext):
video_ext_list = ['3g2', '3gp', 'asf', 'avi', 'flv', 'm4v', 'mov',
'mp4', 'mpg', 'rm', 'srt', 'swf', 'vob', 'wmv']
return ext.lower() in video_ext_list
def is_document_file_pdf(ext):
pdf_ext_list = ['indd', 'pct', 'pdf']
return ext.lower() in pdf_ext_list
def is_document_file_code(ext):
code_ext_list = ['aspx', 'json', 'jsp', 'do', 'htm', 'html', 'ser',
'php', 'jad', 'cfm', 'xml', 'js', 'pod', 'asp',
@ -96,16 +100,19 @@ def is_document_file_code(ext):
'drc', 'appxsym']
return ext.lower() in code_ext_list
def is_document_file_text(ext):
text_ext_list = ['doc', 'docx', 'log', 'msg', 'odt', 'pages', 'rtf',
'tex', 'txt', 'wpd', 'wps']
return ext.lower() in text_ext_list
def is_document_file_sheet(ext):
sheet_ext_list = ['csv', 'xls', 'xlsx',
'xlsm', 'xlsb', 'xltx', 'xltm', 'xlt']
return ext.lower() in sheet_ext_list
def is_document_file_zip(ext):
ext_list = ['zip', '7Z', 'gz', 'rar', 'ZIPX', 'ACE', 'tar', ]
return ext.lower() in ext_list
@ -114,3 +121,17 @@ def is_document_file_zip(ext):
@register.filter
def subtract(value, arg):
return value - int(arg)
@register.filter
def delete_condition(user, task):
if user == task.created_by or user.role == 'ADMIN':
return True
return False
@register.filter
def view_edit_condition(user, task):
if user == task.created_by or user.role == 'ADMIN' or user.has_sales_access or user in task.assigned_to.all:
return True
return False

View file

@ -7,7 +7,7 @@ from common.views import (
UsersListView, CreateUserView, UpdateUserView, UserDetailView,
UserDeleteView, PasswordResetView,
DocumentListView, document_create, document_update,
DocumentDetailView, DocumentDeleteView,
DocumentDetailView, DocumentDeleteView,get_teams_and_users,
download_document, change_user_status, download_attachment,
add_comment, edit_comment, remove_comment,
api_settings, add_api_settings, view_api_settings,
@ -93,6 +93,8 @@ urlpatterns = [
# user activate link
path('activate-user/<uidb64>/<token>/<activation_key>/', activate_user, name='activate_user'),
path('resend_activation_link/<userId>/', resend_activation_link, name='resend_activation_link'),
path('get_teams_and_users/', get_teams_and_users, name="get_teams_and_users")
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View file

@ -1,7 +1,7 @@
import datetime
import json
import os
import phonenumbers
import boto3
import botocore
import requests
@ -40,12 +40,12 @@ from common.models import (APISettings, Attachments, Comment, Document, Google,
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 common.utils import ROLES, COUNTRIES
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, BlockedDomain, BlockedEmail
from marketing.models import ContactEmailCampaign, BlockedDomain, BlockedEmail
def handler404(request, exception):
@ -56,6 +56,17 @@ def handler500(request):
return render(request, '500.html', status=500)
@login_required
def get_teams_and_users(request):
data = {}
teams = Teams.objects.all()
teams_data = [{'team': team.id, 'users': [user.id for user in team.users.all()]} for team in teams]
users = User.objects.all().values_list("id", flat=True)
data['teams'] = teams_data
data['users'] = list(users)
return JsonResponse(data)
class AdminRequiredMixin(AccessMixin):
def dispatch(self, request, *args, **kwargs):
@ -519,7 +530,7 @@ class DocumentListView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateVie
def get_context_data(self, **kwargs):
context = super(DocumentListView, self).get_context_data(**kwargs)
context["users"] = User.objects.filter(
is_active=True).order_by('email')
is_active=True).order_by('username')
context["documents"] = self.get_queryset()
context["status_choices"] = Document.DOCUMENT_STATUS_CHOICE
context["sharedto_list"] = [
@ -640,7 +651,6 @@ def download_document(request, pk):
request.user not in doc_obj.shared_to.all()):
raise PermissionDenied
if settings.STORAGE_TYPE == "normal":
# print('no no no no')
path = doc_obj.document_file.path
file_path = os.path.join(settings.MEDIA_ROOT, path)
if os.path.exists(file_path):
@ -653,14 +663,11 @@ def download_document(request, pk):
else:
file_path = doc_obj.document_file
file_name = doc_obj.title
# print(file_path)
# print(file_name)
BUCKET_NAME = "django-crm-demo"
KEY = str(file_path)
s3 = boto3.resource('s3')
try:
s3.Bucket(BUCKET_NAME).download_file(KEY, file_name)
# print('got it')
with open(file_name, 'rb') as fh:
response = HttpResponse(
fh.read(), content_type="application/vnd.ms-excel")
@ -694,8 +701,6 @@ def download_attachment(request, pk): # pragma: no cover
else:
file_path = attachment_obj.attachment
file_name = attachment_obj.file_name
# print(file_path)
# print(file_name)
BUCKET_NAME = "django-crm-demo"
KEY = str(file_path)
s3 = boto3.resource('s3')
@ -713,8 +718,6 @@ def download_attachment(request, pk): # pragma: no cover
print("The object does not exist.")
else:
raise
# if file_path:
# print('yes tus pus')
raise Http404
@ -797,6 +800,7 @@ def api_settings(request):
}
if request.method == 'POST':
# settings = api_settings
# if request.POST.get('api_settings', None):
# if request.POST.get('title', None):
@ -1053,9 +1057,25 @@ def create_lead_from_site(request): # pragma: no cover
if (request.get_host() in ['sales.micropyramid.com', ] and request.POST.get('origin_domain') in allowed_domains):
if request.method == 'POST':
if request.POST.get('full_name', None):
try:
description = request.POST.get('enquiry_type') + '\n' + request.POST.get('message')
except Exception as e:
print("e:::",e)
country = request.POST.get('country').title()
country_codes = list(COUNTRIES)
for count in country_codes:
if country == count[1]:
country = count[0]
break
phone=request.POST.get('phone')
phone_number = phonenumbers.parse(phone, country)
lead = Lead.objects.create(title=request.POST.get('full_name'), email=request.POST.get(
'email'), phone=request.POST.get('phone'), description=request.POST.get('message'),
'email'), phone=phone_number,
description=description,
country=country,
created_from_site=True)
lead.source = 'micropyramid'
lead.save()
recipients = User.objects.filter(
role='ADMIN').values_list('id', flat=True)
lead.assigned_to.add(*recipients)

View file

@ -21,7 +21,7 @@ class ContactForm(forms.ModelForm):
for key, value in self.fields.items():
if key == 'phone':
value.widget.attrs['placeholder'] = "+91-123-456-7890"
value.widget.attrs['placeholder'] = "+911234567890"
else:
value.widget.attrs['placeholder'] = value.label
self.fields["teams"].choices = [(team.get('id'), team.get('name')) for team in Teams.objects.all().values('id', 'name')]

View file

@ -47,8 +47,8 @@
<label for="exampleInputEmail1">Assigned To</label>
<select class="assigned_users form-control" name="assigned_to" multiple="multiple">
{% for user in users %}
<option value="{{user.id}}" {% if user.id in assignedto_list %} selected="" {% endif %}>
{{user.email}}</option>
<option value="{{user.id}}" {% if user.id in assignedto_list %} selected="" {% endif %}>
{% if user.username %}{{user.username}}{% else %}{{user.email}}{% endif %}</option>
{% endfor %}
</select>
</div>
@ -319,4 +319,4 @@
$('#contacts_filter').submit();
});
</script>
{% endblock js_block %}
{% endblock js_block %}

View file

@ -105,7 +105,7 @@
id="id_assigned_to">
{% for user in users %}
<option value="{{user.id}}"
{% if user in contact_obj.assigned_to.all or user.id in assignedto_list %} selected=""
{% if user in contact_obj.get_assigned_users_not_in_teams or user.id in assignedto_list %} selected=""
{% endif %}>{{user.email}}</option>
{% endfor %}
</select>
@ -217,36 +217,170 @@
}
}
$("#id_teams").change(function (e) {
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
if (!users) {
// users = []
} else {
users = users.concat(_data.split(','))
}
})
// users = $('option:selected', this).attr('data-users')
// if (!users) {
// users = []
// } else {
// users = users.split(',')
// }
console.log('selected users teams data', users)
var existingUsers = $('#id_assigned_to').val();
var allUsers = users.concat(existingUsers)
console.log(existingUsers)
if (users.length) {
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
function find_dict(dict, id){
var index = dict.map(function(o) { return o.team; }).indexOf(parseInt(id));
return dict[index]['users']
}
$("#id_teams").change(function (e) {
var teams = []
var all_users = []
var selected_teams = []
var selected_users = []
var assigned_users = []
$.get("{% url 'contacts:get_teams_and_users' %}", function(data){
// console.log(data)
if(($('#id_teams').val()).length==0){
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2().trigger('change');
}
teams = data['teams']
all_users = data['users']
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
selected_teams.push($(this).val())
selected_users.push(find_dict(teams, $(this).val()))
// console.log("s_users", selected_users)
var un_select_users = [].concat.apply([], selected_users)
// console.log('un select users', un_select_users);
$('#id_assigned_to option').each(function () {
if($.inArray(parseInt($(this).val()), un_select_users) != -1){
$(this).attr('disabled', 'disabled')
$('#id_assigned_to').select2();
}
else{
$(this).show()
$(this).removeAttr('disabled')
$('#id_assigned_to').select2();
}
}
)
if (!selected_teams) {
users = []
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2();
} else {
users = users.concat(_data.split(','))
}
});
$('#id_teams option').each(function () {
if ($(this).is(':selected')) {
_data = $(this).attr('data-users').split(',')
// console.log(' selected', $(this).attr('data-users').split(','))
// console.log('selected', $(this).attr('data-users'))
}
else {
_unselected = $(this).attr('data-users').split(',')
// console.log('un selected', $(this).attr('data-users').split(','))
}
});
// console.log('selected users teams data', users)
var existingUsers = $('#id_assigned_to').val();
var allUsers = users
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
if (users.length) {
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val([]).trigger('change');
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val(existingUsers).trigger('change');
}
})
});
$(document).ready(function($) {
var teams = []
var all_users = []
var selected_teams = []
var selected_users = []
var assigned_users = []
$.get("{% url 'contacts:get_teams_and_users' %}", function(data){
if(($('#id_teams').val()).length==0){
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
// $('#id_assigned_to').select2().val([]).trigger('change');
}
teams = data['teams']
all_users = data['users']
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
selected_teams.push($(this).val())
selected_users.push(find_dict(teams, $(this).val()))
var un_select_users = [].concat.apply([], selected_users)
$('#id_assigned_to option').each(function () {
if($.inArray(parseInt($(this).val()), un_select_users) != -1){
// $(this).attr('disabled', 'disabled')
$(this).attr('disabled', 'disabled')
$('#id_assigned_to').select2();
}
else{
$(this).show()
$(this).removeAttr('disabled')
$('#id_assigned_to').select2();
}
}
)
if (!selected_teams) {
users = []
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2();
} else {
users = users.concat(_data.split(','))
}
});
$('#id_teams option').each(function () {
if ($(this).is(':selected')) {
_data = $(this).attr('data-users').split(',')
}
else {
_unselected = $(this).attr('data-users').split(',')
}
});
var existingUsers = $('#id_assigned_to').val();
// var allUsers = users.concat(existingUsers)
var allUsers = users
// console.log(existingUsers)
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
if (users.length) {
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val([]).trigger('change');
}
})
});
</script>

View file

@ -1,7 +1,7 @@
from django.urls import path
from contacts.views import (
ContactsListView, CreateContactView, ContactDetailView,
UpdateContactView, RemoveContactView,
UpdateContactView, RemoveContactView, get_teams_and_users,
GetContactsView, AddCommentView, UpdateCommentView,
DeleteCommentView, AddAttachmentsView, DeleteAttachmentsView)
@ -30,4 +30,5 @@ urlpatterns = [
name="add_attachment"),
path('attachment/remove/', DeleteAttachmentsView.as_view(),
name="remove_attachment"),
path('get_teams_and_users/', get_teams_and_users, name="get_teams_and_users")
]

View file

@ -1,6 +1,7 @@
import json
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.sites.shortcuts import get_current_site
from django.contrib.auth.decorators import login_required
from django.core.mail import EmailMessage
from django.http import JsonResponse
from django.shortcuts import get_object_or_404, redirect
@ -24,13 +25,24 @@ from common.access_decorators_mixins import (
from teams.models import Teams
@login_required
def get_teams_and_users(request):
data = {}
teams = Teams.objects.all()
teams_data = [{'team': team.id, 'users': [user.id for user in team.users.all()]} for team in teams]
users = User.objects.all().values_list("id", flat=True)
data['teams'] = teams_data
data['users'] = list(users)
return JsonResponse(data)
class ContactsListView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateView):
model = Contact
context_object_name = "contact_obj_list"
template_name = "contacts.html"
def get_queryset(self):
queryset = self.model.objects.all()
queryset = self.model.objects.all().order_by('-created_on')
if (self.request.user.role != "ADMIN" and not
self.request.user.is_superuser):
queryset = queryset.filter(
@ -61,7 +73,7 @@ class ContactsListView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateVie
context["contact_obj_list"] = self.get_queryset()
context["per_page"] = self.request.POST.get('per_page')
context["users"] = User.objects.filter(
is_active=True).order_by('email')
is_active=True).order_by('username')
context["assignedto_list"] = [
int(i) for i in self.request.POST.getlist('assigned_to', []) if i]
search = False

View file

@ -27,7 +27,7 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'simple_pagination',
'compressor',
'haystack',
# 'haystack',
'common',
'accounts',
'cases',
@ -158,8 +158,10 @@ elif STORAGE_TYPE == 's3-storage':
AWS_STORAGE_BUCKET_NAME = AWS_BUCKET_NAME = os.getenv('AWSBUCKETNAME', '')
AM_ACCESS_KEY = AWS_ACCESS_KEY_ID = os.getenv('AWS_ACCESS_KEY_ID', '')
AM_PASS_KEY = AWS_SECRET_ACCESS_KEY = os.getenv('AWS_SECRET_ACCESS_KEY', '')
S3_DOMAIN = AWS_S3_CUSTOM_DOMAIN = str(AWS_BUCKET_NAME) + '.s3.amazonaws.com'
AM_PASS_KEY = AWS_SECRET_ACCESS_KEY = os.getenv(
'AWS_SECRET_ACCESS_KEY', '')
S3_DOMAIN = AWS_S3_CUSTOM_DOMAIN = str(
AWS_BUCKET_NAME) + '.s3.amazonaws.com'
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
@ -292,7 +294,7 @@ if SENTRY_ENABLED and not DEBUG:
MIDDLEWARE = [
'raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware',
'raven.contrib.django.raven_compat.middleware.SentryResponseErrorIdMiddleware',
] + MIDDLEWARE
] + MIDDLEWARE
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
@ -335,17 +337,53 @@ if SENTRY_ENABLED and not DEBUG:
},
}
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch2_backend.Elasticsearch2SearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
},
}
# HAYSTACK_CONNECTIONS = {
# 'default': {
# # 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
# 'ENGINE': 'marketing.search_backends.CustomElasticsearchSearchEngine',
# 'URL': 'http://127.0.0.1:9200/',
# 'INDEX_NAME': 'haystack',
# },
# }
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
# HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
HAYSTACK_SEARCH_RESULTS_PER_PAGE = 10
# HAYSTACK_SEARCH_RESULTS_PER_PAGE = 10
# ELASTICSEARCH_INDEX_SETTINGS = {
# "settings": {
# "analysis": {
# "analyzer": {
# "ngram_analyzer": {
# "type": "custom",
# "tokenizer": "custom_ngram_tokenizer",
# "filter": ["asciifolding", "lowercase"]
# },
# "edgengram_analyzer": {
# "type": "custom",
# "tokenizer": "custom_edgengram_tokenizer",
# "filter": ["asciifolding", "lowercase"]
# }
# },
# "tokenizer": {
# "custom_ngram_tokenizer": {
# "type": "nGram",
# "min_gram": 3,
# "max_gram": 12,
# "token_chars": ["letter", "digit"]
# },
# "custom_edgengram_tokenizer": {
# "type": "edgeNGram",
# "min_gram": 2,
# "max_gram": 12,
# "token_chars": ["letter", "digit"]
# }
# }
# }
# }
# }
# HAYSTACK_DEFAULT_OPERATOR = 'AND'
# Load the local settings file if it exists
if os.path.isfile('crm/local_settings.py'):
@ -361,4 +399,5 @@ CACHES = {
}
}
PASSWORD_RESET_MAIL_FROM_USER = os.getenv('PASSWORD_RESET_MAIL_FROM_USER', 'no-reply@django-crm.com')
PASSWORD_RESET_MAIL_FROM_USER = os.getenv(
'PASSWORD_RESET_MAIL_FROM_USER', 'no-reply@django-crm.com')

View file

@ -1,20 +1,177 @@
# Minimal makefile for Sphinx documentation
# Makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
# User-friendly check for sphinx-build
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
endif
# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " xml to make Docutils-native XML files"
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
.PHONY: help Makefile
clean:
rm -rf $(BUILDDIR)/*
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."
json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."
htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."
qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/MicroSite.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/MicroSite.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/MicroSite"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/MicroSite"
@echo "# devhelp"
epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."
latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
latexpdfja:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through platex and dvipdfmx..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."
man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."
info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."
linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."
doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."
xml:
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
@echo
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
pseudoxml:
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
@echo
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

0
docs/__init__.py Normal file
View file

View file

@ -1,35 +0,0 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

39
docs/source/Accounts.rst Normal file
View file

@ -0,0 +1,39 @@
Accounts
********
| These have the user roles i.e Admin and User. User Role will have permissions where Admin can access.
| Create your Accounts - new account can be created for different users and contacts and leads can create in accounts itself in their view pages
.. image:: screenshots/accountshome1.png
| **Fig** Accounts page
| This page view describes us about the accounts available and basic information.
| There are 2 types of accounts i.e Open/Closed accounts.
| We can Edit/Delete accounts here
| To create an account we have a option "Add New Account" at the top right corner On Clicking it you will be redirected to the below page.
| **Optional:** We can filter the users based on name,city,tags .
.. image:: screenshots/accountcreate.png
| **Fig** Account create page
| Here while we are creating an account, it is mandatory to have minimum one contact and one lead.
| **Note:** Fields having ``*`` are mandatory
.. | Rules to follow:-
.. 1.writing test cases for the code
.. 2.test cases coverage percent should be above 90%

20
docs/source/Cases.rst Normal file
View file

@ -0,0 +1,20 @@
Cases
*****
.. image:: screenshots/caseshome1.png
| **Fig** cases Home Page
| The above figure shows the cases view, this page gives details and list view of leads
| You can filter the results by name, status, priority, account.
| Create a new Lead using the button on right corner ``+ Add New case``
.. image:: screenshots/casescreate.png
| **Fig** cases Create Page
| **Note:** Fields having ``*`` are mandatory.
| **Note:** To create a cases user,accounts are required.

View file

@ -0,0 +1,11 @@
Change Password
***************
.. image:: screenshots/changepassword.png
| **Fig** Password Change Page
| The above figure shows the password change view, here enter the old password in "old password field" and enter new password in "new password field" and retype the new password in "confirm new password" field.
| Click "Change Password" button to change the password successfully, otherwise cancel to cancel the process.

23
docs/source/Contacts.rst Normal file
View file

@ -0,0 +1,23 @@
Contacts
********
| Contacts can be created and can be assigned to Accounts
.. image:: screenshots/contactshome1.png
| **Fig** Contacts Home Page
| The above figure shows the contacts view, this page gives details and list view of leads
| You can filter the results by name, city, assigned user.
| Create a new Lead using the button on right corner ``+ Add New contact``
.. image:: screenshots/contactscreate.png
| **Fig** Contacts Create Page
| **Note:** Fields having ``*`` are mandatory.
| **Note:** To create a contacts lead is required.

18
docs/source/Documents.rst Normal file
View file

@ -0,0 +1,18 @@
Documents
*********
.. image:: screenshots/documentshome1.png
| **Fig** documents Home Page
| The above figure shows the documents view, this page gives details and list view of leads
| You can filter the results by title, status, shared to.
| Create a new Document using the button on right corner ``+ Add New Document``
.. image:: screenshots/documentscreate.png
| **Fig** Documents Create Page
| **Note:** Fields having ``*`` are mandatory.

View file

@ -0,0 +1,43 @@
Forget Password
***************
.. image:: screenshots/forgetpasswordpage.png
| **Fig** Forget Password Page View
| Enter the registered email id and click submit, then you will be sent a email to the registered email address, and redirect to the acknowledge page as below figure
.. image:: screenshots/mailsent.png
| **Fig** Email Sent acknowledgement view
| When you check the mail you will recieve a email similar to the below figure.
.. image:: screenshots/email.png
| **Fig** Email recieved
| When you click on the link in the mail, you will get a page as below
.. image:: screenshots/resetpassword.png
| **Fig** Password Reset view
| After you successful change the password you will get below page
.. image:: screenshots/resetsuccessful.png
| **Fig** Password Reset Successful view
| Now click on login and enter your credentials
| After successful login you will be redirected to Dashboard which looks similiar to the below figure
.. image:: screenshots/homepage.png
| **Fig** Dashboard view
| The home page/Dashboard have access to all the modules of the CRM
| **Note:** The numbers below accounts, contacts, leads, opportunities represent the total count of each module.

18
docs/source/Leads.rst Normal file
View file

@ -0,0 +1,18 @@
Leads
*****
.. image:: screenshots/leadshome1.png
| **Fig** Accounts Home Page
| The above figure shows the leads view, this page gives details and list view of leads
| You can filter the results by name, source, assigned user, status, tags
| Create a new Lead using the button on right corner ``+ Add New Lead``
.. image:: screenshots/leadscreate.png
| **Fig** Leads Create Page
| **Note:** Fields having ``*`` are mandatory

6
docs/source/Login.rst Normal file
View file

@ -0,0 +1,6 @@
Login
*****
.. image:: screenshots/login.png
| **Fig** Login Page

View file

@ -0,0 +1,23 @@
Opportunity
***********
| New Opportunities can be added and can be assigned to accounts and contacts.
.. image:: screenshots/opportunityhome1.png
| **Fig** Opportunity Home Page
| The above figure shows the Opportunity view, this page gives details and list view of leads
| They are two types of leads open and closed
| You can filter the results by name, stage, account, lead source
| Create a new Lead using the button on right corner ``+ Add New Opportunity``
.. image:: screenshots/opportunitycreate.png
| **Fig** Opportunity Create Page
| **Note:** Fields having ``*`` are mandatory.
| **Note:** To create a Opportunity lead is required.

88
docs/source/Profile.rst Normal file
View file

@ -0,0 +1,88 @@
Profile
*******
Dropdown menu for user settings
.. image:: screenshots/dropdown.png
:align: center
| **Fig** Dropdown menu
Here in this drop down all the essential options for the user profile management are available i.e.
Users
~~~~~
| On clicking users, the following page is shown
.. image:: screenshots/usershome.png
:align: center
| **Fig:** Users view
| Here the user can activate/deactivate, edit/delete user data.
| To create new user click on `` + Add New User``.
| One clicking `` + Add New User`` the following page is shown:
.. image:: screenshots/createuser.png
:align: center
| **Fig** User create page
| **Note:** Fields having ``*`` are mandatory.
.. image:: screenshots/edituser.png
:align: center
| **Fig:** User Edit User page
Settings
~~~~~~~~~
| On clicking settings, the following page is shown:
.. image:: screenshots/settingshome.png
:align: center
| **Fig:** User Settings page
| Click on `` + Add New Setting``
.. image:: screenshots/createsettings.png
:align: center
| **Fig:** User Create Setting page
Change Password
~~~~~~~~~~~~~~~
| On clicking settings, the following page is shown:
.. image:: screenshots/changepassword.png
:align: center
| **Fig:** User Change password page
Profile
~~~~~~~
| On clicking settings, the following page is shown:
.. image:: screenshots/profilehome.png
:align: center
| **Fig:** User profile page
.. image:: screenshots/editprofile.png
:align: center
| **Fig:** User edit profile page
| Here user can edit his personal details.
Logout
~~~~~~~
On Clicking logout you will be logged out from the account and redirected to Login page.

View file

@ -1,9 +0,0 @@
========
Accounts
========
Accounts are nothing but converted leads. It has all the information of the company like Contacts, Opportunities, Cases, Tasks, Invoices, Mails history associated with this account.
Here you can able to create a new account, check the existing accounts and update accounts. Here we have 2 types of accounts, Open & Closed accounts. Open accounts are the active accounts. You can filter accounts by account title, city, tags.
In the account view page, you can attach any kind of documents and you can add comments if you have any updates.

View file

@ -1,10 +0,0 @@
=====
Cases
=====
Any customer issues or help will be logged here. Each case will be assigned to respective team or user. Cases can be individual or it can be related to accounts or contacts.
From cases list page, you can create a new case and you can manage existing cases like edit, delete and close cases.
You can filter cases by its name, status, priority and assigned users.

View file

@ -1,9 +0,0 @@
========
Contacts
========
Contacts relate to individual persons of the company. Each account or lead may have more than one contact and one contact may associate with multiple accounts.
You can create a new contact, manage existing contacts. In the contact view page, you can see the detailed view with associated Tasks, comments and attachments if any.
You can filter contacts by name, city and assigned user.

View file

@ -1,11 +0,0 @@
=========
Dashboard
=========
This is the first page you'll see when you login. Here you can see the general overview of your sales activity at a glance. Which displays count of your total Accounts, Contacts, Leads, Opportunities, Recently created accounts & opportunities.
* **Recent Accounts:** Here you can see recently created 10 accounts with respective info like account title, tags, assigned user. By clicking on account title you will be redirected to account view page with detailed info.
* **Recent Opportunities:** Here you can see recently created 10 opportunities with respective info like opportunity title, tags, assigned user. By clicking on opportunity title you will be redirected to opportunity view page with detailed info.

View file

@ -1,9 +0,0 @@
=========
Documents
=========
Here you can upload any kind of documents and assign to either team or individual person. In list page, you can see existing documents in a grid view with view, edit, delete and download options.
Assigned users can able to manage and download the documents from the list page. You can filter documents by it’s name, status and assigned users.

View file

@ -1,12 +0,0 @@
======
Events
======
It is to schedule calls or meetings. There are 2 types of events,
Recurring - Based on the day selection, start & end dates, you can create recurring events
Non-recurring - You can create events for a specific date
When you assign an event for an user, they will receive a notification email reg: the event. You can upload attachments in the events view page. After completion of call or meeting, they can add comments in the event view page.
You can filter events by name, created by, assigned users, date of meeting.

View file

@ -1,15 +0,0 @@
========
Invoices
========
Which helps to generate a bill for your client or account based on the services you have provided. By doing this, you can measure how much of revenue is generating for your company. You can create invoices for individuals and assign to clients.
You can save invoice as either draft or send. Total there are 5 options in the invoice - Draft, Send, Pending, Paid, Cancel.
* **Draft -** It will be used for future purpose
* **Send -** If you choose the invoice status as send, then it will be shared with the respective client
* **Pending -** Waiting for the payment
* **Paid -** Invoice amount has been paid by client
* **Cancel -** It will close the invoice
From invoice list page, you can change the invoice status, view, manage invoices. You can filer invoices by title, invoice number, created by, assigned users, status, total amount.

View file

@ -1,14 +0,0 @@
=====
Leads
=====
Leads plays a crucial role in the sales module. If anyone is interested towards your services, you can add them here. These leads are not confirmed. Once a lead is qualified, you can convert them as an account.
You can create leads in two ways,
* **By creating manually -** You can create only one lead at a time.
* **By uploading CSV file -** You can create more than one lead in a single click.
There are 2 types of leads, open & closed leads. Open leads are the active leads. From the lead list page, you can view, update or delete a lead.
From lead list page, click on the lead title, to check lead quick view. By clicking on the eye icon from table, you can see the detailed view of a lead.

View file

@ -1,10 +0,0 @@
===========
Opportunity
===========
Requested services of the company are meant to be opportunities. New opportunities can be added and can be assigned to accounts & contacts.
You can access opportunity view, edit and delete from the list page. In the list page, you can check which accounts are linked to opportunities.
In the view page, you can check the detailed info an opportunity, uploaded attachments and comments.

View file

@ -1,7 +0,0 @@
=====
Tasks
=====
Project requirements are called as tasks. Each project will be divided into multiple tasks and if you finish tasks on time, then you can be able to complete a project with good productivity.
You can create tasks with deadlines to track easily. From the task list page, you can create a new task, view, update and delete a task. In the task view page, you can check the uploaded documents and comments section.

View file

@ -1,9 +0,0 @@
=====
Teams
=====
You can group users into teams. Instead of assigning leads, accounts etc. to multiple people, you can create a team and assign them. For ex: You can create teams like sales, marketing etc.
In teams list page, you can see which users are involved in each team. From list page, you can access team view, edit, delete features.
You can filter teams by name, created by, assigned users.

View file

@ -1,6 +0,0 @@
===============
Change Password
===============
For security purpose, you can change the password for your account. You can navigate to change password page, from user drop down. You have to specify new & confirm password as per the instructions specified in this page.

View file

@ -1,5 +0,0 @@
===============
Forgot Password
===============
From the login page, you can request for forgot password. To reset the password, you have to specify your email. After that, you will receive an email with instructions to set a new password for your account.

View file

@ -1,5 +0,0 @@
=======
Profile
=======
You can view/edit basic info of an user. You can access this page from user drop down. In this page, you can see the name of your account, email, in which team you are involved, which module permissions you have like sales & marketing, profile picture.

View file

@ -1,7 +0,0 @@
========
Settings
========
In settings page, you can add contacts, block domains, block emails. You can access this page from user drop down. Only admins can able to access settings page.
If you add any contacts in this page, those users will receive an email if anyone in the organization runs a campaign. If you block any domain or email, then they don’t receive any campaign related emails.

View file

@ -1,7 +0,0 @@
=====
Users
=====
To access the CRM, you can create users here with required permissions like user role (Admin & User), module level permissions (sales & marketing). Based on these two, user can access CRM features, when they logged in.
There are 2 types of users, active & inactive(deleted users). From list page, you activate or deactivate user account and you can reset the password for an user.

View file

@ -1,12 +0,0 @@
========
Campaign
========
It will be useful to send promotional campaigns for multiple contacts and to generate more no. of leads. In campaign create page, you can choose existing contact list & email templates.
Here you can choose option as whether to receive your replies to your account or CRM application. You can specify the placeholders in the template. Placeholders are like name, email, company etc.
In the campaign view page, you can take a glance of everything. Like how many bounced contacts, unsubscribed users, opened emails etc. If there are any links in your email, you can also track which users opened that link or not.
You can filter campaigns by name, created by.

View file

@ -1,9 +0,0 @@
============
Contact List
============
Use contact list to import bulk contacts into single list. In create page, you can download the sample file for your reference.
It will be useful, at the time of sending a campaign. In contact list page, you can see name of the contact list, valid & invalid contacts of the list, bounced contacts, failed contacts, duplicate contacts.
Click on the contact list title, to access view page. In view page, you can see detailed contacts info with count. Here you can either edit or delete contacts.

View file

@ -1,8 +0,0 @@
========
Contacts
========
All the uploaded contacts will be appeared here. Here you can able to see valid, bounced, failed contacts with the count. You delete existing contacts from the list page.
You filter contacts by email, domain name, created by, contact list. Click on each tab, to check contacts in a detailed view.

View file

@ -1,9 +0,0 @@
=========
Dashboard
=========
Here you can see the general overview of your sales activity at a glance. Which display statistical view of latest 5 campaigns with required data. At bottom of this report, you can latest 5 records of contact list & campaigns
* **Recent Contact List -** Here you can see contact list name, it’s tags. From here, you can switch to contact list view page.
* **Recent Campaigns -** These are latest 5 campaigns with info of campaign title, tags, created on date. Click on the campaign title, to check it’s detailed view.

View file

@ -1,7 +0,0 @@
===============
Email Templates
===============
Email templates are used at the time of campaign creation. From the list page, click on the plus(+) icon to create a campaign using that template.
Click on eye icon, to see how the template will look like. You can filter email templates by name, created by.

View file

@ -1,57 +1,266 @@
# Configuration file for the Sphinx documentation builder.
# -*- coding: utf-8 -*-
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# django-blog-it documentation build configuration file, created by
# sphinx-quickstart on Mon Dec 29 20:41:44 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
from recommonmark.parser import CommonMarkParser
source_parsers = {
'.md': CommonMarkParser,
}
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- General configuration ------------------------------------------------
# -- Project information -----------------------------------------------------
project = 'Django-CRM'
copyright = '2019, MicroPyramid'
author = 'MicroPyramid'
# The full version, including alpha/beta/rc tags
release = '0.9.0'
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.coverage', 'sphinx.ext.napoleon'
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ['ntemplates']
# The suffix of source filenames.
# source_suffix = '.rst'
source_suffix = ['.rst', '.md']
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Django-CRM'
copyright = u'2017, MicroPyramid'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.6.0'
# The full version, including alpha/beta/rc tags.
release = '0.6.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# -- Options for HTML output -------------------------------------------------
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ['nstatic']
master_doc = "index"
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'Django-CRM-doc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'Django-CRM.tex', u'Django-CRM Documentation',
u'Django-CRM', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'Django-CRM', u'Django-CRM Documentation',
[u'Django-CRM'], 1)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Django-CRM', u'Django-CRM Documentation',
u'Django-CRM', 'Django-CRM', 'One line description of project.',
'Miscellaneous'),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False

View file

@ -2,72 +2,102 @@
Django CRM
==========
Django CRM is an opensource CRM on Django framework developed and maintained by `Micropyramid`_. It has all the basic features of Sales and Marketing to begin with and customise to meet industry needs.
Introduction:
=============
.. _Micropyramid: https://micropyramid.com/
Django CRM is opensourse CRM developed on django framework. It has all the basic features of CRM to start with. We welcome code contributions and feature requests via github.
We welcome code contributions, suggestions, and feature requests via github. Source Code is available in `Micropyramid Repository`_.
Source Code is available in Micropyramid Repository() `Link <https://github.com/MicroPyramid/Django-CRM.git>`_.
.. _Micropyramid Repository: https://github.com/MicroPyramid/Django-CRM.git
Tech stack used:
================
Installation
************
* Python >= 3.4
* Django >= 2.0
* Redis
* django-simple-pagination
Modules available in Django-CRM:
================================
User functionalites:
********************
.. toctree::
:maxdepth: 2
setup/index.rst
setup/packages_used.rst
Modules in Sales
****************
Login
Forget Password
Profile
Change Password
Modules in crm:
***************
.. toctree::
:maxdepth: 1
:maxdepth: 2
apps/crm/dashboard.rst
apps/crm/accounts.rst
apps/crm/contacts.rst
apps/crm/leads.rst
apps/crm/opportunity.rst
apps/crm/cases.rst
apps/crm/documents.rst
apps/crm/tasks.rst
apps/crm/invoices.rst
apps/crm/events.rst
apps/crm/teams.rst
Accounts
Contacts
Leads
Opportunity
Cases
Documents
Modules in Marketing
********************
Rules to follow:-
=================
| 1.writing test cases for the code
| 2.test cases coverage percent should be above 90%
.. toctree::
:maxdepth: 1
apps/marketing/dashboard.rst
apps/marketing/contact-list.rst
apps/marketing/contacts.rst
apps/marketing/email-templates.rst
apps/marketing/campaign.rst
Internals
Setup On Local System
=====================
On Windows
**********
On Ubuntu
*********
| First Create a Virtual Environment in a local directory.
| Install Pip to install python packages.
| Then clone the source code from the repository `click here <https://github.com/MicroPyramid/Django-CRM.git>`_.
| Activate Virtual environment, then install the requirements.txt using the command
.. toctree::
:maxdepth: 1
::
apps/internals/users.rst
apps/internals/settings.rst
apps/internals/profile.rst
apps/internals/change_password
apps/internals/forgot_password
pip install -r requirements.txt
| Then execute
::
python manage.py runserver
Now Go to browser, enter the url ``http://127.0.0.1:8000``
Installation - Requirements
===========================
Ubuntu 64bit - 16.04
*********************
| $ sudo apt-get update && apt-get upgrade -y
| $ sudo apt-get install -y curl wget libpq-dev python3-dev gem ruby ruby-dev build-essential libssl-dev libffi-dev python-dev python-virtualenv python-pip git redis-server libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev tcl8.6-dev tk8.6-dev python-tk
| $ sudo gem install sass
Visit our Django web development page [Here](https://micropyramid.com/django-ecommerce-development/)
We welcome your feedback and support, raise github ticket if you want to report a bug or need new feature.
If you need any additional support? `Contact us here`_
Need additional support? `Contact us here`_
.. _contact us here: https://micropyramid.com/contact-us/
or
mailto:: "hello@micropyramid.com"

View file

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View file

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View file

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View file

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View file

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View file

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View file

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View file

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View file

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View file

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View file

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View file

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View file

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View file

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View file

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View file

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View file

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View file

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View file

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View file

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View file

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View file

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View file

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View file

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View file

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View file

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View file

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View file

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View file

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View file

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View file

@ -1,169 +0,0 @@
Installation & Configuration
============================
1. Create a django-crm directory using mkdir, move to it using cd
.. code-block:: python
mkdir django-crm
cd django-crm
2. install virtualenv using the following command
.. code-block:: python
sudo apt-get install virtualenv
3. create a python3 virtual environment and activate it using the following command
.. code-block:: python
virtualenv -p python3 env
source ../env/bin/activate
4. create a django-crm directory again, move to it using cd
.. code-block:: python
mkdir django-crm
cd django-crm
5. Install git using the following command and configure the account details
.. code-block:: python
sudo apt-get install git
.. code-block:: python
git config --user.email <your email id>
git config --user.name <your name>
6. Intialize the git using the following command
.. code-block:: python
git init
7. Add django-crm repository using the following command
.. code-block:: python
git remote add origin https://github.com/MicroPyramid/Django-CRM.git
7. Pull the latest code of django-crm using the following command
.. code-block:: python
git pull origin master
8. Install project dependencies using the following commands
.. code-block:: python
curl -sL https://deb.nodesource.com/setup_10.x | bash -
sudo apt-get update
sudo apt-get apt install -y ruby-dev nodejs postgresql-client redis-server wkhtmltopdf memcache
gem install compass sass
npm -g install less
pip install --no-cache-dir redis
pip install --no-cache-dir -r requirements.txt
9. We're using elasticsearch for searching emails in application. Install elasticsearch using the following command
.. code-block:: python
### Install Java
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer -y java -version
.. code-block:: python
### Download and install the Public Signing Key
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
.. code-block:: python
### Install Elasticsearch
sudo apt-get update && sudo apt-get install elasticsearch -y
# Start elasticsearch
sudo service elasticsearch start
10. open postgresql shell and create a database in postgresql using the following command
.. code-block:: python
sudo su - postgres
psql
create database dj_crm;
11. we're loading third party related keys from virtual environment env. We need to add those keys to tun the application
# sendgrid details
SG_USER=<sendgrid username>
SG_PWD=<sendgrid password>
#google developers account details
GP_CLIENT_ID=<oauth0 client id>
GP_CLIENT_SECRET=<oauth0 client secret>
ENABLE_GOOGLE_LOGIN=<variable to configure google login in application>
#sentry details
SENTRYDSN=<sentry project dsn>
SENTRY_ENABLED=<variable to configure sentry in application>
#aws account details
AWSBUCKETNAME=<aws bucket name>
AWS_ACCESS_KEY_ID=<aws access key id>
AWS_SECRET_ACCESS_KEY=<aws access secret key>
12. Apply migrations to database using the following command
.. code-block:: python
python manage.py migrate
13. Create superuser using the following command
.. code-block:: python
python manage.py createsuperuser
It'll ask for username, email, password for user
14. Run the application using the following command and open the browsr, visit http://localhost:8000
.. code-block:: python
python manage.py runserver
15. Use the following command for indexing documents in elasticsearch
.. code-block:: python
python manage.py rebuild_idex
16. We're using celery for sending emails, other related tasks in the application. Run celery using the following commands
.. code-block:: python
celery -A crm worker -l info
.. code-block:: python
celery -A crm beat -l info

View file

@ -1,58 +0,0 @@
Packages Used
=============
.. class:: center
django
celery
django-simple-pagination
django-compressor
sorl-thumbnail
django-phonenumber-field
phonenumbers
django-storages
psycopg2-binary
arrow
requests
boto3
lxml
cssselect
xlrd
xlwt
openpyxl
pdfkit
redis
coverage
raven
sorl-thumbnail
pytest
pytest-django
codacy-coverage
django-haystack
elasticsearch

View file

@ -1,4 +0,0 @@
Setup Dev system
----------------
Here you can see how to configure your dev machine to run Django-CRM

View file

@ -1,4 +0,0 @@
Setup Dev system
----------------
Here you can see how to configure your server running ubuntu 18.04 to run Django-CRM

View file

@ -132,11 +132,18 @@
{% endif %}
<div class="filter_col col-md-12">
<div class="form-group">
<label for="exampleInputEmail1" class="required">Assigned
To{% if form.assigned_to.field.required %}<span class="error_marker"
<!-- <label for="exampleInputEmail1" class="required">Assigned To{% if form.assigned_to.field.required %}<span class="error_marker"
style="color:red">*</span>{% endif %}</label>
{{ form.assigned_to }}
<span class="error" id="id__assigned_to">{{ form.assigned_to.errors }}</span>
<span class="error" id="id__assigned_to">{{ form.assigned_to.errors }}</span> -->
<select class="assigned_users form-control" name="assigned_to" multiple="multiple"
id="id_assigned_to">
{% for user in users %}
<option value="{{user.id}}" {% if user in event_obj.get_assigned_users_not_in_teams or user.id in assignedto_list %}
selected="" {% endif %}>{{user.email}}</option>
{% endfor %}
</select>
<span class="error error_message" id="error_id_assigned_to">{{ form.assigned_to.errors }}</span>
</div>
</div>
<div class="filter_col col-md-12">
@ -287,36 +294,170 @@
}
});
$("#id_teams").change(function (e) {
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
if (!users) {
// users = []
} else {
users = users.concat(_data.split(','))
}
})
// users = $('option:selected', this).attr('data-users')
// if (!users) {
// users = []
// } else {
// users = users.split(',')
// }
console.log('selected users teams data', users)
var existingUsers = $('#id_assigned_to').val();
var allUsers = users.concat(existingUsers)
console.log(existingUsers)
if (users.length) {
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
function find_dict(dict, id){
var index = dict.map(function(o) { return o.team; }).indexOf(parseInt(id));
return dict[index]['users']
}
$("#id_teams").change(function (e) {
var teams = []
var all_users = []
var selected_teams = []
var selected_users = []
var assigned_users = []
$.get("{% url 'events:get_teams_and_users' %}", function(data){
// console.log(data)
if(($('#id_teams').val()).length==0){
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2().trigger('change');
}
teams = data['teams']
all_users = data['users']
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
selected_teams.push($(this).val())
selected_users.push(find_dict(teams, $(this).val()))
// console.log("s_users", selected_users)
var un_select_users = [].concat.apply([], selected_users)
// console.log('un select users', un_select_users);
$('#id_assigned_to option').each(function () {
if($.inArray(parseInt($(this).val()), un_select_users) != -1){
$(this).attr('disabled', 'disabled')
$('#id_assigned_to').select2();
}
else{
$(this).show()
$(this).removeAttr('disabled')
$('#id_assigned_to').select2();
}
}
)
if (!selected_teams) {
users = []
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2();
} else {
users = users.concat(_data.split(','))
}
});
$('#id_teams option').each(function () {
if ($(this).is(':selected')) {
_data = $(this).attr('data-users').split(',')
// console.log(' selected', $(this).attr('data-users').split(','))
// console.log('selected', $(this).attr('data-users'))
}
else {
_unselected = $(this).attr('data-users').split(',')
// console.log('un selected', $(this).attr('data-users').split(','))
}
});
// console.log('selected users teams data', users)
var existingUsers = $('#id_assigned_to').val();
var allUsers = users
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
if (users.length) {
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val([]).trigger('change');
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val(existingUsers).trigger('change');
}
})
});
$(document).ready(function($) {
var teams = []
var all_users = []
var selected_teams = []
var selected_users = []
var assigned_users = []
$.get("{% url 'events:get_teams_and_users' %}", function(data){
if(($('#id_teams').val()).length==0){
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
// $('#id_assigned_to').select2().val([]).trigger('change');
}
teams = data['teams']
all_users = data['users']
try {
var users = []
$('#id_teams option:selected').each(function () {
// users.push($(this).attr('data-users'))
_data = $(this).attr('data-users');
selected_teams.push($(this).val())
selected_users.push(find_dict(teams, $(this).val()))
var un_select_users = [].concat.apply([], selected_users)
$('#id_assigned_to option').each(function () {
if($.inArray(parseInt($(this).val()), un_select_users) != -1){
// $(this).attr('disabled', 'disabled')
$(this).attr('disabled', 'disabled')
$('#id_assigned_to').select2();
}
else{
$(this).show()
$(this).removeAttr('disabled')
$('#id_assigned_to').select2();
}
}
)
if (!selected_teams) {
users = []
$('#id_assigned_to option').each(function () {
$(this).removeAttr('disabled')
})
$('#id_assigned_to').select2();
} else {
users = users.concat(_data.split(','))
}
});
$('#id_teams option').each(function () {
if ($(this).is(':selected')) {
_data = $(this).attr('data-users').split(',')
}
else {
_unselected = $(this).attr('data-users').split(',')
}
});
var existingUsers = $('#id_assigned_to').val();
// var allUsers = users.concat(existingUsers)
var allUsers = users
// console.log(existingUsers)
$('#_id_assigned_to').select2().val(allUsers).trigger('change');
if (users.length) {
}
} catch (error) {
console.log(error)
$('#_id_assigned_to').select2().val([]).trigger('change');
}
})
});
</script>

View file

@ -57,7 +57,7 @@
<select class="assigned_users form-control" name="assigned_to" multiple="multiple">
{% for user in users %}
<option value="{{user.id}}" {% if user.id|slugify in assigned_to %} selected="" {% endif %}>
{{user.email}}</option>
{% if user.username %}{{user.username}}{% else %}{{user.email}}{% endif %}</option>
{% endfor %}
</select>
</div>
@ -201,7 +201,7 @@
{% endif %}
</td>
<td class="actions">
{% if request.user == event.created_by or request.user.role == 'ADMIN' %}
{% if request.user == event.created_by or request.user.role == 'ADMIN' or request.user.has_sales_access %}
<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" title="Edit"><i
@ -545,4 +545,4 @@
$('#leads_filter').submit();
});
</script>
{% endblock js_block %}
{% endblock js_block %}

View file

@ -18,4 +18,5 @@ urlpatterns = [
path('attachment/add/', AddAttachmentView.as_view(), name="add_attachment"),
path('attachment/remove/', DeleteAttachmentsView.as_view(),
name="remove_attachment"),
path('get_teams_and_users/', get_teams_and_users, name="get_teams_and_users")
]

View file

@ -20,6 +20,18 @@ from common.access_decorators_mixins import (
from teams.models import Teams
@login_required
def get_teams_and_users(request):
data = {}
teams = Teams.objects.all()
teams_data = [{'team': team.id, 'users': [
user.id for user in team.users.all()]} for team in teams]
users = User.objects.all().values_list("id", flat=True)
data['teams'] = teams_data
data['users'] = list(users)
return JsonResponse(data)
@login_required
@sales_access_required
def events_list(request):
@ -35,7 +47,6 @@ def events_list(request):
else:
pass
if request.method == 'GET':
context = {}
if request.user.role == 'ADMIN' or request.user.is_superuser:
@ -43,12 +54,13 @@ def events_list(request):
else:
events = Event.objects.filter(
Q(created_by=request.user) | Q(assigned_to=request.user)).distinct()
context['events'] = events.order_by('id')
context['events'] = events.order_by('-created_on')
# context['status'] = status
context['users'] = users
user_ids = list(events.values_list('created_by', flat=True))
user_ids.append(request.user.id)
context['created_by_users'] = users.filter(is_active=True, id__in=user_ids)
context['created_by_users'] = users.filter(
is_active=True, id__in=user_ids)
return render(request, 'events_list.html', context)
if request.method == 'POST':
@ -79,10 +91,11 @@ def events_list(request):
events = events.filter(
date_of_meeting=request.POST.get('date_of_meeting'))
context['events'] = events.distinct().order_by('id')
context['events'] = events.distinct().order_by('-created_on')
user_ids = list(events.values_list('created_by', flat=True))
user_ids.append(request.user.id)
context['created_by_users'] = users.filter(is_active=True, id__in=user_ids)
context['created_by_users'] = users.filter(
is_active=True, id__in=user_ids)
return render(request, 'events_list.html', context)
@ -111,7 +124,8 @@ def event_create(request):
event.save()
form.save_m2m()
if request.POST.getlist('teams', []):
user_ids = Teams.objects.filter(id__in=request.POST.getlist('teams')).values_list('users', flat=True)
user_ids = Teams.objects.filter(id__in=request.POST.getlist(
'teams')).values_list('users', flat=True)
assinged_to_users_ids = event.assigned_to.all().values_list('id', flat=True)
for user_id in user_ids:
if user_id not in assinged_to_users_ids:
@ -119,7 +133,8 @@ def event_create(request):
if request.POST.getlist('teams', []):
event.teams.add(*request.POST.getlist('teams'))
assigned_to_list = list(event.assigned_to.all().values_list('id', flat=True))
assigned_to_list = list(
event.assigned_to.all().values_list('id', flat=True))
send_email.delay(
event.id, assigned_to_list, domain=request.get_host(), protocol=request.scheme)
@ -146,7 +161,8 @@ def event_create(request):
event.contacts.add(*request.POST.getlist('contacts'))
event.assigned_to.add(*request.POST.getlist('assigned_to'))
if request.POST.getlist('teams', []):
user_ids = Teams.objects.filter(id__in=request.POST.getlist('teams')).values_list('users', flat=True)
user_ids = Teams.objects.filter(id__in=request.POST.getlist(
'teams')).values_list('users', flat=True)
assinged_to_users_ids = event.assigned_to.all().values_list('id', flat=True)
for user_id in user_ids:
if user_id not in assinged_to_users_ids:
@ -154,9 +170,10 @@ def event_create(request):
if request.POST.getlist('teams', []):
event.teams.add(*request.POST.getlist('teams'))
assigned_to_list = list(event.assigned_to.all().values_list('id', flat=True))
assigned_to_list = list(
event.assigned_to.all().values_list('id', flat=True))
send_email.delay(
event.id, assigned_to_list, domain=request.get_host(), protocol=request.scheme)
event.id, assigned_to_list, domain=request.get_host(), protocol=request.scheme)
return JsonResponse({'error': False, 'success_url': reverse('events:events_list')})
else:
@ -215,7 +232,8 @@ def event_update(request, event_id):
if form.is_valid():
start_date = form.cleaned_data.get('start_date')
end_date = form.cleaned_data.get('end_date')
previous_assigned_to_users = list(event_obj.assigned_to.all().values_list('id', flat=True))
previous_assigned_to_users = list(
event_obj.assigned_to.all().values_list('id', flat=True))
# recurring_days
# recurring_days = request.POST.getlist('days')
@ -226,7 +244,8 @@ def event_update(request, event_id):
event.save()
form.save_m2m()
if request.POST.getlist('teams', []):
user_ids = Teams.objects.filter(id__in=request.POST.getlist('teams')).values_list('users', flat=True)
user_ids = Teams.objects.filter(id__in=request.POST.getlist(
'teams')).values_list('users', flat=True)
assinged_to_users_ids = event.assigned_to.all().values_list('id', flat=True)
for user_id in user_ids:
if user_id not in assinged_to_users_ids:
@ -236,8 +255,10 @@ def event_update(request, event_id):
event.teams.add(*request.POST.getlist('teams'))
else:
event.teams.clear()
assigned_to_list = list(event.assigned_to.all().values_list('id', flat=True))
recipients = list(set(assigned_to_list) - set(previous_assigned_to_users))
assigned_to_list = list(
event.assigned_to.all().values_list('id', flat=True))
recipients = list(set(assigned_to_list) -
set(previous_assigned_to_users))
send_email.delay(
event.id, recipients, domain=request.get_host(), protocol=request.scheme)
@ -246,7 +267,8 @@ def event_update(request, event_id):
event.save()
form.save_m2m()
if request.POST.getlist('teams', []):
user_ids = Teams.objects.filter(id__in=request.POST.getlist('teams')).values_list('users', flat=True)
user_ids = Teams.objects.filter(id__in=request.POST.getlist(
'teams')).values_list('users', flat=True)
assinged_to_users_ids = event.assigned_to.all().values_list('id', flat=True)
for user_id in user_ids:
if user_id not in assinged_to_users_ids:
@ -256,8 +278,10 @@ def event_update(request, event_id):
event.teams.add(*request.POST.getlist('teams'))
else:
event.teams.clear()
assigned_to_list = list(event.assigned_to.all().values_list('id', flat=True))
recipients = list(set(assigned_to_list) - set(previous_assigned_to_users))
assigned_to_list = list(
event.assigned_to.all().values_list('id', flat=True))
recipients = list(set(assigned_to_list) -
set(previous_assigned_to_users))
send_email.delay(
event.id, recipients, domain=request.get_host(), protocol=request.scheme)

Some files were not shown because too many files have changed in this diff Show more