Merge pull request #200 from MicroPyramid/dev

started test case enhancements
This commit is contained in:
Ashwin Kumar 2019-02-12 04:37:27 +05:30 committed by GitHub
commit 4d5fefb7cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 429 additions and 280 deletions

View file

@ -38,10 +38,9 @@
<label for="exampleInputEmail1">Assigned Users</label>
<select class="assigned_users form-control" name="assigned_to" multiple="multiple">
{% for user in users %}
<option value="{{user.id}}" {% if user in account_obj.assigned_to.all or user.id in assignedto_list or user.id in request.POST.assigned_to %} selected="" {% endif %}>{{user.email}}</option>
<option value="{{user.id}}" {% if user.id in assignedto_list %} selected="" {% endif %}>{{user.email}}</option>
{% endfor %}
</select>
{{ account_form.assigned_to.errors }}
</div>
</div>
<div class="filter_col col-md-2">

View file

@ -57,6 +57,56 @@
</div>
</div>
</div>
<div class="col-md-4">
<div class="filter_col billing_block col-md-12" style="padding: 0px;">
<div class="form-group">
<label for="exampleInputEmail1">Billing Address {% if billing_form.address_line.field.required %}<span class="error">*</span>{% endif %}</label>
{{ billing_form.address_line }}
<span class="error">{{ billing_form.address_line.errors }}</span>
</div>
<div class="row" style="margin-top: 10px;">
<div class="col-md-6">
<div class="form-group">
<label for="exampleInputEmail1">Street {% if billing_form.street.field.required %}<span class="error">*</span>{% endif %}</label>
{{ billing_form.street }}
<span class="error">{{ billing_form.street.errors }}</span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="exampleInputEmail1">PostCode {% if billing_form.postcode.field.required %}<span class="error">*</span>{% endif %}</label>
{{ billing_form.postcode }}
<span class="error">{{ billing_form.postcode.errors }}</span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="exampleInputEmail1">City {% if billing_form.city.field.required %}<span class="error">*</span>{% endif %}</label>
{{ billing_form.city }}
<span class="error">{{ billing_form.city.errors }}</span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="exampleInputEmail1">State {% if billing_form.state.field.required %}<span class="error">*</span>{% endif %}</label>
{{ billing_form.state }}
<span class="error">{{ billing_form.state.errors }}</span>
</div>
</div>
<div class="col-md-12" style="margin-top: 10px;">
<div class="form-group">
<label for="exampleInputEmail1">Country {% if billing_form.country.field.required %}<span class="error">*</span>{% endif %}</label>
{{ billing_form.country }}
<span class="error">{{ billing_form.country.errors }}</span>
</div>
</div>
</div>
</div>
<div>
<h6 style="color:white;">Copy Address</h6>
</div>
</div>
<div class="col-md-4">
<div class="filter_col col-12">
<div class="form-group">
@ -70,38 +120,6 @@
{{ account_form.assigned_to.errors }}
</div>
</div>
<div class="filter_col billing_block col-md-12">
<div class="form-group">
<label for="exampleInputEmail1">Billing Address</label>
{{ billing_form.address_line }}
<span class="error">{{ billing_form.address_line.errors }}</span>
</div>
{{ billing_form.street }}
<span class="error">{{ billing_form.street.errors }}</span>
<div class="row" style="margin-top: 10px;">
<div class="col-md-4">
{{ billing_form.city }}
<span class="error">{{ billing_form.city.errors }}</span>
</div>
<div class="col-md-4">
{{ billing_form.state }}
<span class="error">{{ billing_form.state.errors }}</span>
</div>
<div class="col-md-4">
{{ billing_form.postcode }}
<span class="error">{{ billing_form.postcode.errors }}</span>
</div>
<div class="col-md-12" style="margin-top: 10px;">
{{ billing_form.country }}
<span class="error">{{ billing_form.country.errors }}</span>
</div>
</div>
</div>
<div>
<h6 style="color:white;">Copy Address</h6>
</div>
</div>
<div class="col-md-4">
<div class="filter_col col-12">
<div class="form-group">
<label for="id_sattus">Status{% if account_form.status.field.required %}<span class="error">*</span>{% endif %}</label>

View file

