From df0830b93c8aae28d9411de1fa0cbad99de2131a Mon Sep 17 00:00:00 2001 From: Ashwin Date: Thu, 12 Apr 2018 17:15:10 +0530 Subject: [PATCH] code cleaning --- README.rst | 5 -- accounts/views.py | 18 +---- cases/views.py | 4 +- common/urls.py | 4 +- common/views.py | 11 +-- contacts/views.py | 4 +- crm/settings.py | 1 - emails/views.py | 19 +++-- leads/views.py | 18 +++-- opportunity/views.py | 12 +-- planner/forms.py | 2 +- requirements.txt | 2 +- static/css/main.scss | 74 +++++++++++++++---- static/css/ref.scss | 5 +- static/js/accounts/view_account.js | 25 +------ static/js/calls.js | 17 ----- static/js/cases/cases.js | 23 +----- static/js/cases/create_case.js | 18 +---- static/js/cases/show_case.js | 37 ++-------- static/js/cases/view_case.js | 19 +---- static/js/contacts/comments.js | 3 +- static/js/contacts/meetings.js | 19 ----- static/js/contacts/view_contact.js | 19 +---- static/js/leads/view_lead.js | 19 +---- static/js/meetings.js | 19 ----- static/js/opportunities/contacts.js | 31 +------- static/js/opportunities/view_opportunity.js | 21 +----- static/js/tasks.js | 17 ----- templates/accounts/accounts.html | 4 +- templates/accounts/create_account.html | 68 +---------------- templates/accounts/view_account.html | 46 +++--------- templates/base.html | 8 +- templates/cases/cases.html | 3 +- templates/cases/create_cases.html | 33 +-------- templates/cases/show_case.html | 7 +- templates/cases/view_case.html | 4 +- templates/change_password.html | 3 +- templates/contacts/contacts.html | 2 +- templates/contacts/create_contact.html | 34 +-------- templates/contacts/view_contact.html | 4 +- templates/emails/create_mail.html | 2 - templates/emails/emails.html | 10 +-- templates/emails/mail_drafts.html | 2 +- templates/emails/mail_sent.html | 1 - templates/leads/checkbox.html | 3 +- templates/leads/create_lead.html | 33 +-------- templates/leads/leads.html | 2 +- templates/leads/view_leads.html | 4 +- templates/login.html | 2 +- templates/nav_menu.html | 21 ++++-- templates/opportunity/create_opportunity.html | 33 +-------- templates/opportunity/opportunity.html | 3 +- templates/opportunity/view_opportunity.html | 4 +- templates/planner/calls.html | 41 ---------- templates/planner/meetings.html | 41 ---------- templates/planner/tasks.html | 41 ---------- templates/registration.html | 1 - templates/usera.html | 1 - templates/users/create.html | 2 +- templates/users/list.html | 2 +- 60 files changed, 184 insertions(+), 747 deletions(-) diff --git a/README.rst b/README.rst index d1d0015a..fae6498d 100644 --- a/README.rst +++ b/README.rst @@ -20,11 +20,6 @@ Django CRM is opensourse CRM developed on django framework. It has all the basic .. image:: https://www.codetriage.com/micropyramid/django-crm/badges/users.svg :target: https://www.codetriage.com/micropyramid/django-crm -.. image:: https://api.codacy.com/project/badge/Grade/b11da5f09dd542479fd3bd53944595d2 - :alt: Codacy Badge - :target: https://app.codacy.com/app/ashwin/Django-CRM?utm_source=github.com&utm_medium=referral&utm_content=MicroPyramid/Django-CRM&utm_campaign=badger - - http://django-crm.readthedocs.io for latest documentation diff --git a/accounts/views.py b/accounts/views.py index 9eda6386..5bb4733f 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -3,20 +3,15 @@ from django.http import HttpResponseRedirect, HttpResponse, JsonResponse from django.contrib.auth.decorators import login_required from accounts.models import Account from common.models import User, Address, Team, Comment -from common.utils import INDCHOICES, TYPECHOICES, COUNTRIES, CURRENCY_CODES, CASE_TYPE, PRIORITY_CHOICE, STATUS_CHOICE +from common.utils import INDCHOICES, COUNTRIES, CURRENCY_CODES, CASE_TYPE, PRIORITY_CHOICE, STATUS_CHOICE from opportunity.models import Opportunity, STAGES, SOURCES from contacts.models import Contact from cases.models import Case from accounts.forms import AccountForm, AccountCommentForm from common.forms import BillingAddressForm, ShippingAddressForm -from django.views.decorators.csrf import csrf_exempt - - -# CRUD Operations Start @login_required -@csrf_exempt def accounts_list(request): accounts_list = Account.objects.all() page = request.POST.get('per_page') @@ -40,7 +35,6 @@ def accounts_list(request): @login_required -@csrf_exempt def add_account(request): users = User.objects.filter(is_active=True).order_by('email') account_form = AccountForm(assigned_to=users) @@ -76,7 +70,7 @@ def add_account(request): 'countries': COUNTRIES, 'users': users, 'teams': teams, - 'assignedto_list': assignedto_list, + 'assignedto_list': [int(user_id) for user_id in assignedto_list], 'teams_list': teams_list }) @@ -95,7 +89,6 @@ def add_account(request): @login_required -@csrf_exempt def view_account(request, account_id): account_record = get_object_or_404(Account, id=account_id) comments = account_record.accounts_comments.all() @@ -123,7 +116,6 @@ def view_account(request, account_id): @login_required -@csrf_exempt def edit_account(request, edid): account_instance = get_object_or_404(Account, id=edid) account_billing_address = account_instance.billing_address @@ -164,7 +156,7 @@ def edit_account(request, edid): 'industries': INDCHOICES, 'teams': teams, 'users': users, - 'assignedto_list': assignedto_list, + 'assignedto_list': [int(user_id) for user_id in assignedto_list], 'teams_list': teams_list }) else: @@ -185,15 +177,11 @@ def edit_account(request, edid): @login_required -@csrf_exempt def remove_account(request, aid): account_record = get_object_or_404(Account, id=aid) account_record.delete() return redirect("accounts:list") -# CRUD Operations Ends -# Comments Section Starts - @login_required def add_comment(request): diff --git a/cases/views.py b/cases/views.py index 1c5cc204..10cd9318 100644 --- a/cases/views.py +++ b/cases/views.py @@ -79,7 +79,7 @@ def add_case(request): 'case_priority': PRIORITY_CHOICE, 'case_status': STATUS_CHOICE, 'teams_list': teams_list, - 'assignedto_list': assignedto_list, + 'assignedto_list': [int(user_id) for user_id in assignedto_list], 'contacts_list': contacts_list }) return render(request, "cases/create_cases.html", { @@ -151,7 +151,7 @@ def edit_case(request, case_id): 'case_priority': PRIORITY_CHOICE, 'case_status': STATUS_CHOICE, 'teams_list': teams_list, - 'assignedto_list': assignedto_list, + 'assignedto_list': [int(user_id) for user_id in assignedto_list], 'contacts_list': contacts_list }) diff --git a/common/urls.py b/common/urls.py index b6f741ad..a4f248a2 100644 --- a/common/urls.py +++ b/common/urls.py @@ -13,7 +13,7 @@ urlpatterns = [ url(r'^profile/$', views.profile, name="profile"), url(r'^users/list$', views.users_list, name="users_list"), url(r'^users/create$', views.create_user, name="create_user"), - url(r'^user/(?P\d*)/view/$', views.view_user, name="view_user"), - url(r'^user/(?P\d*)/edit/$', views.edit_user, name="edit_user"), + url(r'^users/(?P\d*)/view/$', views.view_user, name="view_user"), + url(r'^users/(?P\d*)/edit/$', views.edit_user, name="edit_user"), url(r'^user/(?P\d*)/delete/$', views.remove_user, name="remove_user"), ] diff --git a/common/views.py b/common/views.py index a7a7d532..355d5942 100644 --- a/common/views.py +++ b/common/views.py @@ -1,7 +1,6 @@ from django.shortcuts import render, redirect, get_object_or_404 from django.contrib.auth.decorators import login_required -from django.views.decorators.csrf import csrf_exempt -from django.http import HttpResponseRedirect, JsonResponse +from django.http import HttpResponseRedirect from django.http.response import Http404 from django.contrib.auth import logout, authenticate, login from django.contrib.auth.hashers import check_password @@ -57,7 +56,6 @@ def profile(request): return render(request, "profile.html", {'user_obj': user_obj}) -@csrf_exempt def login_crm(request): if request.user.is_authenticated: return HttpResponseRedirect('/') @@ -78,7 +76,6 @@ def login_crm(request): return render(request, 'login.html') -@csrf_exempt def logout_crm(request): logout(request) request.session.flush() @@ -86,7 +83,6 @@ def logout_crm(request): @admin_required -@csrf_exempt def users_list(request): users_list = User.objects.all() page = request.POST.get('per_page') @@ -111,10 +107,8 @@ def users_list(request): @admin_required -@csrf_exempt def create_user(request): user_form = UserForm() - users_list = User.objects.all() if request.method == 'POST': user_form = UserForm(request.POST) if user_form.is_valid(): @@ -130,7 +124,6 @@ def create_user(request): @admin_required -@csrf_exempt def view_user(request, user_id): users_list = User.objects.all() user_obj = User.objects.filter(id=user_id) @@ -143,7 +136,6 @@ def view_user(request, user_id): @admin_required -@csrf_exempt def edit_user(request, user_id): user_obj = get_object_or_404(User, id=user_id) user_form = UserForm(instance=user_obj) @@ -162,7 +154,6 @@ def edit_user(request, user_id): @admin_required -@csrf_exempt def remove_user(request, user_id): user_obj = get_object_or_404(User, id=user_id) user_obj.delete() diff --git a/contacts/views.py b/contacts/views.py index bb340563..728e51a6 100644 --- a/contacts/views.py +++ b/contacts/views.py @@ -78,7 +78,7 @@ def add_contact(request): 'countries': COUNTRIES, 'teams': teams, 'users': users, - 'assignedto_list': assignedto_list, + 'assignedto_list': [int(user_id) for user_id in assignedto_list], 'teams_list': teams_list }) else: @@ -142,7 +142,7 @@ def edit_contact(request, pk): 'countries': COUNTRIES, 'teams': teams, 'users': users, - 'assignedto_list': assignedto_list, + 'assignedto_list': [int(user_id) for user_id in assignedto_list], 'teams_list': teams_list }) else: diff --git a/crm/settings.py b/crm/settings.py index 110d0358..8c281952 100644 --- a/crm/settings.py +++ b/crm/settings.py @@ -43,7 +43,6 @@ INSTALLED_APPS = [ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', diff --git a/emails/views.py b/emails/views.py index b8406382..59912f65 100644 --- a/emails/views.py +++ b/emails/views.py @@ -103,10 +103,10 @@ def email_draft(request): fd = datetime.strptime(from_date, "%Y-%m-%d").date() filter_list = filter_list.filter(send_time__gte=fd) if request.GET.get('to_date', ''): - to_date = request.GET.get('to_date', '') - td = datetime.strptime(to_date, "%Y-%m-%d") - td = td + timedelta(seconds=(24 * 60 * 60 - 1)) - filter_list = filter_list.filter(send_time__lte=td) + to_date = request.GET.get('to_date', '') + td = datetime.strptime(to_date, "%Y-%m-%d") + td = td + timedelta(seconds=(24 * 60 * 60 - 1)) + filter_list = filter_list.filter(send_time__lte=td) if request.GET.get('name', ''): name = request.GET.get('name', '') filter_list = filter_list.filter(to_email__startswith=name) @@ -146,15 +146,14 @@ def email_imp_list(request): filter_list = filter_list.filter(send_time__gte=fd) if request.GET.get('to_date', ''): - to_date = request.GET.get('to_date', '') - td = datetime.strptime(to_date, "%Y-%m-%d") - td = td + timedelta(seconds=(24 * 60 * 60 - 1)) - filter_list = filter_list.filter(send_time__lte=td) + to_date = request.GET.get('to_date', '') + td = datetime.strptime(to_date, "%Y-%m-%d") + td = td + timedelta(seconds=(24 * 60 * 60 - 1)) + filter_list = filter_list.filter(send_time__lte=td) if request.GET.get('name', ''): name = request.GET.get('name', '') filter_list = filter_list.filter(to_email__startswith=name) - return render(request, 'emails/mail_important.html', - {'filter_list': filter_list}) + return render(request, 'emails/mail_important.html', {'filter_list': filter_list}) def email_sent_edit(request, pk): diff --git a/leads/views.py b/leads/views.py index 9e64a0bd..72d86d50 100644 --- a/leads/views.py +++ b/leads/views.py @@ -3,13 +3,12 @@ from django.http import HttpResponseRedirect, HttpResponse, JsonResponse from django.contrib.auth.decorators import login_required from django.urls import reverse from django.db.models import Q -from django.views.decorators.csrf import csrf_exempt from django.forms.models import modelformset_factory from leads.models import Lead from contacts.forms import ContactForm from common.models import User, Address, Comment, Team -from common.utils import LEAD_STATUS, LEAD_SOURCE, INDCHOICES, TYPECHOICES, COUNTRIES +from common.utils import LEAD_STATUS, LEAD_SOURCE, INDCHOICES, COUNTRIES from leads.forms import LeadCommentForm, LeadForm from accounts.forms import AccountForm from common.forms import BillingAddressForm, ShippingAddressForm @@ -69,9 +68,12 @@ def add_lead(request): if request.POST.get('status') == "converted": account_object = Account.objects.create( created_by=request.user, name=lead_account, - email=lead_email, phone=lead_phone + email=lead_email, phone=lead_phone, + description=request.POST.get('description'), + website=request.POST.get('website'), ) account_object.billing_address = address_object + account_object.assigned_to.add(*assignedto_list) account_object.save() if request.POST.get("savenewform"): return HttpResponseRedirect(reverse("leads:add_lead")) @@ -83,7 +85,7 @@ def add_lead(request): 'accounts': accounts, 'countries': COUNTRIES, 'teams': teams, 'users': users, 'status': LEAD_STATUS, 'source': LEAD_SOURCE, - 'assignedto_list': assignedto_list, 'teams_list': teams_list}) + 'assignedto_list': [int(user_id) for user_id in assignedto_list], 'teams_list': teams_list}) else: return render(request, 'leads/create_lead.html', { 'lead_form': form, 'address_form': address_form, @@ -93,7 +95,6 @@ def add_lead(request): @login_required -@csrf_exempt def view_lead(request, lead_id): lead_record = get_object_or_404(Lead, id=lead_id) comments = Comment.objects.filter(lead__id=lead_id).order_by('-id') @@ -149,9 +150,12 @@ def edit_lead(request, lead_id): if request.POST.get('status') == "converted": account_object = Account.objects.create( created_by=request.user, name=lead_account, - email=lead_email, phone=lead_phone + email=lead_email, phone=lead_phone, + description=request.POST.get('description'), + website=request.POST.get('website') ) account_object.billing_address = dis_address_obj + account_object.assigned_to.add(*assignedto_list) account_object.save() return HttpResponseRedirect(reverse('leads:list')) else: @@ -162,7 +166,7 @@ def edit_lead(request, lead_id): 'accounts': accounts, 'countries': COUNTRIES, 'teams': teams, 'users': users, 'status': LEAD_STATUS, 'source': LEAD_SOURCE, - 'assignedto_list': assignedto_list, 'teams_list': teams_list}) + 'assignedto_list': [int(user_id) for user_id in assignedto_list], 'teams_list': teams_list}) else: return render(request, 'leads/create_lead.html', { 'lead_form': form, 'address_form': address_form, diff --git a/opportunity/views.py b/opportunity/views.py index f8770f5a..0b88964c 100644 --- a/opportunity/views.py +++ b/opportunity/views.py @@ -1,6 +1,4 @@ -import json - -from django.shortcuts import render, redirect +from django.shortcuts import render from django.http import HttpResponseRedirect, HttpResponse, JsonResponse from django.contrib.auth.decorators import login_required from django.shortcuts import get_object_or_404 @@ -85,7 +83,7 @@ def opp_create(request): 'stages': STAGES, 'sources': SOURCES, 'currencies': CURRENCY_CODES, - 'assignedto_list': assignedto_list, + 'assignedto_list': [int(user_id) for user_id in assignedto_list], 'teams_list': teams_list, 'contacts_list': contacts_list }) @@ -159,7 +157,7 @@ def opp_edit(request, pk): 'stages': STAGES, 'sources': SOURCES, 'currencies': CURRENCY_CODES, - 'assignedto_list': assignedto_list, + 'assignedto_list': [int(user_id) for user_id in assignedto_list], 'teams_list': teams_list, 'contacts_list': contacts_list }) @@ -202,10 +200,6 @@ def contacts(request): return JsonResponse(data) -# CRUD Operations Ends -# Comments Section Start - - @login_required def add_comment(request): if request.method == 'POST': diff --git a/planner/forms.py b/planner/forms.py index 7ce864ac..07246cf1 100644 --- a/planner/forms.py +++ b/planner/forms.py @@ -1,5 +1,5 @@ from django import forms -from planner.models import Event, Reminder +from planner.models import Reminder # class EventForm(forms.ModelForm): diff --git a/requirements.txt b/requirements.txt index 01513008..ea5763ac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ Django==2.0 django-simple-pagination==1.1.8 pytz==2018.3 -psycopg2==2.7.4 +psycopg2-binary==2.7.4 redis django-compressor==2.2 coverage diff --git a/static/css/main.scss b/static/css/main.scss index 9846c606..c4f0ed91 100644 --- a/static/css/main.scss +++ b/static/css/main.scss @@ -1,10 +1,7 @@ @import "ref.scss"; - - body { - font-family: $font_0, $font_1; + font-family: 'Muli', sans-serif; padding: 0; - font-size: 12px; font-weight: 500; margin: 0; padding-top:60px; @@ -12,6 +9,13 @@ body { .login_register_body { background: $body_bg; } + +*{ + font-size: 14px; + @media(min-width:$large){ + font-size:17px; + } + } .marl { margin-left: 0; margin-right: 0; @@ -105,6 +109,7 @@ header{ border:none; .navbar-brand{ color: $login_btn_bg; + font-weight: 600; &:hover{ color: $login_btn_bg; } @@ -112,15 +117,19 @@ header{ .navbar-nav{ >li{ >a{ - color: $text_color3; - font-weight: 500; - font-size: 12px; - padding:15px 10px; + color: lighten($text_color3, 10%) !important; + font-weight: 600; + font-size: 0.9rem; + padding:14px 10px; + padding-top: 16px; @media(min-width: $mob_min) and (max-width: $smob_max) { padding:5px 10px; } + @media(min-width:$large){ + font-size:1rem; + } &:hover{ - color:#ddd; + color:#fff !important; } } } @@ -139,7 +148,16 @@ header{ } .dropdown-menu{ a{ - font-size: 12px; + font-size: 0.9rem; + color: darken($text_color,5%); + svg{ + display: inline-block; + margin-right: 5px; + font-size: 0.75rem; + } + @media(min-width:$large){ + font-size:0.95rem; + } } } } @@ -158,9 +176,19 @@ header{ &.nav-link{ padding:0.5rem; } + &.nav-link .active { + color: white; + } } } } + /* li{ + a{ + &:hover{ + color:lighten($text_color,15%); + } + } + }*/ } .navbar-form{ .form-group{ @@ -246,28 +274,42 @@ $color_2: #000; /* main_container stats here */ .main_container{ - padding-top: 10px; + padding-top: 0.8rem; .heading_create{ .heading{ - font-size: 14px; + font-size: 1.1rem; text-transform: uppercase; letter-spacing: 1px; color: darken($text_color, 15%); - font-weight: 600; h4{ - font-size: 15px; + font-size: 1.1rem; + font-weight: 800; } } .create_new{ a{ background: $login_btn_bg; color: #fff; - font-size: 12px; - font-weight: 500; + font-size: 1rem; + font-weight: 600; text-transform: capitalize; letter-spacing: initial; display: inline-block; padding: 5px 10px 3px 10px; + /*svg{ + font-size: 0.8rem; + }*/ + @media(min-width:$large){ + font-size:1rem; + svg{ + position: relative; + top: -1px; + } + } + svg{ + display: inline-block; + margin-right: 5px; + } } } .search-row{ diff --git a/static/css/ref.scss b/static/css/ref.scss index 41adfbcb..1e2a49dd 100644 --- a/static/css/ref.scss +++ b/static/css/ref.scss @@ -16,11 +16,10 @@ $dark_sky:#099CBE; $dark_yellow:#FEA124; $inner_page_bg:#CDCDCD; -//fonts -$font_0: Poppins; -$font_1: sans-serif; + //mediaviews +$large:1500px; $med_min:992px; $med_max:1199px; $tab_max:991px; diff --git a/static/js/accounts/view_account.js b/static/js/accounts/view_account.js index 53a10f82..a160644a 100644 --- a/static/js/accounts/view_account.js +++ b/static/js/accounts/view_account.js @@ -1,24 +1,3 @@ - -/*Cookie Js Starts*/ - -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} - -/*Cookie Js Ends*/ - /*Comment Add Js Start*/ $("#comment_form").submit(function(e){ @@ -98,12 +77,10 @@ function HideError(e) { /*Comment Remove Js Start*/ function remove_comment(x) { - var csrftoken = getCookie('csrftoken'); var con = confirm("Do you want to Delete it for Sure!?") if (con == true) { $.post('/accounts/comment/remove/', { - "comment_id": x, - "csrfmiddlewaretoken": csrftoken, + "comment_id": x }, function (data) { if (data.error) { alert(data.error) diff --git a/static/js/calls.js b/static/js/calls.js index 313ddbc7..1046f321 100644 --- a/static/js/calls.js +++ b/static/js/calls.js @@ -346,24 +346,7 @@ $.ajaxSetup({ if (settings.type == 'POST' || settings.type == 'PUT' || settings.type == 'DELETE') { if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) { - // Only send the token to relative URLs i.e. locally. - xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); } } } }); -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} diff --git a/static/js/cases/cases.js b/static/js/cases/cases.js index b881ee39..a2d006e5 100644 --- a/static/js/cases/cases.js +++ b/static/js/cases/cases.js @@ -1,29 +1,12 @@ -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} function close_case(x, url){ - var csrftoken = getCookie('csrftoken'); var stat = $("#status_id"+x).text() if(stat==="Closed"){ alert("Case Already Closed") } else{ $.post(url, { - "case_id": x, - "csrfmiddlewaretoken": csrftoken + "case_id": x }, function(data) { $("#status_id"+data.cid).text(data.status) }) @@ -31,13 +14,11 @@ function close_case(x, url){ } function remove_case(x, url){ - var csrftoken = getCookie('csrftoken'); if (!confirm('Are you sure you want to Remove?')) return; window.location = url $.post(url, { - "case_id": x, - "csrfmiddlewaretoken": csrftoken + "case_id": x }, function(data) { $(".case_row" + data.case_id).remove() $(".total_count").html("Total "+data.count) diff --git a/static/js/cases/create_case.js b/static/js/cases/create_case.js index 84ca668b..63c13fa8 100644 --- a/static/js/cases/create_case.js +++ b/static/js/cases/create_case.js @@ -1,23 +1,7 @@ -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} $('#id_account').change(function(){ - var csrftoken = getCookie('csrftoken'); var account = $("#id_account").val() - $.get("/cases/select_contacts/", {"account":account, "csrfmiddlewaretoken": csrftoken}, function(data){ + $.get("/cases/select_contacts/", {"account":account}, function(data){ $("#id_contacts").html("") $.each(data, function (index, value) { $("#id_contacts").append("") diff --git a/static/js/cases/show_case.js b/static/js/cases/show_case.js index cd8fdbd0..116d9c02 100644 --- a/static/js/cases/show_case.js +++ b/static/js/cases/show_case.js @@ -1,20 +1,4 @@ -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} - $("#comment_form").submit(function(e){ e.preventDefault() var formData = new FormData($("#comment_form")[0]); @@ -115,10 +99,9 @@ function HideError(e){ } function remove_file(x){ - var csrftoken = getCookie('csrftoken'); var con = confirm("Sure, You want to delete") if (con == true){ - $.post('/cases/remove_comment_file/', {"file_id":x, "csrfmiddlewaretoken": csrftoken,}, function(data){ + $.post('/cases/remove_comment_file/', {"file_id":x}, function(data){ if(data.error){ alert(data.error) } @@ -129,10 +112,9 @@ function remove_file(x){ } function remove_comment(x){ - var csrftoken = getCookie('csrftoken'); var con = confirm("Sure, You want to delete") if (con == true){ - $.post('/cases/remove_comment/', {"comment_id":x, "csrfmiddlewaretoken": csrftoken,}, function(data){ + $.post('/cases/remove_comment/', {"comment_id":x}, function(data){ if(data.error){ alert(data.error) } @@ -143,12 +125,10 @@ function remove_comment(x){ } function editFun(x) { - var csrftoken = getCookie('csrftoken'); $.ajax({ type: "POST", url: "/cases/editdetails/", // the endpoint,commonly same url data: { - csrfmiddlewaretoken: csrftoken, tid: x }, success: function(data) { @@ -173,10 +153,8 @@ function editFun(x) { $('#id_account').change(function() { var acc = $("#id_account").val() - var csrftoken = getCookie('csrftoken'); $.get("/cases/select_contacts/", { - "acc": acc, - "csrfmiddlewaretoken": csrftoken + "acc": acc }, function(data) { $("#id_contacts").html("") $.each(data, function(index, value) { @@ -198,11 +176,10 @@ $('body').on('click', '.status_set', function (e) { eventID = $(this).closest('ul').attr('id') event = eventID.match(/\d+/)[0] status = $(this).text().replace('Set ', '') - var token = getCookie('csrftoken'); window.location = "" $.post( '/planner/event/set/status/', - {id: event, status: status, csrfmiddlewaretoken: token}, + {id: event, status: status}, function (data) { console.log("success") }) @@ -212,11 +189,10 @@ $('body').on('click', '.remove_event', function (e) { e.preventDefault(); eventID = $(this).closest('ul').attr('id') event = eventID.match(/\d+/)[0] - var token = getCookie('csrftoken'); window.location = "" $.post( '/planner/meeting/delete/', - {meetingID: event, csrfmiddlewaretoken: token}, + {meetingID: event}, function (data) { console.log("removed") }) @@ -226,10 +202,9 @@ $('body').on('click', '.display_event', function (e) { e.preventDefault(); eventID = $(this).closest('ul').attr('id') event = eventID.match(/\d+/)[0] - var token = getCookie('csrftoken'); $.post( '/planner/get/meeting/', - {meetingID: event, csrfmiddlewaretoken: token}, + {meetingID: event}, function (data, status, xhr) { $("#meeting-dispaly-model").modal("show") }) }) \ No newline at end of file diff --git a/static/js/cases/view_case.js b/static/js/cases/view_case.js index 227b96dc..b0b9f96b 100644 --- a/static/js/cases/view_case.js +++ b/static/js/cases/view_case.js @@ -1,18 +1,3 @@ -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} $("#comment_form").submit(function (e) { e.preventDefault() @@ -84,12 +69,10 @@ function HideError(e) { } function remove_comment(x) { - var csrftoken = getCookie('csrftoken'); var con = confirm("Do you want to Delete it for Sure!?") if (con == true) { $.post('/cases/comment/remove/', { - "comment_id": x, - "csrfmiddlewaretoken": csrftoken, + "comment_id": x }, function (data) { if (data.error) { alert(data.error) diff --git a/static/js/contacts/comments.js b/static/js/contacts/comments.js index 16c78dd6..2a309fbe 100644 --- a/static/js/contacts/comments.js +++ b/static/js/contacts/comments.js @@ -64,10 +64,9 @@ $("#comment_edit").click(function(e){ function remove_comment(x){ - var csrftoken = getCookie('csrftoken'); var verify = confirm("Are You Sure, you Want to Delete this Comment!?") if (verify == true){ - $.post('/contacts/comment_remove/', {"comment_id":x, "csrfmiddlewaretoken": csrftoken, }, function(data){ + $.post('/contacts/comment_remove/', {"comment_id":x}, function(data){ if(data.error){ alert(data.error) } else { diff --git a/static/js/contacts/meetings.js b/static/js/contacts/meetings.js index 41d24f90..47aae184 100644 --- a/static/js/contacts/meetings.js +++ b/static/js/contacts/meetings.js @@ -351,26 +351,7 @@ $.ajaxSetup({ if (settings.type == 'POST' || settings.type == 'PUT' || settings.type == 'DELETE') { if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) { - // Only send the token to relative URLs i.e. locally. - xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); } } } }); - - -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} diff --git a/static/js/contacts/view_contact.js b/static/js/contacts/view_contact.js index 4dab0ab3..09e5a462 100644 --- a/static/js/contacts/view_contact.js +++ b/static/js/contacts/view_contact.js @@ -1,18 +1,3 @@ -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} $("#comment_form").submit(function (e) { e.preventDefault() @@ -84,12 +69,10 @@ function HideError(e) { } function remove_comment(x) { - var csrftoken = getCookie('csrftoken'); var con = confirm("Do you want to Delete it for Sure!?") if (con == true) { $.post('/contacts/comment/remove/', { - "comment_id": x, - "csrfmiddlewaretoken": csrftoken, + "comment_id": x }, function (data) { if (data.error) { alert(data.error) diff --git a/static/js/leads/view_lead.js b/static/js/leads/view_lead.js index b86d4d58..85edf667 100644 --- a/static/js/leads/view_lead.js +++ b/static/js/leads/view_lead.js @@ -1,18 +1,3 @@ -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} $("#comment_form").submit(function (e) { e.preventDefault() @@ -85,12 +70,10 @@ function HideError(e) { } function remove_comment(x) { - var csrftoken = getCookie('csrftoken'); var con = confirm("Do you want to Delete it for Sure!?") if (con == true) { $.post('/leads/comment/remove/', { - "comment_id": x, - "csrfmiddlewaretoken": csrftoken, + "comment_id": x }, function (data) { if (data.error) { alert(data.error) diff --git a/static/js/meetings.js b/static/js/meetings.js index 5e849fcc..94f3be2a 100644 --- a/static/js/meetings.js +++ b/static/js/meetings.js @@ -369,26 +369,7 @@ $.ajaxSetup({ if (settings.type == 'POST' || settings.type == 'PUT' || settings.type == 'DELETE') { if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) { - // Only send the token to relative URLs i.e. locally. - xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); } } } }); - - -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} diff --git a/static/js/opportunities/contacts.js b/static/js/opportunities/contacts.js index f70a0101..2b3f2343 100644 --- a/static/js/opportunities/contacts.js +++ b/static/js/opportunities/contacts.js @@ -1,22 +1,7 @@ -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} $('#id_account').change(function(){ - var csrftoken = getCookie('csrftoken'); var Account= $("#id_account").val() - $.get("/opportunities/contacts/", {"Account":Account, "csrfmiddlewaretoken": csrftoken}, function(data){ + $.get("/opportunities/contacts/", {"Account":Account}, function(data){ $("#id_contacts").html("") $.each(data, function (index, value) { $("#id_contacts").append("") @@ -89,10 +74,9 @@ $("#comment_edit").click(function(e){ }); function remove_comment(x){ - var csrftoken = getCookie('csrftoken'); var warn = confirm("Are You Sure, you Want to Delete this Comment!?") if (warn == true){ - $.post('/opportunities/comment_remove/', {"comment_id":x, "csrfmiddlewaretoken": csrftoken, }, function(data){ + $.post('/opportunities/comment_remove/', {"comment_id":x}, function(data){ if(data.error){ alert(data.error) } else { @@ -103,15 +87,10 @@ function remove_comment(x){ } function editFun(x) { - var csrftoken = getCookie('csrftoken'); - alert("Heloooooooooooooo") $.ajax({ type: "POST", url: "/opportunities/editdetails/", - data: { - csrfmiddlewaretoken: csrftoken, - tid: x - }, + data: {tid: x}, success: function(data) { $("#viewdiv").hide() $("#editdiv").show() @@ -136,10 +115,8 @@ function editFun(x) { $('#id_account').change(function() { var Account = $("#id_account").val() - var csrftoken = getCookie('csrftoken'); $.get("/opportunities/contacts/", { - "Account": Account, - "csrfmiddlewaretoken": csrftoken + "Account": Account }, function(data) { $("#id_contacts").html("") $.each(data, function(index, value) { diff --git a/static/js/opportunities/view_opportunity.js b/static/js/opportunities/view_opportunity.js index 05109cf0..ef13e516 100644 --- a/static/js/opportunities/view_opportunity.js +++ b/static/js/opportunities/view_opportunity.js @@ -1,18 +1,3 @@ -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} $("#comment_form").submit(function (e) { e.preventDefault() @@ -84,13 +69,11 @@ function HideError(e) { } function remove_comment(x) { - var csrftoken = getCookie('csrftoken'); var con = confirm("Do you want to Delete it for Sure!?") if (con == true) { $.post('/opportunities/comment/remove/', { - "comment_id": x, - "csrfmiddlewaretoken": csrftoken, - }, function (data) { + "comment_id": x + }, function (data) { if (data.error) { alert(data.error) } else { diff --git a/static/js/tasks.js b/static/js/tasks.js index 0003234c..71f35dee 100644 --- a/static/js/tasks.js +++ b/static/js/tasks.js @@ -268,24 +268,7 @@ $.ajaxSetup({ if (settings.type == 'POST' || settings.type == 'PUT' || settings.type == 'DELETE') { if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) { - // Only send the token to relative URLs i.e. locally. - xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken')); } } } }); -function getCookie(name) { - var cookieValue = null; - if (document.cookie && document.cookie != '') { - var cookies = document.cookie.split(';'); - for (var i = 0; i < cookies.length; i++) { - var cookie = jQuery.trim(cookies[i]); - // Does this cookie string begin with the name we want? - if (cookie.substring(0, name.length + 1) == (name + '=')) { - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); - break; - } - } - } - return cookieValue; -} diff --git a/templates/accounts/accounts.html b/templates/accounts/accounts.html index d524d7b5..7fc7efb2 100644 --- a/templates/accounts/accounts.html +++ b/templates/accounts/accounts.html @@ -24,8 +24,7 @@
- -
{% csrf_token %} +
Filters
@@ -70,7 +69,6 @@
-
List of Accounts diff --git a/templates/accounts/create_account.html b/templates/accounts/create_account.html index cc6fd3d1..097210a2 100644 --- a/templates/accounts/create_account.html +++ b/templates/accounts/create_account.html @@ -13,41 +13,10 @@ {% endblock %} {% block content %} - {% csrf_token %} - - +
-
CREATE ACCOUNT @@ -101,9 +70,10 @@
+ {{request.POST.assigned_to}} {{ account_form.assigned_to.errors }} @@ -140,36 +110,6 @@
Copy Address
- -

@@ -216,4 +156,4 @@ $('.assigned_users').select2(); }); -{% endblock js_block %} \ No newline at end of file +{% endblock js_block %} diff --git a/templates/accounts/view_account.html b/templates/accounts/view_account.html index 18792bc4..19087290 100644 --- a/templates/accounts/view_account.html +++ b/templates/accounts/view_account.html @@ -16,7 +16,6 @@
-
@@ -143,14 +142,13 @@
-
Comments
- {% csrf_token %} +

@@ -193,7 +191,7 @@
- {% csrf_token %} +