fixed issue of Normal user shouldn't get edit & delete options under actions in document list page, displaying contacts in account detail page, APISettings modal updated with website field and also CRUD opearations views respective to website field (#209)
* added django storages, loading local or aws storages based on env variable, removed reset password option for loggedin user, fixed issue of account edit in account list, removed address text in leads create page, properly aligining attachments, fixed issue of unable to see assigned contacts in edit account page * added source column in leads list page, fixed issue converting leads to accounts in leads view page, displaying billing address details in accounts view page, added more colors for tags * fixed issue of Normal user shouldn't get edit & delete options under actions in document list page, displaying contacts in account detail page, APISettings modal updated with website field and also CRUD opearations views respective to website field
This commit is contained in:
parent
24788d8d9f
commit
65db196826
21 changed files with 485 additions and 103 deletions
|
|
@ -129,17 +129,6 @@
|
|||
{{ account_form.assigned_to.errors }}
|
||||
</div>-->
|
||||
</div>
|
||||
<div class="filter_col col-12">
|
||||
<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 in account_obj.assigned_to.all or user.id in assignedto_list %} selected="" {% endif %}>{{user.email}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{{ account_form.assigned_to.errors }}
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
|
|
@ -196,12 +185,13 @@
|
|||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-tagsinput/1.3.6/jquery.tagsinput.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
// $(document).ready(function() {
|
||||
// $('.assigned_users').select2();
|
||||
// });
|
||||
$(document).ready(function() {
|
||||
$("#id_contacts").select2();
|
||||
$('.assigned_users').select2();
|
||||
});
|
||||
|
||||
|
||||
$("#copy_billing_btn").click(function(){
|
||||
var address_line = $("#id_address_line").val();
|
||||
var street = $("#id_street").val();
|
||||
|
|
@ -273,3 +263,4 @@
|
|||
}
|
||||
</script>
|
||||
{% endblock js_block %}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import re
|
||||
from django import forms
|
||||
from django.contrib.auth import authenticate
|
||||
from django.contrib.auth.forms import PasswordResetForm
|
||||
|
|
@ -198,6 +199,19 @@ class UserCommentForm(forms.ModelForm):
|
|||
fields = ('comment', 'user', 'commented_by')
|
||||
|
||||
|
||||
def find_urls(string):
|
||||
# website_regex = "^((http|https)://)?([A-Za-z0-9.-]+\.[A-Za-z]{2,63})?$" # (http(s)://)google.com or google.com
|
||||
# website_regex = "^https?://([A-Za-z0-9.-]+\.[A-Za-z]{2,63})?$" # (http(s)://)google.com
|
||||
website_regex = "^https?://[A-Za-z0-9.-]+\.[A-Za-z]{2,63}$" # http(s)://google.com
|
||||
website_regex_port = "^https?://[A-Za-z0-9.-]+\.[A-Za-z]{2,63}:[0-9]{2,4}$" # http(s)://google.com:8000
|
||||
url = re.findall(website_regex, string)
|
||||
url_port = re.findall(website_regex_port, string)
|
||||
if len(url) > 0 and url[0] != '':
|
||||
return url
|
||||
else:
|
||||
return url_port
|
||||
|
||||
|
||||
class APISettingsForm(forms.ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
@ -215,4 +229,13 @@ class APISettingsForm(forms.ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = APISettings
|
||||
fields = ('title', 'lead_assigned_to')
|
||||
fields = ('title', 'lead_assigned_to', 'website')
|
||||
|
||||
def clean_website(self):
|
||||
website = self.data.get('website')
|
||||
if website and not (website.startswith('http://') or website.startswith('https://')):
|
||||
raise forms.ValidationError("Please provide valid schema")
|
||||
if not len(find_urls(website)) > 0:
|
||||
raise forms.ValidationError(
|
||||
"Please provide a valid URL with schema and without trailing slash - Example: http://google.com")
|
||||
return website
|
||||
|
|
|
|||
18
common/migrations/0012_apisettings_website.py
Normal file
18
common/migrations/0012_apisettings_website.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 2.1.7 on 2019-02-19 10:53
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('common', '0011_auto_20190218_1230'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='apisettings',
|
||||
name='website',
|
||||
field=models.URLField(default='', max_length=255),
|
||||
),
|
||||
]
|
||||
|
|
@ -243,6 +243,7 @@ def generate_key():
|
|||
class APISettings(models.Model):
|
||||
title = models.CharField(max_length=1000)
|
||||
apikey = models.CharField(max_length=16, blank=True)
|
||||
website = models.URLField(max_length=255, default='')
|
||||
lead_assigned_to = models.ManyToManyField(User, related_name='lead_assignee_users')
|
||||
tags = models.ManyToManyField('accounts.Tags', blank=True)
|
||||
created_by = models.ForeignKey(User, related_name='settings_created_by', on_delete=models.SET_NULL, null=True)
|
||||
|
|
|
|||
|
|
@ -25,14 +25,14 @@
|
|||
<div class="col-md-12">
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="id_firstname">Title {% if doc_form.title.field.required %}<span class="error">*</span>{% endif %}</label>
|
||||
<label for="id_firstname">Title {% if doc_form.title.field.required %}<span class="error_marker" style="color:red">*</span>{% endif %}</label>
|
||||
<input type="text" id="title" class="form-control" name="title" value="{% if doc_obj %}{{ doc_obj.title }}{% else %}{{request.POST.title}}{% endif %}" placeholder="Document title">
|
||||
</div>
|
||||
<span class="error" id="id_title">{{ errors.title }}</span>
|
||||
</div>
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Upload Document{% if doc_form.document_file.field.required %}<span class="error">*</span>{% endif %}</label>
|
||||
<label for="exampleInputEmail1">Upload Document {% if doc_form.document_file.field.required %}<span class="error_marker" style="color:red">*</span>{% endif %}</label>
|
||||
<input type="file" name="document_file" class="form-control" id="document_file" />
|
||||
</div>
|
||||
{% if doc_obj %}<span>{{doc_file_name}}</span>{% endif %}
|
||||
|
|
@ -43,7 +43,9 @@
|
|||
<label for="exampleInputEmail1">Share To{% if doc_form.shared_to.field.required %}<span class="error">*</span>{% endif %}</label>
|
||||
<select class="assigned_users form-control" name="shared_to" multiple="multiple">
|
||||
{% for user in users %}
|
||||
<option value="{{user.id}}" {% if user in doc_obj.shared_to.all or user.id in sharedto_list %} selected="" {% endif %}>{{user.email}}</option>
|
||||
{% if user != request.user %}
|
||||
<option value="{{user.id}}" {% if user in doc_obj.shared_to.all or user.id in sharedto_list %} selected="" {% endif %}>{{user.email}}</option>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</select>
|
||||
{{ errors.shared_to.errors }}
|
||||
|
|
|
|||
|
|
@ -80,9 +80,11 @@
|
|||
<tr>
|
||||
<th width="5%">S.No</th>
|
||||
<th width="15%">Title</th>
|
||||
<th width="20%">Created By</th>
|
||||
<th width="10%">Created By</th>
|
||||
<th width="15%">Created On</th>
|
||||
<th width="10%">Status</th>
|
||||
<th width="20%">Shared To</th>
|
||||
<th width="5%">Download</th>
|
||||
<th width="10%">Actions</th>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
|
@ -106,6 +108,7 @@
|
|||
<img src="{% static 'images/user.png' %}" title="{{ document.created_by }}" width="40" height="40">
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{document.created_on}}</td>
|
||||
<td>{{document.status}}</td>
|
||||
<td>{% with shared_users=document.shared_to.all %}
|
||||
{% if shared_users %}
|
||||
|
|
@ -113,13 +116,20 @@
|
|||
<span class="text-left">{{ user.email }}</span><br>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
Not Shared to any
|
||||
Not shared with anyone
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
<td>
|
||||
{% if request.user in document.shared_to.all or request.user == document.created_by or request.user.role == 'ADMIN' %}
|
||||
<a href="{% url 'common:download_document' document.id %}">Download</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="actions">
|
||||
<a href="{% url 'common:edit_doc' document.id %}" class="btn btn-success edit"><i class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'common:remove_doc' document.id %}" class="btn btn-danger delete remove_document"><i class="fas fa-trash-alt"></i></a>
|
||||
{% if request.user == document.created_by or request.user.role == 'ADMIN' %}
|
||||
<a href="{% url 'common:edit_doc' document.id %}" class="btn btn-success edit"><i class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'common:remove_doc' document.id %}" class="btn btn-danger delete remove_document"><i class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
@ -177,3 +187,4 @@
|
|||
});
|
||||
</script>
|
||||
{% endblock js_block %}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{% url 'common:api_settings' %}">Settings</a></li>
|
||||
<li class="breadcrumb-item active">{% if setting %}Edit{% else %}Create{% endif %}</li>
|
||||
<li class="breadcrumb-item active">Create</li>
|
||||
</ol>
|
||||
</nav>
|
||||
{% endblock %}
|
||||
|
|
@ -21,20 +21,26 @@
|
|||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="card-title text-center">
|
||||
{% if setting %}EDIT{% else %}CREATE{% endif %} SETTINGS
|
||||
CREATE SETTINGS
|
||||
</div>
|
||||
<div class="row marl no-gutters">
|
||||
<div class="col-md-12">
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label>Title{% if settings_form.title.field.required %}<span class="error">*</span>{% endif %}</label>
|
||||
<input type="text" name="title" class="form-control" value="{% if setting %}{{setting.title}}{% endif %}">
|
||||
<input type="text" name="title" class="form-control" value="">
|
||||
<span class="error">{{ settings_form.title.errors }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
{{ settings_form }}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label>Website{% if settings_form.website.field.required %}<span class="error">*</span>{% endif %} <span class="help-text">Example: http://google.com</span></label>
|
||||
<input type="text" name="website" class="form-control" value="">
|
||||
<span class="error">{{ settings_form.website.errors }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="filter_col col-md-12">
|
||||
|
|
@ -42,7 +48,7 @@
|
|||
<label>Assigned Users</label>
|
||||
<select class="assigned_users form-control" name="lead_assigned_to" multiple="multiple">
|
||||
{% for user in users %}
|
||||
<option value="{{user.id}}" {% if auser in setting.lead_assigned_to.all or user.id in assign_to_list %} selected="" {% endif %}>{{user.email}}</option>
|
||||
<option value="{{user.id}}" {% if user in setting.lead_assigned_to.all or user.id in assign_to_list %} selected="" {% endif %}>{{user.email}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<span class="error">{{ settings_form.lead_assigned_to.errors }}</span>
|
||||
|
|
@ -59,6 +65,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<span class="__all__"></span>
|
||||
<div class="row marl buttons_row text-center form_btn_row">
|
||||
<button class="btn btn-default save" type="submit">Save</button>
|
||||
{% if not setting %}
|
||||
|
|
@ -80,6 +87,27 @@
|
|||
<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 type="text/javascript">
|
||||
$("#add_form").submit(function(e){
|
||||
e.preventDefault();
|
||||
$form = $(this)
|
||||
$.post("", $form.serialize(), function(response){
|
||||
$(".error").remove();
|
||||
if(response.error){
|
||||
$.each(response.errors, function(field_name, error){
|
||||
if (field_name == '__all__'){
|
||||
error = "<span class=\"error\" style=color:red>" + error + "</span>"
|
||||
$("span.__all__").after(error)
|
||||
}else{
|
||||
error = "<span class=\"error\" style=color:red>" + error + "</span>"
|
||||
$form.find("[name="+field_name + "]").after(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
else{
|
||||
window.location = response.success_url
|
||||
}
|
||||
});
|
||||
});
|
||||
$(".savenew").on('click', function(e){
|
||||
e.preventDefault()
|
||||
$("#save_new_form").val('true')
|
||||
|
|
|
|||
|
|
@ -7,55 +7,88 @@
|
|||
<!-- filter_row starts here -->
|
||||
<div class="row marl">
|
||||
<div class="col-lg-12 text-right">
|
||||
<span class="d-inline"><a href="{% url 'common:add_api_settings'%}" class="btn primary_btn"><i class="fa fa-plus"></i> Add New Setting</a></span>
|
||||
<span class="d-inline"><a href="{% url 'common:create_user'%}" class="btn primary_btn"><i class="fa fa-plus"></i> Add New User</a></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- filter_row ends here -->
|
||||
<!-- popup for change password start's here -->
|
||||
<div class="modal fade" id="pass_change_div" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="padding:20px 50px;">
|
||||
<h4><span class="glyphicon glyphicon-lock"></span> Change Password</h4>
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
</div>
|
||||
<div class="modal-body" style="padding:20px 50px;">
|
||||
<form role="form" id="chang_password_form" method="POST" action="{% url 'common:change_passsword_by_admin' %}">
|
||||
<div class="form-group">
|
||||
<label for="usrname"><span class="glyphicon glyphicon-user"></span> New Password</label>
|
||||
<input type="password" class="form-control" name="new_passwoord" id="new_passwoord" placeholder="New Password">
|
||||
<p id="password_eror"style="color:red"></p>
|
||||
<input type="hidden" id="useer_id" name="useer_id">
|
||||
</div>
|
||||
<button id="submit_password" type="submit" class="btn btn-success btn-block"><span class="glyphicon glyphicon-off"></span> Change</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- popup for change password end's here -->
|
||||
<div class="table_container_row row marl">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="card-title list text-right">
|
||||
<span class="float-left">Settings - {% if show_pageitems %} {% show_pageitems %}{% else %} {{ users|length }}{% endif %}</span>
|
||||
<span class="float-left">Users - {% if show_pageitems %} {% show_pageitems %}{% else %} {{ users|length }}{% endif %}</span>
|
||||
<span class="filter_toggle">
|
||||
<a href="#" class="primary_btn"></a>
|
||||
<a style="padding:0px 10px;" href="#" class="primary_btn"></a>
|
||||
</span>
|
||||
</div>
|
||||
<div class="table-responsive ">
|
||||
<table class="table table-bordered table-striped table-condensed">
|
||||
<thead>
|
||||
{% if settings|length > 0 %}
|
||||
{% if users|length > 0 %}
|
||||
<tr>
|
||||
<th width="20%">Title</th>
|
||||
<th width="20%">API Key</th>
|
||||
<th width="8%">Assign To</th>
|
||||
<th width="15%">User</th>
|
||||
<th width="20%">Username</th>
|
||||
<th width="20%">Email Address</th>
|
||||
<th width="8%">User Role</th>
|
||||
<th width="15%">Status</th>
|
||||
<th width="20%">Actions</th>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if per_page %}
|
||||
{% paginate per_page settings %}
|
||||
{% paginate per_page users %}
|
||||
{% else %}
|
||||
{% paginate 10 settings %}
|
||||
{% paginate 10 users %}
|
||||
{% endif %}
|
||||
{% for setting in settings %}
|
||||
{% for user in users %}
|
||||
<tr class="text-center">
|
||||
<td><a href="{% url 'common:view_api_settings' setting.id %}">{{ setting.title }}</a></td>
|
||||
<td>{{ setting.apikey }}</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>
|
||||
{% for user in setting.lead_assigned_to.all %}
|
||||
{{user.email}}{% if forloop.counter < setting.lead_assigned_to.all|length %}, {% endif %}
|
||||
{% empty %}
|
||||
Not Assigned Yet!
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>{% if setting.created_by %}{{ setting.created_by.email }}{% else %}No user!{% endif %}</td>
|
||||
{% ifnotequal request.user user %}
|
||||
<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 %}
|
||||
<i class="fa fa-toggle-off"></i> InActive
|
||||
{% endif %}
|
||||
</a>
|
||||
{% else %}
|
||||
Active
|
||||
{% endifnotequal %}
|
||||
</td>
|
||||
<td class="actions">
|
||||
<!-- <a href="{% url 'common:view_api_settings' setting.id %}" class="btn btn-info view"><i class="fas fa-eye"></i>View</a> -->
|
||||
<a href="{% url 'common:update_api_settings' setting.id %}" class="btn btn-success edit action"><i class="fas fa-pencil-alt"></i>Edit</a>
|
||||
<a href="{% url 'common:delete_api_settings' setting.id %}" class="btn btn-danger trash action"><i class="fas fa-trash-alt"></i>Delete</a>
|
||||
<!-- <a href="{% url 'common:view_user' user.id %}" class="btn btn-info view"><i class="fas fa-eye"></i>View</a> -->
|
||||
{% if user.email != admin_email or request.user.email == admin_email %}
|
||||
<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" {% if request.user.email == user.email %} style="visibility: hidden;" {% endif %}><i class="fas fa-trash-alt"></i>Delete</a>
|
||||
{% if user.email != admin_email or request.user != user %}
|
||||
<a style="color:black;margin-bottom: -11px;" data-id="{{user.id}}" href="" class="fa-passwd-reset fa-stack" ><i class="fa fa-undo fa-stack-2x"></i><i class="fa fa-lock fa-stack-1x"></i></a>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
@ -63,7 +96,7 @@
|
|||
</table>
|
||||
</div>
|
||||
{% ifequal users|length 0 %}
|
||||
<h6 class="text-center">No Settings Found!</h6>
|
||||
<h6 class="text-center">No User Records Found</h6>
|
||||
{% endifequal %}
|
||||
<div class="marl row text-center">
|
||||
{% show_pages %}
|
||||
|
|
@ -85,4 +118,27 @@
|
|||
window.location = $(this).attr('href')
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
var user_id;
|
||||
$(".fa-passwd-reset").click(function(e){
|
||||
e.preventDefault();
|
||||
user_id = $(this).attr('data-id')
|
||||
$("#password_eror").text("");
|
||||
$("#pass_change_div").modal();
|
||||
});
|
||||
$("#submit_password").click(function(e){
|
||||
e.preventDefault();
|
||||
if ($("#new_passwoord").val().length <4){
|
||||
$("#password_eror").text("* Password must be atleast 4 characters long! ")
|
||||
}
|
||||
else{
|
||||
$("#password_eror").text("");
|
||||
$('#useer_id').val(user_id);
|
||||
$("#chang_password_form").submit()
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock js_block %}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@
|
|||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{% url 'common:api_settings' %}">Settings</a></li>
|
||||
<li class="breadcrumb-item active">{% if setting %}Edit{% else %}Create{% endif %}</li>
|
||||
<li class="breadcrumb-item"><a href="{% url 'common:view_api_settings' setting.id %}">{{ setting.title }}</a></li>
|
||||
<li class="breadcrumb-item active">Edit</li>
|
||||
</ol>
|
||||
</nav>
|
||||
{% endblock %}
|
||||
|
|
@ -21,7 +22,7 @@
|
|||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="card-title text-center">
|
||||
{% if setting %}EDIT{% else %}CREATE{% endif %} SETTINGS
|
||||
EDIT SETTINGS
|
||||
</div>
|
||||
<div class="row marl no-gutters">
|
||||
<div class="col-md-12">
|
||||
|
|
@ -34,7 +35,13 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
{{ settings_form }}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label>Website{% if settings_form.website.field.required %}<span class="error">*</span>{% endif %} <span class="help-text">Example: http://google.com</span></label>
|
||||
<input type="text" name="website" class="form-control" value="{% if setting %}{{setting.website}}{% endif %}">
|
||||
<span class="error">{{ settings_form.website.errors }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="filter_col col-md-12">
|
||||
|
|
@ -42,7 +49,7 @@
|
|||
<label>Assigned Users</label>
|
||||
<select class="assigned_users form-control" name="lead_assigned_to" multiple="multiple">
|
||||
{% for user in users %}
|
||||
<option value="{{user.id}}" {% if user.id in setting.lead_assigned_to.all or user.id in assign_to_list %}selected{% endif %}>{{user.email}}</option>
|
||||
<option value="{{user.id}}" {% if user in setting.lead_assigned_to.all or user.id in assign_to_list %}selected{% endif %}>{{user.email}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<span class="error">{{ settings_form.lead_assigned_to.errors }}</span>
|
||||
|
|
@ -80,6 +87,27 @@
|
|||
<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 type="text/javascript">
|
||||
$("#update_form").submit(function(e){
|
||||
e.preventDefault();
|
||||
$form = $(this)
|
||||
$.post("", $form.serialize(), function(response){
|
||||
$(".error").remove();
|
||||
if(response.error){
|
||||
$.each(response.errors, function(field_name, error){
|
||||
if (field_name == '__all__'){
|
||||
error = "<span class=\"error\" style=color:red>" + error + "</span>"
|
||||
$("span.__all__").after(error)
|
||||
}else{
|
||||
error = "<span class=\"error\" style=color:red>" + error + "</span>"
|
||||
$form.find("[name="+field_name + "]").after(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
else{
|
||||
window.location = response.success_url
|
||||
}
|
||||
});
|
||||
});
|
||||
$(".savenew").on('click', function(e){
|
||||
e.preventDefault()
|
||||
$("#save_new_form").val('true')
|
||||
|
|
|
|||
|
|
@ -1,10 +1,125 @@
|
|||
{% extends 'base.html' %}
|
||||
{% extends 'sales/base.html' %}
|
||||
{% load staticfiles %}
|
||||
{% block breadcrumb %}
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{% url 'common:api_settings' %}">Settings</a></li>
|
||||
<li class="breadcrumb-item active">{{ setting.title }} - View</li>
|
||||
</ol>
|
||||
</nav>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<!-- main_container starts here -->
|
||||
<div class="main_container">
|
||||
<!-- filter_row starts here -->
|
||||
<div class="row marl">
|
||||
<div class="main_container" id="maincontainer">
|
||||
<div class="overview_form_block row marl justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<div class="card">
|
||||
<div class="card-body" id="datashow">
|
||||
<div class="card-title text-right">
|
||||
<h5 >
|
||||
<span class="float-left title">Overview</span>
|
||||
<span class="" style="margin-top: 0px">
|
||||
<div class="dropdown buttons_row">
|
||||
<button class="btn primary_btn dropdown-toggle " type="button" data-toggle="dropdown">Actions
|
||||
<span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{% url 'common:update_api_settings' setting.id %}" >Edit</a></li>
|
||||
<li class="trash"><a href="{% url 'common:delete_api_settings' setting.id %}" >Delete</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</span>
|
||||
</h5>
|
||||
</div>
|
||||
<div class="row ">
|
||||
<div class="col-md-12">
|
||||
{% if setting.title %}
|
||||
<div class="filter_col col-md-12" id="iname">
|
||||
<div class="form-group" >
|
||||
<label class="acc_field_label" for="id_name" data-name="name">Title</label>
|
||||
<div class="account_field" id="account_name" data-name="name">{{ setting.title }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if setting.website %}
|
||||
<div class="filter_col col-md-12" id="iname">
|
||||
<div class="form-group" >
|
||||
<label class="acc_field_label" for="id_name" data-name="name">Website</label>
|
||||
<div class="account_field" id="account_name" data-name="name">{{ setting.website }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if setting.apikey %}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="acc_field_label" for="id_phone" data-name="name">API KEY</label>
|
||||
<div class="account_field" id="account_phone" data-name="name">
|
||||
<span class="copy-text" id="texttocopy">{{ setting.apikey }}</span>
|
||||
<span class="btn btn-primary" onclick="copyToClipboard('#texttocopy')"><i class="fa fa-copy"></i> Copy</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if setting.lead_assigned_to.all|length > 0 %}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="acc_field_label" for="id_email" data-name="name">Assigned To</label>
|
||||
<div class="account_field" id="account_email" data-name="name">{% for user in setting.lead_assigned_to.all %}{{user.email}}{% if forloop.counter < setting.lead_assigned_to.all|length %}, {% endif %}{% endfor %}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if setting.tags.all|length > 0 %}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="acc_field_label" for="id_website" data-name="name">Tags</label>
|
||||
<div class="account_field" id="account_website">
|
||||
{% for tag_obj in setting.tags.all %}
|
||||
<span class="">{{tag_obj.name}}</span>{% if forloop.counter < setting.tags.all|length %}, {% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if setting.created_by %}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="acc_field_label" for="id_email" data-name="name">Created By</label>
|
||||
<div class="account_field" id="account_email" data-name="name">{{ setting.created_by.email }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if setting.created_on %}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="acc_field_label" for="id_email" data-name="name">Created On</label>
|
||||
<div class="account_field" id="account_email" data-name="name">{{ setting.created_on }}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
{% endblock content %}
|
||||
{% block js_block %}
|
||||
<script type="text/javascript">
|
||||
$('.trash').click(function(e){
|
||||
e.preventDefault()
|
||||
url = $(this).attr('href')
|
||||
if (!confirm('Are you sure you want to delete?'))
|
||||
return;
|
||||
window.location = $(this).attr('href')
|
||||
});
|
||||
|
||||
function copyToClipboard(element) {
|
||||
var $temp = $("<input>");
|
||||
$("body").append($temp);
|
||||
$temp.val($(element).html()).select();
|
||||
document.execCommand("copy");
|
||||
$temp.remove();
|
||||
alert("Copied!")
|
||||
}
|
||||
|
||||
</script>
|
||||
{% endblock js_block %}
|
||||
|
|
|
|||
|
|
@ -570,3 +570,12 @@ def return_complete_address(self):
|
|||
else:
|
||||
address += self.get_country_display()
|
||||
return address
|
||||
|
||||
|
||||
def get_client_ip(request):
|
||||
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
|
||||
if x_forwarded_for:
|
||||
ip = x_forwarded_for.split(',')[0]
|
||||
else:
|
||||
ip = request.META.get('REMOTE_ADDR')
|
||||
return ip
|
||||
|
|
|
|||
|
|
@ -601,13 +601,14 @@ def add_api_settings(request):
|
|||
settings_obj.tags.add(tag)
|
||||
if assign_to_list:
|
||||
settings_obj.lead_assigned_to.add(*assign_to_list)
|
||||
success_url = reverse_lazy("common:api_settings")
|
||||
if request.POST.get("savenewform"):
|
||||
return redirect('common:add_api_settings')
|
||||
return redirect("common:api_settings")
|
||||
success_url = reverse_lazy("common:add_api_settings")
|
||||
data = {'success_url': success_url, 'error': False}
|
||||
return JsonResponse(data)
|
||||
|
||||
else:
|
||||
print (form.errors)
|
||||
data = {'form': form, "setting": api_settings,
|
||||
'users': users, 'assign_to_list': assign_to_list}
|
||||
return JsonResponse({'error': True, 'errors': form.errors})
|
||||
else:
|
||||
data = {'form': form, "setting": api_settings,
|
||||
'users': users, 'assign_to_list': assign_to_list}
|
||||
|
|
@ -647,14 +648,14 @@ def update_api_settings(request, pk):
|
|||
if assign_to_list:
|
||||
settings_obj.lead_assigned_to.clear()
|
||||
settings_obj.lead_assigned_to.add(*assign_to_list)
|
||||
success_url = reverse_lazy("common:api_settings")
|
||||
if request.POST.get("savenewform"):
|
||||
return redirect('common:add_api_settings')
|
||||
return redirect("common:api_settings")
|
||||
success_url = reverse_lazy("common:add_api_settings")
|
||||
data = {'success_url': success_url, 'error': False}
|
||||
return JsonResponse(data)
|
||||
|
||||
else:
|
||||
data = {
|
||||
'form': form, "setting": api_settings, 'users': users, 'assign_to_list': assign_to_list,
|
||||
'assigned_to_list': json.dumps([i.id for i in api_settings.lead_assigned_to.all() if i])
|
||||
}
|
||||
return JsonResponse({'error': True, 'errors': form.errors})
|
||||
else:
|
||||
data = {
|
||||
'form': form, "setting": api_settings, 'users': users, 'assign_to_list': assign_to_list,
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from common.forms import BillingAddressForm
|
|||
from common.utils import COUNTRIES
|
||||
from contacts.models import Contact
|
||||
from contacts.forms import ContactForm, ContactCommentForm, ContactAttachmentForm
|
||||
from accounts.models import Account
|
||||
|
||||
|
||||
class ContactsListView(LoginRequiredMixin, TemplateView):
|
||||
|
|
@ -77,6 +78,11 @@ class CreateContactView(LoginRequiredMixin, CreateView):
|
|||
contact_obj.address = address_obj
|
||||
contact_obj.created_by = self.request.user
|
||||
contact_obj.save()
|
||||
if self.request.GET.get('view_account', None):
|
||||
if Account.objects.filter(id=
|
||||
int(self.request.GET.get('view_account'))).exists():
|
||||
Account.objects.get(id=
|
||||
int(self.request.GET.get('view_account'))).contacts.add(contact_obj)
|
||||
return self.form_valid(form)
|
||||
|
||||
return self.form_invalid(form)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||
SECRET_KEY = 'mwx@&97%!$fx_*zgj(2ygi^(s=oh5j(cqb$=+-mkd9scbt!0v0'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from django.urls import path
|
|||
from leads.views import (
|
||||
LeadListView, CreateLeadView, LeadDetailView, UpdateLeadView, DeleteLeadView, ConvertLeadView,
|
||||
GetLeadsView, AddCommentView, UpdateCommentView, DeleteCommentView,
|
||||
AddAttachmentsView, DeleteAttachmentsView
|
||||
AddAttachmentsView, DeleteAttachmentsView, create_lead_from_site
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -12,6 +12,8 @@ app_name = 'leads'
|
|||
urlpatterns = [
|
||||
path('list/', LeadListView.as_view(), name='list'),
|
||||
path('create/', CreateLeadView.as_view(), name='add_lead'),
|
||||
# create_lead_from_site
|
||||
path('create/from-site/', create_lead_from_site, name="create_lead_from_site"),
|
||||
path('<int:pk>/view/', LeadDetailView.as_view(), name="view_lead"),
|
||||
path('<int:pk>/edit/', UpdateLeadView.as_view(), name="edit_lead"),
|
||||
path('<int:pk>/delete/', DeleteLeadView.as_view(), name="remove_lead"),
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ from django.views.generic import (
|
|||
CreateView, UpdateView, DetailView, ListView, TemplateView, View)
|
||||
|
||||
from accounts.models import Account, Tags
|
||||
from common.models import User, Comment, Attachments
|
||||
from common.utils import LEAD_STATUS, LEAD_SOURCE, COUNTRIES
|
||||
from common.models import User, Comment, Attachments, APISettings
|
||||
from common.utils import LEAD_STATUS, LEAD_SOURCE, COUNTRIES, get_client_ip
|
||||
from common import status
|
||||
from contacts.models import Contact
|
||||
from leads.models import Lead
|
||||
|
|
@ -581,7 +581,7 @@ class DeleteAttachmentsView(LoginRequiredMixin, View):
|
|||
def post(self, request, *args, **kwargs):
|
||||
self.object = get_object_or_404(Attachments, id=request.POST.get("attachment_id"))
|
||||
if (
|
||||
request.user == self.object.created_by or request.user.is_superuser or
|
||||
request.user == self.object.created_by or request.user.is_superuser or
|
||||
request.user.role == 'ADMIN'
|
||||
):
|
||||
self.object.delete()
|
||||
|
|
@ -593,30 +593,45 @@ class DeleteAttachmentsView(LoginRequiredMixin, View):
|
|||
|
||||
|
||||
def create_lead_from_site(request):
|
||||
if request.method == "POST":
|
||||
# ip_addres = get_client_ip(request)
|
||||
# website_address = request.scheme + '://' + ip_addres
|
||||
api_key = request.POST.get('apikey')
|
||||
# api_setting = APISettings.objects.filter(website=website_address, apikey=api_key).first()
|
||||
api_setting = APISettings.objects.filter(apikey=api_key).first()
|
||||
if not api_setting:
|
||||
return JsonResponse({
|
||||
'error': True, 'message': "You don't have permission, please contact the admin!."},
|
||||
status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
if request.POST.get("email") and request.POST.get("full_name"):
|
||||
user = User.objects.filter(is_admin=True, is_active=True).first()
|
||||
lead = Lead.objects.create(
|
||||
title=request.POST.get("full_name"),
|
||||
status="assigned", source="micropyramid.com",
|
||||
description=request.POST.get("message"),
|
||||
email=request.POST.get("email"), phone=request.POST.get("phone"),
|
||||
is_active=True, created_by=user)
|
||||
lead.assigned_to.add(user)
|
||||
# Send Email to Assigned Users
|
||||
site_address = request.scheme + '://' + request.META['HTTP_HOST']
|
||||
send_lead_assigned_emails.delay(lead.id, [user.id], site_address)
|
||||
# Create Contact
|
||||
contact = Contact.objects.create(
|
||||
first_name=request.POST.get("full_name"),
|
||||
email=request.POST.get("email"), phone=request.POST.get("phone"),
|
||||
description=request.POST.get("message"), created_by=user,
|
||||
is_active=True)
|
||||
contact.assigned_to.add(user)
|
||||
if api_setting and request.POST.get("email") and request.POST.get("full_name"):
|
||||
# user = User.objects.filter(is_admin=True, is_active=True).first()
|
||||
user = api_setting.created_by
|
||||
lead = Lead.objects.create(
|
||||
title=request.POST.get("full_name"),
|
||||
status="assigned", source=api_setting.website,
|
||||
description=request.POST.get("message"),
|
||||
email=request.POST.get("email"), phone=request.POST.get("phone"),
|
||||
is_active=True, created_by=user)
|
||||
lead.assigned_to.add(user)
|
||||
# Send Email to Assigned Users
|
||||
site_address = request.scheme + '://' + request.META['HTTP_HOST']
|
||||
send_lead_assigned_emails.delay(lead.id, [user.id], site_address)
|
||||
# Create Contact
|
||||
contact = Contact.objects.create(
|
||||
first_name=request.POST.get("full_name"),
|
||||
email=request.POST.get("email"), phone=request.POST.get("phone"),
|
||||
description=request.POST.get("message"), created_by=user,
|
||||
is_active=True)
|
||||
contact.assigned_to.add(user)
|
||||
|
||||
lead.contacts.add(contact)
|
||||
lead.contacts.add(contact)
|
||||
|
||||
return JsonResponse({'error': False, 'message': "Lead Created sucessfully."},
|
||||
status=status.HTTP_201_CREATED)
|
||||
return JsonResponse({'error': True, 'message': "In-valid data."},
|
||||
status=status.HTTP_400_BAD_REQUEST)
|
||||
return JsonResponse({'error': False, 'message': "Lead Created sucessfully."},
|
||||
status=status.HTTP_201_CREATED)
|
||||
return JsonResponse({'error': True, 'message': "In-valid data."},
|
||||
status=status.HTTP_400_BAD_REQUEST)
|
||||
else:
|
||||
return JsonResponse({
|
||||
'error': True, 'message': "In-valid request method."},
|
||||
status=status.HTTP_400_BAD_REQUEST)
|
||||
|
|
|
|||
43
static/css/403.css
Normal file
43
static/css/403.css
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
body {
|
||||
color: #666;
|
||||
text-align: center;
|
||||
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
margin: auto;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 56px;
|
||||
line-height: 100px;
|
||||
font-weight: normal;
|
||||
color: #456;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
color: #666;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
h3 {
|
||||
color: #456;
|
||||
font-size: 20px;
|
||||
font-weight: normal;
|
||||
line-height: 28px;
|
||||
}
|
||||
|
||||
hr {
|
||||
max-width: 800px;
|
||||
margin: 18px auto;
|
||||
border: 0;
|
||||
border-top: 1px solid #eee;
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 40vw;
|
||||
}
|
||||
|
||||
.container {
|
||||
margin: auto 20px;
|
||||
}
|
||||
|
|
@ -1476,4 +1476,15 @@ pre{
|
|||
font-size: 1.3rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.copy-text {
|
||||
border: 2px solid #dadada;
|
||||
border-style: dashed;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.help-text{
|
||||
font-size: 12px;
|
||||
color: #a7a7a7a7;
|
||||
}
|
||||
|
|
|
|||
22
templates/403.html
Normal file
22
templates/403.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{% load staticfiles %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
|
||||
<title>The page you're looking for could not be found (404)</title>
|
||||
<link href="{% static 'css/403.css' %}" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>
|
||||
404
|
||||
</h1>
|
||||
<div class="container">
|
||||
<h3>The page you're looking for could not be found.</h3>
|
||||
<hr />
|
||||
<p>Make sure the address is correct and that the page hasn't moved.</p>
|
||||
<p>Please contact your administrator if you think this is a mistake.</p>
|
||||
GO back Home<a href="/"> CRM Home</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -58,7 +58,7 @@
|
|||
<h3>The page you're looking for could not be found.</h3>
|
||||
<hr />
|
||||
<p>Make sure the address is correct and that the page hasn't moved.</p>
|
||||
<p>Please contact your GitLab administrator if you think this is a mistake.</p>
|
||||
<p>Please contact your administrator if you think this is a mistake.</p>
|
||||
GO back Home<a href="/"> CRM Home</a>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
<h3>The page you're looking for could not be found.</h3>
|
||||
<hr />
|
||||
<p>Make sure the address is correct and that the page hasn't moved.</p>
|
||||
<p>Please contact your GitLab administrator if you think this is a mistake.</p>
|
||||
<p>Please contact your administrator if you think this is a mistake.</p>
|
||||
GO back Home<a href="/"> CRM Home</a>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Reference in a new issue