@ -37,8 +37,8 @@ class AccountsListView(LoginRequiredMixin, TemplateView):
queryset = queryset.filter(industry__icontains=request_post.get('industry'))
if request_post.get('tag'):
queryset = queryset.filter(tags__in=request_post.get('tag'))
if request_post.get('assigned_to'):
queryset = queryset.filter(assigned_to__id__in=request_post.get('assigned_to'))
if request_post.getlist('assigned_to'):
queryset = queryset.filter(assigned_to__id__in=request_post.getlist('assigned_to'))
return queryset
def get_context_data(self, **kwargs):
@ -51,6 +51,8 @@ class AccountsListView(LoginRequiredMixin, TemplateView):
context['close_accounts'] = close_accounts
context["industries"] = INDCHOICES
context["per_page"] = self.request.POST.get('per_page')
context["assignedto_list"] = [
int(i) for i in self.request.POST.getlist('assigned_to', []) if i]
context['tags'] = Tags.objects.all()
tab_status = 'Open'
@ -85,7 +87,7 @@ class CreateAccountView(LoginRequiredMixin, CreateView):
def post(self, request, *args, **kwargs):
self.object = None
form = self.get_form()
billing_form = BillingAddressForm(request.POST)
billing_form = BillingAddressForm(request.POST, account=True)
shipping_form = ShippingAddressForm(request.POST, prefix='ship')
if form.is_valid() and billing_form.is_valid() and shipping_form.is_valid():
return self.form_valid(form, billing_form, shipping_form)
@ -152,10 +154,10 @@ class CreateAccountView(LoginRequiredMixin, CreateView):
context["shipping_form"] = kwargs["shipping_form"]
else:
if self.request.POST:
context["billing_form"] = BillingAddressForm(self.request.POST)
context["billing_form"] = BillingAddressForm(self.request.POST, account=True)
context["shipping_form"] = ShippingAddressForm(self.request.POST, prefix='ship')
else:
context["billing_form"] = BillingAddressForm()
context["billing_form"] = BillingAddressForm(account=True)
context["shipping_form"] = ShippingAddressForm(prefix='ship')
context["assignedto_list"] = [
int(i) for i in self.request.POST.getlist('assigned_to', []) if i]
@ -226,7 +228,7 @@ class AccountUpdateView(LoginRequiredMixin, UpdateView):
def post(self, request, *args, **kwargs):
self.object = self.get_object()
form = self.get_form()
billing_form = BillingAddressForm(request.POST, instance=self.object.billing_address)
billing_form = BillingAddressForm(request.POST, instance=self.object.billing_address, account=True)
shipping_form = ShippingAddressForm(
request.POST, instance=self.object.shipping_address, prefix='ship')
if form.is_valid() and billing_form.is_valid() and shipping_form.is_valid():
@ -304,12 +306,12 @@ class AccountUpdateView(LoginRequiredMixin, UpdateView):
else:
if self.request.POST:
context["billing_form"] = BillingAddressForm(
self.request.POST, instance=self.object.billing_address)
self.request.POST, instance=self.object.billing_address, account=True)
context["shipping_form"] = ShippingAddressForm(
self.request.POST, instance=self.object.shipping_address, prefix='ship')
else:
context["billing_form"] = BillingAddressForm(
instance=self.object.billing_address)
instance=self.object.billing_address, account=True)
context["shipping_form"] = ShippingAddressForm(
instance=self.object.shipping_address, prefix='ship')
context["assignedto_list"] = [

View file

@ -11,6 +11,8 @@ class BillingAddressForm(forms.ModelForm):
fields = ('address_line', 'street', 'city', 'state', 'postcode', 'country')
def __init__(self, *args, **kwargs):
account_view = kwargs.pop('account', False)
super(BillingAddressForm, self).__init__(*args, **kwargs)
for field in self.fields.values():
field.widget.attrs = {"class": "form-control"}
@ -26,6 +28,14 @@ class BillingAddressForm(forms.ModelForm):
'placeholder': 'Postcode'})
self.fields["country"].choices = [("", "--Country--"), ] + list(self.fields["country"].choices)[1:]
if account_view:
self.fields['address_line'].required = True
self.fields['street'].required = True
self.fields['city'].required = True
self.fields['state'].required = True
self.fields['postcode'].required = True
self.fields['country'].required = True
class ShippingAddressForm(forms.ModelForm):
class Meta:
@ -107,12 +117,14 @@ class LoginForm(forms.ModelForm):
password = self.cleaned_data.get("password")
if email and password:
self.user = authenticate(email=email, password=password)
self.user = authenticate(username=email, password=password)
if self.user:
if not self.user.is_active:
raise forms.ValidationError("User is Inactive")
pass
# raise forms.ValidationError("User is Inactive")
else:
raise forms.ValidationError("Invalid email and password")
pass
# raise forms.ValidationError("Invalid email and password")
return self.cleaned_data

View file

@ -36,6 +36,7 @@
<span class="error" id="id_document_file">{{ errors.document_file }}</span>
</div>
<p></p>
{% if doc_obj %}
<div class="filter_col col-md-12">
<div class="form-group">
<label for="id_status">Status{% if doc_form.status.field.required %}<span class="error">*</span>{% endif %}</label>
@ -43,6 +44,7 @@
<span class="error">{{ doc_form.status.errors }}</span>
</div>
</div>
{% endif %}
</div>
</div>
<div class="row marl buttons_row form_btn_row text-center">

View file

