@@ -42,7 +49,7 @@
{{ settings_form.lead_assigned_to.errors }}
@@ -80,6 +87,27 @@
+{% endblock js_block %}
diff --git a/common/utils.py b/common/utils.py
index 64c23fb0..7eb33001 100644
--- a/common/utils.py
+++ b/common/utils.py
@@ -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
diff --git a/common/views.py b/common/views.py
index a1d74a8c..691b7f1f 100644
--- a/common/views.py
+++ b/common/views.py
@@ -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,
diff --git a/contacts/views.py b/contacts/views.py
index 33862ee9..5a36165d 100644
--- a/contacts/views.py
+++ b/contacts/views.py
@@ -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)
diff --git a/crm/settings.py b/crm/settings.py
index 55542847..bb270449 100644
--- a/crm/settings.py
+++ b/crm/settings.py
@@ -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 = ['*']
diff --git a/leads/urls.py b/leads/urls.py
index c9fa1e52..4d23c0c5 100644
--- a/leads/urls.py
+++ b/leads/urls.py
@@ -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('
/view/', LeadDetailView.as_view(), name="view_lead"),
path('/edit/', UpdateLeadView.as_view(), name="edit_lead"),
path('/delete/', DeleteLeadView.as_view(), name="remove_lead"),
diff --git a/leads/views.py b/leads/views.py
index f1d951b9..23db0336 100644
--- a/leads/views.py
+++ b/leads/views.py
@@ -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)
diff --git a/static/css/403.css b/static/css/403.css
new file mode 100644
index 00000000..4c46ea5b
--- /dev/null
+++ b/static/css/403.css
@@ -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;
+}
diff --git a/static/css/main.scss b/static/css/main.scss
index 052cb074..c137e2fa 100644
--- a/static/css/main.scss
+++ b/static/css/main.scss
@@ -1476,4 +1476,15 @@ pre{
font-size: 1.3rem;
font-weight: 600;
}
-}
\ No newline at end of file
+}
+
+.copy-text {
+ border: 2px solid #dadada;
+ border-style: dashed;
+ padding: 10px;
+}
+
+.help-text{
+ font-size: 12px;
+ color: #a7a7a7a7;
+}
diff --git a/templates/403.html b/templates/403.html
new file mode 100644
index 00000000..412dc01a
--- /dev/null
+++ b/templates/403.html
@@ -0,0 +1,22 @@
+{% load staticfiles %}
+
+
+
+
+ The page you're looking for could not be found (404)
+
+
+
+
+
+ 404
+
+
+
The page you're looking for could not be found.
+
+
Make sure the address is correct and that the page hasn't moved.
+
Please contact your administrator if you think this is a mistake.
+ GO back Home
CRM Home
+
+
+
diff --git a/templates/404.html b/templates/404.html
index af236bd0..ad03c50f 100644
--- a/templates/404.html
+++ b/templates/404.html
@@ -58,7 +58,7 @@
The page you're looking for could not be found.
Make sure the address is correct and that the page hasn't moved.
- Please contact your GitLab administrator if you think this is a mistake.
+ Please contact your administrator if you think this is a mistake.
GO back Home CRM Home