@ -10,53 +10,6 @@
<span class="d-inline"><a href="{% url 'common:create_user'%}" class="btn primary_btn"><i class="fa fa-plus"></i> Add New User</a></span>
</div>
</div>
<div class="filter_row list_filter_row row marl">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<div class="card-title">Filters</div>
<form id="users_filter" action="" method="POST">
<div class="row marl">
<div class="filter_col col-2">
<div class="form-group">
<label for="exampleInputEmail1">User Name</label>
<input type="text" class="form-control" placeholder="Username" name="username" value="{{request.POST.username}}">
</div>
</div>
<div class="filter_col col-2">
<div class="form-group">
<label for="exampleInputEmail1">First Name</label>
<input type="text" class="form-control" placeholder="First Name" name="first_name" value="{{request.POST.first_name}}">
</div>
</div>
<div class="filter_col col-2">
<div class="form-group">
<label for="exampleInputEmail1">Status</label>
<select class="form-control" name="status">
<option value="True" {% if request.POST.status == "True"%}selected{% endif %}>Active</option>
<option value="False" {% if request.POST.status == "False"%}selected{% endif %}>InActive</option>
</select>
</div>
</div>
<div class="filter_col col-3">
<div class="form-group">
<label for="exampleInputEmail1">Email</label>
<input type="text" class="form-control" placeholder="Email" name="email" value="{{request.POST.email}}">
</div>
</div>
<div class="filter_col col-3">
<div class="form-group buttons_row">
<button class="btn btn-primary save" type="submit">Search</button>
<a href="{% url 'common:users_list' %}" class="btn btn-default clear">Clear</a>
</div>
</div>
<br clear="all">
</div>
</form>
</div>
</div>
</div>
</div>
<!-- filter_row ends here -->
<div class="table_container_row row marl">
<div class="col-md-12">
@ -66,7 +19,7 @@
<span class="float-left">Users - {% if show_pageitems %} {% show_pageitems %}{% else %} {{ users|length }}{% endif %}</span>
<span class="filter_toggle">
<a href="#" class="primary_btn"><i class="fas fa-filter"></i></a>
<a href="#" class="primary_btn"></a>
</span>
</div>
<div class="table-responsive ">
@ -74,7 +27,6 @@
<thead>
{% if users|length > 0 %}
<tr>
<th width="5%">S.No</th>
<th width="20%">First Name</th>
<th width="20%">Username</th>
<th width="20%">Email Address</th>
@ -92,13 +44,12 @@
{% endif %}
{% for user in users %}
<tr class="text-center">
<td scope="row">{{ forloop.counter }}</td>
<td>{{ user.first_name }}</td>
<td><a href="{% url 'common:view_user' user.id %}">{{ user.username }}</a></td>
<td>{{ user.email }}</td>
<td class="user_role">{% if user.is_superuser %} Admin {% else %} {{user.role}} {% endif %}</td>
<td><a href="{% url 'common:change_user_status' pk=user.id %}" class="on_off" style="color: #454545; text-decoration: none;">
<td><a {% if user.is_active %} onclick="return confirm('Are you sure you want to deactivate this user?')" {% else %} onclick="return confirm('Are you sure you want to activate this user?')" {% endif %} href="{% url 'common:change_user_status' pk=user.id %}" class="on_off" style="color: #454545; text-decoration: none;">
{% if user.is_active == True %}
<i class="fa fa-toggle-on"></i> Active
{% else %}
@ -134,15 +85,6 @@
{% block js_block %}
<script type="text/javascript">
$(document).ready(function(){
$(".filter_toggle").click(function(){
$(".list_filter_row").toggle();
});
});
$('.trash').click(function(e){
e.preventDefault()
url = $(this).attr('href')
@ -150,11 +92,5 @@
return;
window.location = $(this).attr('href')
});
$("a[rel='page']").click(function(e){
e.preventDefault();
$('#users_filter').attr("action", $(this).attr("href"));
$('#users_filter').submit();
});
</script>
{% endblock js_block %}

View file

@ -44,7 +44,7 @@
{% if user_obj.last_name %}
<div class="filter_col col-md-12">
<div class="form-group">
<label class="acc_field_label" for="id_phone" data-name="name">Last Nmae</label>
<label class="acc_field_label" for="id_phone" data-name="name">Last Name</label>
<div class="account_field" id="account_phone" data-name="name">{{ user_obj.last_name }}</div>
</div>
</div>
@ -95,6 +95,7 @@
</div>
<!-- CONTACTS LIST STARTS -->
<br>
<div class="row no-gutters" style="margin-bottom: 1.5rem;">
<div class="col-md-12">
<div class="card">
<div class="card-body">
@ -168,6 +169,7 @@
</div>
</div>
</div>
</div>
<form method='GET' class="accountdetails_row">
<div class="table_container_row row marl no-gutters">
<div class="col-md-12">
@ -282,7 +284,7 @@
</tbody>
</table>
</div>
`{% ifequal contacts|length 0 %}
`{% ifequal opportunity_list|length 0 %}
<h6 class="text-center">No Opportunity Records Found</h6>
{% endifequal %}
</div>
@ -368,8 +370,8 @@
d = new Date(data.commented_on);
$("#comments_div").prepend("<li class='list-group-item list-row' id='comment"+data.comment_id+"'>"+
"<div class='float-right right-container'>"+
"<div class='list-row-buttons dropdown btn-group float-right'>"+
"<button class='btn btn-link btn-sm dropdown-toggle' data-toggle='dropdown' type='button'><span class='caret'></span></button>"+
"<div class='list-row-buttons btn-group float-right'>"+
"<button class='btn primary_btn btn-sm dropdown-toggle' data-toggle='dropdown' type='button'><span class='caret'></span>Actions</button>"+
"<ul class='dropdown-menu text-center'>"+
"<li><a class='action' onclick='edit_comment("+data.comment_id+")'>Edit</a></li>"+
"<li><a class='action' onclick='remove_comment("+data.comment_id+")''>Remove</a></li></ul></div></div>"+

View file

@ -94,24 +94,37 @@ class LoginView(TemplateView):
def post(self, request, *args, **kwargs):
form = LoginForm(request.POST, request=request)
if form.is_valid():
user = authenticate(username=request.POST.get('email'), password=request.POST.get('password'))
user = User.objects.filter(email=request.POST.get('email')).first()
# user = authenticate(username=request.POST.get('email'), password=request.POST.get('password'))
if user is not None:
if user.is_active:
login(request, user)
return HttpResponseRedirect('/')
user = authenticate(username=request.POST.get('email'),
password=request.POST.get('password'))
if user is not None:
login(request, user)
return HttpResponseRedirect('/')
else:
return render(request, "login.html", {
"error": True,
"message": "Your username and password didn't match. Please try again."
})
else:
return render(request, "login.html", {
"error": True,
"message": "Your Account is inactive. Please Contact Administrator"
})
else:
return render(request, "login.html", {
"error": True,
"message": "Your Account is InActive. Please Contact Administrator"
})
"message": "Your Account is not Found. Please Contact Administrator"
})
else:
return render(request, "login.html", {
"error": True,
"message": "Your Account is not Found. Please Contact Administrator"
})
return render(request, "login.html", {
"error": True,
"message": "Your username and password didn't match. Please try again."
})
"message": "Your username and password didn't match. Please try again."
})
class ForgotPasswordView(TemplateView):
@ -133,25 +146,11 @@ class UsersListView(AdminRequiredMixin, TemplateView):
def get_queryset(self):
queryset = self.model.objects.all()
request_post = self.request.POST
if request_post:
if request_post.get('first_name'):
queryset = queryset.filter(first_name__icontains=request_post.get('first_name'))
if request_post.get('last_name'):
queryset = queryset.filter(last_name_id=request_post.get('last_name'))
if request_post.get('username'):
queryset = queryset.filter(username__icontains=request_post.get('username'))
if request_post.get('email'):
queryset = queryset.filter(email__icontains=request_post.get('email'))
if request_post.get('status'):
queryset = queryset.filter(is_active=request_post.get('status'))
return queryset
def get_context_data(self, **kwargs):
context = super(UsersListView, self).get_context_data(**kwargs)
context["users"] = self.get_queryset()
context["active_users"] = self.get_queryset().filter(is_active=True)
context["inactive_users"] = self.get_queryset().filter(is_active=False)
context["per_page"] = self.request.POST.get('per_page')
context['admin_email'] = settings.ADMIN_EMAIL
return context

View file

@ -15,7 +15,6 @@ class LeadForm(forms.ModelForm):
self.fields['assigned_to'].queryset = assigned_users
self.fields['assigned_to'].required = False
self.fields['teams'].required = False
self.fields['phone'].required = True
for key, value in self.fields.items():
if key == 'phone':
value.widget.attrs['placeholder'] = 'Enter phone number with country code'

View file

@ -0,0 +1,18 @@
# Generated by Django 2.1.5 on 2019-02-11 06:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('leads', '0002_lead_tags'),
]
operations = [
migrations.AlterField(
model_name='lead',
name='email',
field=models.EmailField(blank=True, max_length=254, null=True),
),
]

View file

@ -13,7 +13,7 @@ class Lead(models.Model):
title = models.CharField(pgettext_lazy("Treatment Pronouns for the customer", "Title"), max_length=64, blank=True, null=True)
first_name = models.CharField(("First name"), max_length=255)
last_name = models.CharField(("Last name"), max_length=255)
email = models.EmailField()
email = models.EmailField(null=True, blank=True)
phone = PhoneNumberField(null=True, blank=True)
account = models.ForeignKey(Account, related_name='Leads', on_delete=models.CASCADE, blank=True, null=True)
status = models.CharField(_("Status of Lead"), max_length=255, blank=True, null=True, choices=LEAD_STATUS)

View file

@ -32,13 +32,15 @@
<div class="col-md-4">
<div class="filter_col col-md-12">
<div class="form-group">
<label for="exampleInputEmail1" class="name" >Name{% if lead_form.first_name.field.required %}<span class="error">*</span>{% endif %}</label>
<div class="row">
<div class="filter_col col-md-6">
<label for="exampleInputEmail1" class="name" >First Name{% if lead_form.first_name.field.required %}<span class="error">*</span>{% endif %}</label>
{{ lead_form.first_name }}
<span class="error">{{ lead_form.first_name.errors }}</span>
</div>
<div class="filter_col col-md-6">
<label for="exampleInputEmail1" class="name" >Last Name{% if lead_form.last_name.field.required %}<span class="error">*</span>{% endif %}</label>
{{ lead_form.last_name }}
<span class="error">{{ lead_form.last_name.errors }}</span>
</div>

View file

@ -1,6 +1,9 @@
{% extends 'base.html' %}
{% load staticfiles %}
{% load paginate %}
{% block extralinks %}
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
{% endblock %}
{% block content %}
<!-- main_container starts here -->
<div class="main_container">
@ -21,17 +24,32 @@
<div class="row marl">
<div class="filter_col col-md-2">
<div class="form-group">
<label for="exampleInputEmail1">First Name</label>
<input type="text" class="form-control" placeholder="First Name" name="first_name" value="{{request.POST.first_name}}">
<label for="exampleInputEmail1">Name</label>
<input type="text" class="form-control" placeholder="First Name" name="name" value="{{request.POST.name}}">
</div>
</div>
<div class="filter_col col-md-2">
<div class="form-group">
<label for="exampleInputEmail1">Last Name</label>
<input type="text" class="form-control" placeholder="Last Name" name="last_name" value="{{request.POST.last_name}}">
<label for="exampleInputEmail1">Source</label>
<select class="form-control" id="id_source" name="source" >
<option value="">--Source of Lead--</option>
{% for each_source in source %}
<option value="{{each_source.0}}" {% if request.POST.source %} {% ifequal each_source.0 request.POST.source %}selected{% endifequal %}{% endif %} >{{each_source.1}} </option>
{% endfor %}
</select>
</div>
</div>
<div class="filter_col col-md-3">
</div>
<div class="filter_col col-md-2">
<div class="form-group">
<label for="exampleInputEmail1">Assigned Users</label>
<select class="assigned_users form-control" name="assigned_to" multiple="multiple">
{% for user in users %}
<option value="{{user.id}}" {% if user.id in assignedto_list %} selected="" {% endif %}>{{user.email}}</option>
{% endfor %}
</select>
</div>
</div>
<div class="filter_col col-md-2">
<div class="form-group">
<label for="exampleInputEmail1">Lead Status</label>
<select class="form-control" id="id_status" name="status" >
@ -42,7 +60,7 @@
</select>
</div>
</div>
<div class="filter_col col-md-3">
<div class="filter_col col-md-2">
<div class="form-group">
<label for="exampleInputEmail1">Tags</label>
<select class="form-control" id="id_tag" name="tag" >
@ -53,6 +71,7 @@
</select>
</div>
</div>
<input type="hidden" name="tab_status" id="tab_status">
<div class="filter_col col-2">
<div class="form-group buttons_row">
<button class="btn btn-primary save" type="submit">Search</button>
@ -66,99 +85,202 @@
</div>
</div>
</div>
<div class="table_container_row row marl">
<div class="table_container_row row marl no-gutters">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<div class="card-title text-right">
<span class="float-left">Leads - {% if show_pageitems %} {% show_pageitems %}{% else %} {{ lead_obj|length }}{% endif %}</span>
<span class="filter_toggle">
<a href="#" class="primary_btn"><i class="fas fa-filter"></i></a>
</span>
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="open-tab" data-toggle="tab" href="#open" role="tab" aria-controls="open" aria-selected="true">Open</a>
</li>
<li class="nav-item">
<a class="nav-link" id="close-tab" data-toggle="tab" href="#close" role="tab" aria-controls="close" aria-selected="false">Closed</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="open" role="tabpanel" aria-labelledby="open">
<div class="card">
<div class="card-body">
<div class="card-title text-right">
<span class="float-left">Open Leads - {% if show_pageitems %} {% show_pageitems %}{% else %} {{ open_leads|length }}{% endif %}</span>
<span class="filter_toggle">
<a href="#" class="primary_btn"><i class="fas fa-filter"></i></a>
</span>
</div>
<div class="table-responsive">
<table class="table ">
<thead>
{% if open_leads|length > 0 %}
<tr>
<th width="5%">ID</th>
<th width="10%">Name</th>
<th width="10%">Status</th>
<th width="20%">Assigned User</th>
<th width="20%">Tags</th>
<th width="15%">Created On</th>
<th width="10%">Actions</th>
</tr>
{% endif %}
</thead>
<tbody>
{% if per_page %}
{% paginate per_page open_leads %}
{% else %}
{% paginate 10 open_leads %}
{% endif %}
{% for lead in open_leads %}
<tr class="text-center">
<td scope="row">{{ forloop.counter }}</td>
<td><a href="{% url 'leads:view_lead' lead.id %}">{{ lead.first_name }} {{ lead.last_name }}</a></td>
<td>{{ lead.get_status_display }}</td>
<td>
{% with lead_users=lead.assigned_to.all %}
{% if lead_users %}
{% for user in lead_users %}
<span class="text-left">{{ user.email }}</span><br>
{% endfor %}
{% else %}
Not Assigned to Any
{% endif %}
{% endwith %}
</td>
<td style="display: flex;">
{% with tags=lead.tags.all %}
{% if tags %}
{% for tag in tags %}
<span class="text-left" id="list_tag">{{ tag.name }}</span><br>
{% endfor %}
{% else %}
No Tags
{% endif %}
{% endwith %}
</td>
<td>{{ lead.created_on }}</td>
<td class="actions">
<a href="{% url 'leads:edit_lead' lead.id %}" class="btn btn-success edit"><i class="fas fa-pencil-alt"></i></a>
<a href="{% url 'leads:remove_lead' lead.id %}" class="btn btn-danger delete remove_account"><i class="fas fa-trash-alt"></i></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{%ifequal open_leads|length 0%}
<h6 class="text-center">No Open Lead Records Found</h6>
{%endifequal%}
<div class="marl row text-center">
{% show_pages %}
</div>
</div>
</div>
<div class="table-responsive">
<table class="table ">
<thead>
{% if lead_obj|length > 0 %}
<tr>
<th width="5%">ID</th>
<th width="10%">Name</th>
<th width="10%">Status</th>
<th width="20%">Assigned User</th>
<th width="20%">Tags</th>
<th width="15%">Created On</th>
<th width="10%">Actions</th>
</tr>
{% endif %}
</thead>
<tbody>
{% if per_page %}
{% paginate per_page lead_obj %}
{% else %}
{% paginate 10 lead_obj %}
{% endif %}
{% for lead in lead_obj %}
<tr class="text-center">
<td scope="row">{{ forloop.counter }}</td>
<td><a href="{% url 'leads:view_lead' lead.id %}">{{ lead.first_name }} {{ lead.last_name }}</a></td>
<td>{{ lead.get_status_display }}</td>
<td>
{% with lead_users=lead.assigned_to.all %}
{% if lead_users %}
{% for user in lead_users %}
<span class="text-left">{{ user.email }}</span><br>
{% endfor %}
</div>
<div class="tab-pane fade" id="close" role="tabpanel" aria-labelledby="close">
<div class="card">
<div class="card-body">
<div class="card-title text-right">
<span class="float-left">Closed Leads - {% if show_pageitems %} {% show_pageitems %}{% else %} {{ close_leads|length }}{% endif %}</span>
<span class="filter_toggle">
<a href="#" class="primary_btn"><i class="fas fa-filter"></i></a>
</span>
</div>
<div class="table-responsive">
<table class="table ">
<thead>
{% if close_leads|length > 0 %}
<tr>
<th width="5%">ID</th>
<th width="10%">Name</th>
<th width="10%">Status</th>
<th width="20%">Assigned User</th>
<th width="20%">Tags</th>
<th width="15%">Created On</th>
<th width="10%">Actions</th>
</tr>
{% endif %}
</thead>
<tbody>
{% if per_page %}
{% paginate per_page close_leads %}
{% else %}
Not Assigned to Any
{% paginate 10 close_leads %}
{% endif %}
{% endwith %}
</td>
<td style="display: flex;">
{% with tags=lead.tags.all %}
{% if tags %}
{% for tag in tags %}
<span class="text-left" id="list_tag">{{ tag.name }}</span><br>
{% endfor %}
{% else %}
No Tags
{% endif %}
{% endwith %}
</td>
<td>{{ lead.created_on }}</td>
<td class="actions">
{# <a href="{% url 'leads:view_lead' lead.id %}" class="btn btn-info view"><i class="fas fa-eye"></i> </a> #}
<a href="{% url 'leads:edit_lead' lead.id %}" class="btn btn-success edit"><i class="fas fa-pencil-alt"></i></a>
<a href="{% url 'leads:remove_lead' lead.id %}" class="btn btn-danger delete remove_account"><i class="fas fa-trash-alt"></i></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{%ifequal lead_obj|length 0%}
<h6 class="text-center">No Lead Records Found</h6>
{%endifequal%}
<div class="marl row text-center">
{% show_pages %}
{% for lead in close_leads %}
<tr class="text-center">
<td scope="row">{{ forloop.counter }}</td>
<td><a href="{% url 'leads:view_lead' lead.id %}">{{ lead.first_name }} {{ lead.last_name }}</a></td>
<td>{{ lead.get_status_display }}</td>
<td>
{% with lead_users=lead.assigned_to.all %}
{% if lead_users %}
{% for user in lead_users %}
<span class="text-left">{{ user.email }}</span><br>
{% endfor %}
{% else %}
Not Assigned to Any
{% endif %}
{% endwith %}
</td>
<td style="display: flex;">
{% with tags=lead.tags.all %}
{% if tags %}
{% for tag in tags %}
<span class="text-left" id="list_tag">{{ tag.name }}</span><br>
{% endfor %}
{% else %}
No Tags
{% endif %}
{% endwith %}
</td>
<td>{{ lead.created_on }}</td>
<td class="actions">
<a href="{% url 'leads:edit_lead' lead.id %}" class="btn btn-success edit"><i class="fas fa-pencil-alt"></i></a>
<a href="{% url 'leads:remove_lead' lead.id %}" class="btn btn-danger delete remove_account"><i class="fas fa-trash-alt"></i></a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{%ifequal close_leads|length 0%}
<h6 class="text-center">No Dead Lead Records Found</h6>
{%endifequal%}
<div class="marl row text-center">
{% show_pages %}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- filter_row ends here -->
</div>
<!-- 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>
<script type="text/javascript">
$(document).ready(function(){
$(document).ready(function(){
$('.assigned_users').select2();
$(".filter_toggle").click(function(){
$(".list_filter_row").toggle();
});
});
});
$("#close-tab").click(function(e){
$("#tab_status").val('Closed')
})
$("#open-tab").click(function(e){
$("#tab_status").val('Open')
})
tab_status = "{{tab_status}}"
if(tab_status == 'Closed'){
$("#close-tab").click()
}else{
$("#open-tab").click()
}
$('.delete').click(function(e){
e.preventDefault()
url = $(this).attr('href')

View file

@ -41,59 +41,78 @@
</div>
</div>
<div class="filter_col col-md-12">
{% if lead_record.account_name %}
<div class="form-group">
<label class="lead_field_label" for="id_contact_account" data-name="name">Account Name</label>
{% if lead_record.account_name %}
<div class="lead_field" id ="contact_account" data-name="name">{{ lead_record.account_name }}</div>
{% else %}
<div class="lead_field">Not Specified</div>
{% endif %}
</div>
{% endif %}
</div>
<div class="filter_col col-md-12">
{% if lead_record.title %}
<div class="form-group">
<label class="lead_field_label" for="id_title" data-name="name">Title</label>
<div class="lead_field" id="lead_title" data-name="name">{{ lead_record.title }}</div>
{% if lead_record.title %}
<div class="lead_field" id="lead_title" data-name="name">{{ lead_record.title }}</div>
{% else %}
<div class="lead_field">Not Specified</div>
{% endif %}
</div>
</div>
<div class="filter_col col-md-12">
<div class="form-group">
<label class="lead_field_label" for="id_phone" data-name="name">Phone</label>
{% if lead_record.phone %}
<div class="lead_field" id="lead_phone" data-name="name">{{ lead_record.phone }}</div>
{% else %}
<div class="lead_field">Not specified</div>
{% endif %}
</div>
{% endif %}
</div>
</div>
<div class="col-md-4">
<div class="filter_col col-md-12">
<div class="form-group">
<label class="lead_field_label" for="id_phone" data-name="name">Phone</label>
<div class="lead_field" id="lead_phone" data-name="name">{{ lead_record.phone }}</div>
</div>
</div>
<div class="filter_col col-md-12">
<div class="form-group">
<label class="lead_field_label" for="id_email" data-name="name">Email</label>
{% if lead_record.email %}
<div class="lead_field" id="lead_email" data-name="name">{{ lead_record.email }}</div>
{% else %}
<div class="lead_field">Not Specified</div>
{% endif %}
</div>
</div>
<div class="filter_col col-md-12">
{% if lead_record.status %}
<div class="form-group">
<label class="lead_field_label" for="id_status" data-name="name">Status</label>
<div class="lead_field" id="lead_status" data-name="name">{{ lead_record.status }}</div>
{% if lead_record.status %}
<div class="lead_field" id="lead_status" data-name="name">{{ lead_record.status }}</div>
{% else %}
<div class="lead_field">Not Specified</div>
{% endif %}
</div>
{% endif %}
</div>
<div class="filter_col col-md-12">
{% if lead_record.source %}
<div class="form-group">
<label class="lead_field_label" for="id_source" data-name="name">Source</label>
{% if lead_record.source %}
<div class="lead_field" id="lead_source" data-name="name">{{ lead_record.source }}</div>
</div>
{% else %}
<div class="lead_field">Not Specified</div>
{% endif %}
</div>
</div>
<div class="filter_col col-md-12">
{% if lead_record.website %}
<div class="form-group">
<label class="lead_field_label" for="id_website" data-name="name">Website</label>
{% if lead_record.website %}
<div class="lead_field" id="lead_website" data-name="name">{{ lead_record.website }}</div>
</div>
{% else %}
<div class="lead_field">Not Specified</div>
{% endif %}
</div>
</div>
</div>
<div class="col-md-4">

View file

@ -30,10 +30,10 @@ class LeadListView(LoginRequiredMixin, TemplateView):
queryset = self.model.objects.all().exclude(status='converted')
request_post = self.request.POST
if request_post:
if request_post.get('first_name'):
queryset = queryset.filter(first_name__icontains=request_post.get('first_name'))
if request_post.get('last_name'):
queryset = queryset.filter(last_name__icontains=request_post.get('last_name'))
if request_post.get('name'):
queryset = queryset.filter(
Q(first_name__icontains=request_post.get('name')) &
Q(last_name__icontains=request_post.get('name')))
if request_post.get('city'):
queryset = queryset.filter(address__city__icontains=request_post.get('city'))
if request_post.get('email'):
@ -42,14 +42,33 @@ class LeadListView(LoginRequiredMixin, TemplateView):
queryset = queryset.filter(status=request_post.get('status'))
if request_post.get('tag'):
queryset = queryset.filter(tags__in=request_post.get('tag'))
if request_post.get('source'):
queryset = queryset.filter(source=request_post.get('source'))
if request_post.getlist('assigned_to'):
queryset = queryset.filter(assigned_to__id__in=request_post.getlist('assigned_to'))
return queryset
def get_context_data(self, **kwargs):
context = super(LeadListView, self).get_context_data(**kwargs)
context["lead_obj"] = self.get_queryset()
# context["lead_obj"] = self.get_queryset()
open_leads = self.get_queryset().exclude(status='dead')
close_leads = self.get_queryset().filter(status='dead')
context["status"] = LEAD_STATUS
context["open_leads"] = open_leads
context["close_leads"] = close_leads
context["per_page"] = self.request.POST.get('per_page')
context["source"] = LEAD_SOURCE
context["users"] = User.objects.filter(is_active=True).order_by('email')
context["assignedto_list"] = [
int(i) for i in self.request.POST.getlist('assigned_to', []) if i]
context['tags'] = Tags.objects.all()
tab_status = 'Open'
if self.request.POST.get('tab_status'):
tab_status = self.request.POST.get('tab_status')
context['tab_status'] = tab_status
return context
def post(self, request, *args, **kwargs):

View file

@ -1,8 +1,8 @@
{% autoescape off %}
Hello {{ user.get_username }},
you was assigned to account {{ account.name }}
click the link below:
{{ protocol }}://{{ domain }}{% url 'accounts:view_account' pk=account.id %}
Sincerely,
The Django-CRM Team
Hello {{ user.get_username }}<br>,
you are assigned to account {{ account.name }}<br>
click the link below to access it:<br>
{{ protocol }}://{{ domain }}{% url 'accounts:view_account' pk=account.id %}<br>
<br>
Django-CRM
{% endautoescape %}

View file

@ -1,8 +1,8 @@
{% autoescape off %}
Hello {{ user.get_username }},
you was assigned to case {{ case.name }}
click the link below:
{{ protocol }}://{{ domain }}{% url 'cases:view_case' pk=case.id %}
Sincerely,
The Django-CRM Team
Hello {{ user.get_username }},<br>
you are assigned to case {{ case.name }}<br>
click the link below to access:<br>
{{ protocol }}://{{ domain }}{% url 'cases:view_case' pk=case.id %}<br>
<br>
Django-CRM
{% endautoescape %}

View file

@ -1,8 +1,8 @@
{% autoescape off %}
Hello {{ user.get_username }},
you was assigned to contact {{ contact.first_name }} {{ contact.last_name }}
click the link below:
{{ protocol }}://{{ domain }}{% url 'contacts:view_contact' pk=contact.id %}
Sincerely,
The Django-CRM Team
Hello {{ user.get_username }},<br>
you are assigned to contact {{ contact.first_name }} {{ contact.last_name }}<br>
click the link below to access:<br>
{{ protocol }}://{{ domain }}{% url 'contacts:view_contact' pk=contact.id %}<br>
<br>
Django-CRM
{% endautoescape %}

View file

@ -1,8 +1,8 @@
{% autoescape off %}
Hello {{ user.get_username }},
you was assigned to lead {{ lead.name }}
click the link below:
{{ protocol }}://{{ domain }}{% url 'leads:view_lead' pk=lead.id %}
Sincerely,
The Django-CRM Team
Hello {{ user.get_username }},<br>
you are assigned to lead {{ lead.name }}<br>
click the link below to access:<br>
{{ protocol }}://{{ domain }}{% url 'leads:view_lead' pk=lead.id %}<br>
<br>
Django-CRM
{% endautoescape %}

View file

@ -1,8 +1,8 @@
{% autoescape off %}
Hello {{ user.get_username }},
you was assigned to opportunity {{ opportunity.name }}
click the link below:
{{ protocol }}://{{ domain }}{% url 'opportunity:opp_view' pk=opportunity.id %}
Sincerely,
The Django-CRM Team
Hello {{ user.get_username }},<br>
you are assigned to opportunity {{ opportunity.name }}<br>
click the link below to access:<br>
{{ protocol }}://{{ domain }}{% url 'opportunity:opp_view' pk=opportunity.id %}<br>
<br>
Django-CRM
{% endautoescape %}