Merge pull request #242 from MicroPyramid/dev
added teams and other fixes
This commit is contained in:
commit
153c8d7deb
61 changed files with 2576 additions and 488 deletions
|
|
@ -119,6 +119,7 @@
|
|||
href="{% url 'accounts:view_account' each_account.id %}">{{ each_account.name }}</a>{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if each_account.created_by %}
|
||||
{% if each_account.created_by.profile_pic %}
|
||||
{% thumbnail each_account.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
|
||||
|
|
@ -126,7 +127,10 @@
|
|||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}" alt="Micro profile pic"
|
||||
style="width: 40px;height: 40px;" />
|
||||
style="width: 40px;height: 40px;" title="{{ each_account.created_by }}" />
|
||||
{% endif %}
|
||||
{% else %}
|
||||
None
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{% if each_account.billing_city %}{{ each_account.billing_city }} {% else %} Not specified
|
||||
|
|
@ -182,6 +186,7 @@
|
|||
<tr>
|
||||
<th width="5%">ID</th>
|
||||
<th width="15%">Name</th>
|
||||
<th width="10%">Created By</th>
|
||||
<th width="10%">City</th>
|
||||
<th width="10%">State</th>
|
||||
<th width="18%">Tags</th>
|
||||
|
|
@ -201,6 +206,21 @@
|
|||
<td>{% if each_account.name %}<a
|
||||
href="{% url 'accounts:view_account' each_account.id %}">{{ each_account.name }}</a>{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if each_account.created_by %}
|
||||
{% if each_account.created_by.profile_pic %}
|
||||
{% thumbnail each_account.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
|
||||
title="{{ each_account.created_by }}">
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}" alt="Micro profile pic"
|
||||
style="width: 40px;height: 40px;" title="{{ each_account.created_by }}" />
|
||||
{% endif %}
|
||||
{% else %}
|
||||
None
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{% if each_account.billing_city %}{{ each_account.billing_city }} {% else %} Not specified
|
||||
{% endif %}</td>
|
||||
<td>{% if each_account.billing_state %}{{ each_account.billing_state }} {% else %} Not
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ from django.contrib.auth.decorators import login_required
|
|||
from accounts.tasks import send_email
|
||||
from common.tasks import send_email_user_mentions
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from common.access_decorators_mixins import (
|
||||
sales_access_required, marketing_access_required, SalesAccessRequiredMixin, MarketingAccessRequiredMixin)
|
||||
|
||||
|
||||
class AccountsListView(LoginRequiredMixin, TemplateView):
|
||||
class AccountsListView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateView):
|
||||
model = Account
|
||||
context_object_name = "accounts_list"
|
||||
template_name = "accounts.html"
|
||||
|
|
@ -95,7 +96,7 @@ class AccountsListView(LoginRequiredMixin, TemplateView):
|
|||
return self.render_to_response(context)
|
||||
|
||||
|
||||
class CreateAccountView(LoginRequiredMixin, CreateView):
|
||||
class CreateAccountView(SalesAccessRequiredMixin, LoginRequiredMixin, CreateView):
|
||||
model = Account
|
||||
form_class = AccountForm
|
||||
template_name = "create_account.html"
|
||||
|
|
@ -194,7 +195,7 @@ class CreateAccountView(LoginRequiredMixin, CreateView):
|
|||
return context
|
||||
|
||||
|
||||
class AccountDetailView(LoginRequiredMixin, DetailView):
|
||||
class AccountDetailView(SalesAccessRequiredMixin, LoginRequiredMixin, DetailView):
|
||||
model = Account
|
||||
context_object_name = "account_record"
|
||||
template_name = "view_account.html"
|
||||
|
|
@ -240,7 +241,7 @@ class AccountDetailView(LoginRequiredMixin, DetailView):
|
|||
return context
|
||||
|
||||
|
||||
class AccountUpdateView(LoginRequiredMixin, UpdateView):
|
||||
class AccountUpdateView(SalesAccessRequiredMixin, LoginRequiredMixin, UpdateView):
|
||||
model = Account
|
||||
form_class = AccountForm
|
||||
template_name = "create_account.html"
|
||||
|
|
@ -342,7 +343,7 @@ class AccountUpdateView(LoginRequiredMixin, UpdateView):
|
|||
return context
|
||||
|
||||
|
||||
class AccountDeleteView(LoginRequiredMixin, DeleteView):
|
||||
class AccountDeleteView(SalesAccessRequiredMixin, LoginRequiredMixin, DeleteView):
|
||||
model = Account
|
||||
template_name = 'view_account.html'
|
||||
|
||||
|
|
|
|||
|
|
@ -284,7 +284,8 @@ class TestCasesListViewForUser(CaseCreation, TestCase):
|
|||
first_name="mpmp",
|
||||
username='mpmp',
|
||||
email='mpmp@micropyramid.com',
|
||||
role="USER")
|
||||
role="USER",
|
||||
has_sales_access=True)
|
||||
self.usermp.set_password('mp')
|
||||
self.usermp.save()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import json
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.core.mail import EmailMessage
|
||||
|
|
@ -19,9 +20,11 @@ from django.urls import reverse
|
|||
from django.core.exceptions import PermissionDenied
|
||||
from common.tasks import send_email_user_mentions
|
||||
from cases.tasks import send_email_to_assigned_user
|
||||
from common.access_decorators_mixins import (
|
||||
sales_access_required, marketing_access_required, SalesAccessRequiredMixin, MarketingAccessRequiredMixin)
|
||||
|
||||
|
||||
class CasesListView(LoginRequiredMixin, TemplateView):
|
||||
class CasesListView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateView):
|
||||
model = Case
|
||||
context_object_name = "cases"
|
||||
template_name = "cases.html"
|
||||
|
|
@ -77,6 +80,8 @@ class CasesListView(LoginRequiredMixin, TemplateView):
|
|||
return self.render_to_response(context)
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def create_case(request):
|
||||
users = []
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser:
|
||||
|
|
@ -162,7 +167,7 @@ def create_case(request):
|
|||
return render(request, template_name, context)
|
||||
|
||||
|
||||
class CaseDetailView(LoginRequiredMixin, DetailView):
|
||||
class CaseDetailView(SalesAccessRequiredMixin, LoginRequiredMixin, DetailView):
|
||||
model = Case
|
||||
context_object_name = "case_record"
|
||||
template_name = "view_case.html"
|
||||
|
|
@ -201,6 +206,8 @@ class CaseDetailView(LoginRequiredMixin, DetailView):
|
|||
return context
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def update_case(request, pk):
|
||||
case_object = Case.objects.filter(pk=pk).first()
|
||||
accounts = Account.objects.filter(status="open")
|
||||
|
|
@ -312,7 +319,7 @@ def update_case(request, pk):
|
|||
return render(request, "create_cases.html", context)
|
||||
|
||||
|
||||
class RemoveCaseView(LoginRequiredMixin, View):
|
||||
class RemoveCaseView(SalesAccessRequiredMixin, LoginRequiredMixin, View):
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
case_id = kwargs.get("case_id")
|
||||
|
|
@ -345,7 +352,7 @@ class RemoveCaseView(LoginRequiredMixin, View):
|
|||
raise PermissionDenied
|
||||
|
||||
|
||||
class CloseCaseView(LoginRequiredMixin, View):
|
||||
class CloseCaseView(SalesAccessRequiredMixin, LoginRequiredMixin, View):
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
case_id = request.POST.get("case_id")
|
||||
|
|
|
|||
50
common/access_decorators_mixins.py
Normal file
50
common/access_decorators_mixins.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
from functools import wraps
|
||||
|
||||
from django.contrib.auth.mixins import AccessMixin, LoginRequiredMixin
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.shortcuts import redirect
|
||||
|
||||
|
||||
def sales_access_required(function):
|
||||
""" this function is a decorator used to authorize if a user has sales access """
|
||||
def wrap(request, *args, **kwargs):
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser or request.user.has_sales_access:
|
||||
return function(request, *args, **kwargs)
|
||||
else:
|
||||
raise PermissionDenied
|
||||
return wrap
|
||||
|
||||
|
||||
def marketing_access_required(function):
|
||||
""" this function is a decorator used to authorize if a user has marketing access """
|
||||
def wrap(request, *args, **kwargs):
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser or request.user.has_marketing_access:
|
||||
return function(request, *args, **kwargs)
|
||||
else:
|
||||
raise PermissionDenied
|
||||
return wrap
|
||||
|
||||
|
||||
class SalesAccessRequiredMixin(AccessMixin):
|
||||
""" """ # TODO add docs
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if not request.user.is_authenticated:
|
||||
return self.handle_no_permission()
|
||||
self.raise_exception = True
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser or request.user.has_sales_access:
|
||||
return super(SalesAccessRequiredMixin, self).dispatch(request, *args, **kwargs)
|
||||
else:
|
||||
return self.handle_no_permission()
|
||||
|
||||
|
||||
class MarketingAccessRequiredMixin(AccessMixin):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
if not request.user.is_authenticated:
|
||||
return self.handle_no_permission()
|
||||
self.raise_exception = True
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser or request.user.has_marketing_access:
|
||||
return super(MarketingAccessRequiredMixin, self).dispatch(request, *args, **kwargs)
|
||||
else:
|
||||
return self.handle_no_permission()
|
||||
|
|
@ -4,6 +4,7 @@ from django.contrib.auth import authenticate
|
|||
from django.contrib.auth.forms import PasswordResetForm
|
||||
from common.models import Address, User, Document, Comment, APISettings
|
||||
from django.contrib.auth import password_validation
|
||||
from teams.models import Teams
|
||||
|
||||
|
||||
class BillingAddressForm(forms.ModelForm):
|
||||
|
|
@ -68,11 +69,14 @@ class ShippingAddressForm(forms.ModelForm):
|
|||
class UserForm(forms.ModelForm):
|
||||
|
||||
password = forms.CharField(max_length=100, required=False)
|
||||
# sales = forms.BooleanField(required=False)
|
||||
# marketing = forms.BooleanField(required=False)
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ['email', 'first_name', 'last_name',
|
||||
'username', 'role', 'profile_pic']
|
||||
'username', 'role', 'profile_pic',
|
||||
'has_sales_access', 'has_marketing_access']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(UserForm, self).__init__(*args, **kwargs)
|
||||
|
|
@ -101,6 +105,14 @@ class UserForm(forms.ModelForm):
|
|||
'Password must be at least 4 characters long!')
|
||||
return password
|
||||
|
||||
def clean_has_sales_access(self):
|
||||
sales = self.cleaned_data.get('has_sales_access', False)
|
||||
marketing = self.data.get('has_marketing_access', False)
|
||||
if not sales and not marketing:
|
||||
raise forms.ValidationError('Select atleast one option')
|
||||
return sales
|
||||
|
||||
|
||||
def clean_email(self):
|
||||
email = self.cleaned_data.get("email")
|
||||
if self.instance.id:
|
||||
|
|
@ -170,7 +182,8 @@ class ChangePasswordForm(forms.Form):
|
|||
if self.data.get('confirm') != self.cleaned_data.get('Newpassword'):
|
||||
raise forms.ValidationError(
|
||||
'Confirm password do not match with new password')
|
||||
password_validation.validate_password(self.cleaned_data.get('Newpassword'), user=self.user)
|
||||
password_validation.validate_password(
|
||||
self.cleaned_data.get('Newpassword'), user=self.user)
|
||||
return self.data.get('confirm')
|
||||
|
||||
|
||||
|
|
|
|||
29
common/migrations/0016_auto_20190624_1816.py
Normal file
29
common/migrations/0016_auto_20190624_1816.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Generated by Django 2.2.2 on 2019-06-24 12:46
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('common', '0015_auto_20190604_1830'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='user',
|
||||
name='has_marketing_access',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='user',
|
||||
name='has_sales_access',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='comment',
|
||||
name='lead',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='leads_comments', to='leads.Lead'),
|
||||
),
|
||||
]
|
||||
|
|
@ -33,6 +33,8 @@ class User(AbstractBaseUser, PermissionsMixin):
|
|||
role = models.CharField(max_length=50, choices=ROLES)
|
||||
profile_pic = models.FileField(
|
||||
max_length=1000, upload_to=img_url, null=True, blank=True)
|
||||
has_sales_access = models.BooleanField(default=False)
|
||||
has_marketing_access = models.BooleanField(default=False)
|
||||
|
||||
USERNAME_FIELD = 'email'
|
||||
REQUIRED_FIELDS = ['username', ]
|
||||
|
|
@ -144,7 +146,7 @@ class Comment(models.Model):
|
|||
related_name='invoice_comments', on_delete=models.CASCADE)
|
||||
|
||||
event = models.ForeignKey('events.Event', blank=True, null=True,
|
||||
related_name='events_comments', on_delete=models.CASCADE)
|
||||
related_name='events_comments', on_delete=models.CASCADE)
|
||||
|
||||
def get_files(self):
|
||||
return Comment_Files.objects.filter(comment_id=self)
|
||||
|
|
@ -196,7 +198,7 @@ class Attachments(models.Model):
|
|||
invoice = models.ForeignKey('invoices.Invoice', blank=True, null=True,
|
||||
related_name='invoice_attachment', on_delete=models.CASCADE)
|
||||
event = models.ForeignKey('events.Event', blank=True, null=True,
|
||||
related_name='events_attachment', on_delete=models.CASCADE)
|
||||
related_name='events_attachment', on_delete=models.CASCADE)
|
||||
|
||||
def file_type(self):
|
||||
name_ext_list = self.attachment.url.split(".")
|
||||
|
|
@ -249,6 +251,9 @@ class Document(models.Model):
|
|||
choices=DOCUMENT_STATUS_CHOICE, max_length=64, default='active')
|
||||
shared_to = models.ManyToManyField(User, related_name='document_shared_to')
|
||||
|
||||
class Meta:
|
||||
ordering = ('-created_on',)
|
||||
|
||||
def file_type(self):
|
||||
name_ext_list = self.document_file.url.split(".")
|
||||
if (len(name_ext_list) > 1):
|
||||
|
|
@ -292,6 +297,9 @@ class APISettings(models.Model):
|
|||
on_delete=models.SET_NULL, null=True)
|
||||
created_on = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ('-created_on',)
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
|
|
@ -316,32 +324,3 @@ class Google(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return self.email
|
||||
|
||||
# # Need to be reviewed
|
||||
# class Task(models.Model):
|
||||
|
||||
# # assigned_to can be assigned to contact, oppurtunity, case
|
||||
# assigned_to = models.ManyToManyField(User, related_name='task_assigned_to')
|
||||
# status = models.CharField(max_length=50, choices=)
|
||||
# subject = models.CharField(max_length=200, default='')
|
||||
# name = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True, related_name='user_task')
|
||||
|
||||
# due_date = models.DateField(auto_now=False, auto_now_add=False)
|
||||
# # this could be choice field
|
||||
# related_to = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True, related_name='to_account')
|
||||
# # related_to = models.CharField(max_length=50, choices=)
|
||||
# priority = models.CharField(max_length=50, , choices=)
|
||||
|
||||
|
||||
# comments = models.TextField()
|
||||
# recurrence = models.BooleanField()
|
||||
|
||||
|
||||
# # optional fields
|
||||
# status = models.CharField(max_length=50, choices=)
|
||||
# # type_task = models.CharField(max_length=50)
|
||||
# # phone = models.phonenumber_field(null=True)
|
||||
# # email = models.EmailField(max_length=254)
|
||||
|
||||
# send_notification_mail = models.BooleanField(default=False)
|
||||
# reminder_field = models.DateTimeField(auto_now=False, auto_now_add=False)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
{% extends 'sales/base.html' %}
|
||||
{% load staticfiles %}
|
||||
{% block extralinks %}
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
|
||||
{% endblock %}
|
||||
{% block breadcrumb %}
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
|
|
@ -22,105 +25,166 @@
|
|||
<div class="row marl">
|
||||
<div class="filter_col col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="id_firstname">First Name{% if user_form.first_name.field.required %}<span class="error">*</span>{% endif %}</label>
|
||||
<input type="text" class="form-control" name="first_name" value="{% if user_obj %}{{ user_obj.first_name }}{% else %}{{request.POST.first_name}}{% endif %}" placeholder="First Name">
|
||||
<label for="id_firstname">First Name{% if user_form.first_name.field.required %}<span
|
||||
class="error">*</span>{% endif %}</label>
|
||||
<input type="text" class="form-control" name="first_name"
|
||||
value="{% if user_obj %}{{ user_obj.first_name }}{% else %}{{request.POST.first_name}}{% endif %}"
|
||||
placeholder="First Name">
|
||||
</div>
|
||||
<span class="error_ajax" id="id_first_name" style="color:red">{{ errors.first_name }}</span>
|
||||
</div>
|
||||
<div class="filter_col col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="id_lastname">Last Name{% if user_form.last_name.field.required %}<span class="error">*</span>{% endif %}</label>
|
||||
<input type="text" class="form-control" name="last_name" value="{% if user_obj %}{{ user_obj.last_name }}{% else %}{{request.POST.last_name}}{% endif %}" placeholder="Last Name">
|
||||
<label for="id_lastname">Last Name{% if user_form.last_name.field.required %}<span
|
||||
class="error">*</span>{% endif %}</label>
|
||||
<input type="text" class="form-control" name="last_name"
|
||||
value="{% if user_obj %}{{ user_obj.last_name }}{% else %}{{request.POST.last_name}}{% endif %}"
|
||||
placeholder="Last Name">
|
||||
</div>
|
||||
<span class="error_ajax" id="id_last_name" style="color:red">{{ errors.last_name }}</span>
|
||||
</div>
|
||||
<div class="filter_col col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="id_username">Username{% if user_form.username.field.required %}<span class="error">*</span>{% endif %}</label>
|
||||
<input type="text" class="form-control" name="username" value="{% if user_obj %}{{ user_obj.username }}{% else %}{{request.POST.username}}{% endif %}" placeholder="Username">
|
||||
<label for="id_username">Username{% if user_form.username.field.required %}<span
|
||||
class="error">*</span>{% endif %}</label>
|
||||
<input type="text" class="form-control" name="username"
|
||||
value="{% if user_obj %}{{ user_obj.username }}{% else %}{{request.POST.username}}{% endif %}"
|
||||
placeholder="Username">
|
||||
</div>
|
||||
<span class="error_ajax" id="id_username" style="color:red">{{ errors.username }}</span>
|
||||
</div>
|
||||
<div class="filter_col col-md-6" {% if user_obj %} style="display: none;" {% endif %}>
|
||||
<div class="form-group">
|
||||
<label for="id_email">Email Address{% if user_form.email.field.required %}<span class="error">*</span>{% endif %}</label>
|
||||
<input type="text" class="form-control" name="email" value="{% if user_obj %}{{ user_obj.email }}{% else %}{{request.POST.email}}{% endif %}" {% if user_obj %} readonly=""{% endif %} placeholder="Email">
|
||||
<div class="form-group">
|
||||
<label for="id_email">Email Address{% if user_form.email.field.required %}<span
|
||||
class="error">*</span>{% endif %}</label>
|
||||
<input type="text" class="form-control" name="email"
|
||||
value="{% if user_obj %}{{ user_obj.email }}{% else %}{{request.POST.email}}{% endif %}"
|
||||
{% if user_obj %} readonly="" {% endif %} placeholder="Email">
|
||||
</div>
|
||||
<span class="error_ajax" id="id_email" style="color:red">{{ errors.email }}</span>
|
||||
</div>
|
||||
<div class="filter_col col-md-6"
|
||||
{% if request.user.role != 'ADMIN' and not request.user.is_superuser or request.user.id == user_obj.id %}style="display:none;"
|
||||
{% endif %}>
|
||||
<div class="form-group">
|
||||
<label for="id_role">User Role{% if user_form.role.field.required %}<span
|
||||
class="error">*</span>{% endif %}</label>
|
||||
{% if request.user.role == 'ADMIN' or request.user.is_superuser %}
|
||||
<select name="role" class="form-control">
|
||||
{% for key, value in form.role.field.choices %}
|
||||
<option value="{{key}}" {% if value == user_obj.role %}selected="selected"
|
||||
{% elif user_obj.is_superuser and value == "ADMIN" %}selected{% endif %}>{{value}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% else %}
|
||||
<select name="role">
|
||||
<option value="{{user_obj.role}}">{{user_obj.role}}</option>
|
||||
</select>
|
||||
{% endif %}
|
||||
<span class="error_ajax" id="id_role" style="color:red">{{ user_form.role.errors }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% if not user_obj %}
|
||||
<div class="filter_col col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Password{% if user_form.password.field.required %}<span
|
||||
class="error">*</span>{% endif %}</label>
|
||||
<input type="password" class="form-control" name="password" value="{{request.POST.password}}"
|
||||
placeholder="Password">
|
||||
</div>
|
||||
<span class="error_ajax" id="id_password" style="color:red">{{ errors.password }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="filter_col col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Upload Profile Picture{% if user_form.profile_pic.field.required %}<span
|
||||
class="error">*</span>{% endif %}</label>
|
||||
<input type="file" name="profile_pic" accept="image/*" class="form-control" />
|
||||
</div>
|
||||
|
||||
{% if user_obj %}<span>{{user_profile_name }}</span>{% endif %}
|
||||
<span class="error" id="id_profile_pic">{{ errors.profile_pic }}</span>
|
||||
|
||||
</div>
|
||||
{% if request.user.is_superuser or request.user.role == 'ADMIN' %}
|
||||
<div class="filter_col col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Permissions {% if user_form.profile_pic.field.required %}<span
|
||||
class="error">*</span>{% endif %}</label>
|
||||
<br>
|
||||
<!-- {{user_form.sales}} -->
|
||||
<div class="btn-group">
|
||||
<label class="btn "> Sales
|
||||
<input type="checkbox" name="has_sales_access" id="" autocomplete="off"
|
||||
{% if user_obj.has_sales_access %} checked {% endif %}>
|
||||
</label>
|
||||
<label class="btn "> Marketing
|
||||
<input type="checkbox" name="has_marketing_access" id="" autocomplete="off"
|
||||
{% if user_obj.has_marketing_access %} checked {% endif %}>
|
||||
</label>
|
||||
</div>
|
||||
<span class="error_ajax" id="id_has_sales_access" style="color: red;"></span>
|
||||
<span class="error_ajax" id="id_has_marketing_access" style="color: red;"></span>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="filter_col col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Team {% if user_form.teams.field.required %}<span
|
||||
class="error">*</span>{% endif %}</label>
|
||||
<!-- {{user_form.teams}} -->
|
||||
<select name="teams" id="id_teams" multiple>
|
||||
{% for team in teams %}
|
||||
<option value="{{team.id}}" {% if team in user_obj.user_teams.all %} selected {% endif %}>
|
||||
{{team.name}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<span id="id_teams_error" style="color: red;"></span>
|
||||
</div>
|
||||
<span class="error_ajax" id="id_password" style="color:red">{{ errors.teams }}</span>
|
||||
</div>
|
||||
<span class="error_ajax" id="id_email" style="color:red">{{ errors.email }}</span>
|
||||
</div>
|
||||
<div class="filter_col col-md-6" {% if request.user.role != 'ADMIN' and not request.user.is_superuser or request.user.id == user_obj.id %}style="display:none;"{% endif %}>
|
||||
<div class="form-group">
|
||||
<label for="id_role">User Role{% if user_form.role.field.required %}<span class="error">*</span>{% endif %}</label>
|
||||
{% if request.user.role == 'ADMIN' or request.user.is_superuser %}
|
||||
<select name="role" class="form-control">
|
||||
{% for key, value in form.role.field.choices %}
|
||||
<option value="{{key}}" {% if value == user_obj.role %}selected="selected"{% elif user_obj.is_superuser and value == "ADMIN" %}selected{% endif %}>{{value}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
{% else %}
|
||||
<select name="role">
|
||||
<option value="{{user_obj.role}}">{{user_obj.role}}</option>
|
||||
</select>
|
||||
{% endif %}
|
||||
<span class="error_ajax" id="id_role" style="color:red">{{ user_form.role.errors }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{% if not user_obj %}
|
||||
<div class="filter_col col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Password{% if user_form.password.field.required %}<span class="error">*</span>{% endif %}</label>
|
||||
<input type="password" class="form-control" name="password" value="{{request.POST.password}}" placeholder="Password">
|
||||
</div>
|
||||
<span class="error_ajax" id="id_password" style="color:red">{{ errors.password }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="filter_col col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Upload Profile Picture{% if user_form.profile_pic.field.required %}<span class="error">*</span>{% endif %}</label>
|
||||
<input type="file" name="profile_pic" accept="image/*" class="form-control" />
|
||||
</div>
|
||||
|
||||
{% if user_obj %}<span>{{user_profile_name }}</span>{% endif %}
|
||||
<span class="error" id="id_profile_pic">{{ errors.profile_pic }}</span>
|
||||
|
||||
<p style="color:red" id="forbiden_error"></p>
|
||||
<div class="row marl buttons_row form_btn_row text-center">
|
||||
<button class="btn btn-default save" type="submit">Save</button>
|
||||
<a href="{% if not user_obj or request.user.is_superuser or request.user.role == 'ADMIN' %}{% url 'common:users_list' %}{% else %}{% url 'common:profile' %}{% endif %}"
|
||||
class="btn btn-default clear" id="create_user_cancel">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p style="color:red" id="forbiden_error"></p>
|
||||
<div class="row marl buttons_row form_btn_row text-center">
|
||||
<button class="btn btn-default save" type="submit">Save</button>
|
||||
<a href="{% if not user_obj or request.user.is_superuser or request.user.role == 'ADMIN' %}{% url 'common:users_list' %}{% else %}{% url 'common:profile' %}{% endif %}" class="btn btn-default clear" id="create_user_cancel">Cancel</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock content %}
|
||||
{% block js_block %}
|
||||
<script src="https://malsup.github.io/jquery.form.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$("#id_teams").select2();
|
||||
$('form#add_form').ajaxForm({
|
||||
type:'POST',
|
||||
dataType:'json',
|
||||
url: ".",
|
||||
data:$('#add_form').serialize(),
|
||||
success: function(data) {
|
||||
if(data.error){
|
||||
if(data.error_403){
|
||||
$("#forbiden_error").text(" *You Don't have permission to edit this user ");
|
||||
}
|
||||
if(data.errors){
|
||||
$('.error_ajax').html('')
|
||||
for (var key in data.errors) {
|
||||
$('#id_'+key).html("<p>" + data.errors[key][0] + "</p>");
|
||||
};
|
||||
}
|
||||
}
|
||||
else{
|
||||
window.location = data.success_url;
|
||||
}
|
||||
}
|
||||
});
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
url: ".",
|
||||
data: $('#add_form').serialize(),
|
||||
success: function (data) {
|
||||
if (data.error) {
|
||||
if (data.error_403) {
|
||||
$("#forbiden_error").text(" *You Don't have permission to edit this user ");
|
||||
}
|
||||
if (data.errors) {
|
||||
$('.error_ajax').html('')
|
||||
for (var key in data.errors) {
|
||||
$('#id_' + key).html("<p>" + data.errors[key][0] + "</p>");
|
||||
$('#id_' + key + '_error').html("<p style='colors:red;'>" + data.errors[key][0] + "</p>");
|
||||
};
|
||||
}
|
||||
}
|
||||
else {
|
||||
window.location = data.success_url;
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock js_block %}
|
||||
|
||||
{% endblock js_block %}
|
||||
|
|
@ -99,12 +99,16 @@
|
|||
<td scope="row">{{ forloop.counter }}</td>
|
||||
<td>{% if document.title %}<a href="{% url 'common:view_doc' document.id %}">{{ document.title }}</a>{% endif %}</td>
|
||||
<td>
|
||||
{% if document.created_by %}
|
||||
{% if document.created_by.profile_pic %}
|
||||
{% thumbnail document.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" title="{{ document.created_by }}">
|
||||
{% endthumbnail %}
|
||||
{% thumbnail document.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" title="{{ document.created_by }}">
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}" title="{{ document.created_by }}" width="40" height="40">
|
||||
<img src="{% static 'images/user.png' %}" title="{{ document.created_by }}" width="40" height="40">
|
||||
{% endif %}
|
||||
{% else %}
|
||||
None
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{document.created_on}}</td>
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@
|
|||
<th width="20%">Username</th>
|
||||
<th width="20%">Email Address</th>
|
||||
<th width="8%">User Role</th>
|
||||
<th width="8%">Permissions</th>
|
||||
<th width="15%">Status</th>
|
||||
<th width="20%">Actions</th>
|
||||
</tr>
|
||||
|
|
@ -140,6 +141,20 @@
|
|||
<td>{{ user.email }}</td>
|
||||
<td class="user_role">{% if user.is_superuser %} Admin {% else %} {{user.role}} {% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if user.is_superuser or user.role == 'ADMIN' %}
|
||||
Sales, Marketing
|
||||
{% endif %}
|
||||
{% if user.has_sales_access and user.has_marketing_access %}
|
||||
Sales, Marketing
|
||||
{% elif user.has_sales_access and not user.has_marketing_access %}
|
||||
Sales
|
||||
{% elif not user.has_sales_access and user.has_marketing_access %}
|
||||
Marketing
|
||||
{% else %}
|
||||
{{''}}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% ifnotequal request.user user %}
|
||||
<a {% if user.is_active %}
|
||||
|
|
|
|||
293
common/tests.py
293
common/tests.py
|
|
@ -21,12 +21,12 @@ class ObjectsCreation(object):
|
|||
# is_superuser=True, is_active=True)
|
||||
|
||||
self.user_admin = User.objects.create(first_name="admin",
|
||||
username='admin',
|
||||
email='admin@micropyramid.com',
|
||||
is_staff=True,
|
||||
is_admin=True,
|
||||
is_superuser=True,
|
||||
is_active=True, role='ADMIN')
|
||||
username='admin',
|
||||
email='admin@micropyramid.com',
|
||||
is_staff=True,
|
||||
is_admin=True,
|
||||
is_superuser=True,
|
||||
is_active=True, role='ADMIN')
|
||||
|
||||
self.user_admin.set_password('admin123')
|
||||
self.user_admin.save()
|
||||
|
|
@ -41,7 +41,8 @@ class ObjectsCreation(object):
|
|||
first_name="mp",
|
||||
username='mp',
|
||||
email='mp@micropyramid.com',
|
||||
role="USER")
|
||||
role="USER",
|
||||
has_sales_access=True)
|
||||
self.user1.set_password('mp')
|
||||
self.user1.save()
|
||||
# self.user
|
||||
|
|
@ -59,7 +60,8 @@ class ObjectsCreation(object):
|
|||
first_name="mp2",
|
||||
username='mp2',
|
||||
email='mp2@micropyramid.com',
|
||||
role="USER")
|
||||
role="USER",
|
||||
has_sales_access=True)
|
||||
self.user2.set_password('mp')
|
||||
self.user2.save()
|
||||
|
||||
|
|
@ -108,7 +110,7 @@ class UserCreateTestCase(ObjectsCreation, TestCase):
|
|||
'first_name': '',
|
||||
'last_name': '',
|
||||
'username': '',
|
||||
'role': 'ADMIN',})
|
||||
'role': 'ADMIN', })
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
|
|
@ -441,34 +443,39 @@ class TestChangeUserStatus(ObjectsCreation, TestCase):
|
|||
|
||||
def test_change_user_status(self):
|
||||
response = self.client.get(reverse('common:change_user_status',
|
||||
args=(self.user2.id,)))
|
||||
args=(self.user2.id,)))
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
|
||||
class TestDocumentListViewUser(ObjectsCreation, TestCase):
|
||||
|
||||
def test_document_list_view_user(self):
|
||||
response = self.client.get(reverse('common:doc_list'))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class TestViewApiSettings(ObjectsCreation, TestCase):
|
||||
|
||||
def test_view_api_settings(self):
|
||||
|
||||
self.api_settings = APISettings.objects.create(title='api key',
|
||||
apikey='a45fds54fds54',
|
||||
website='https://micropyramid.com')
|
||||
apikey='a45fds54fds54',
|
||||
website='https://micropyramid.com')
|
||||
|
||||
response = self.client.get(reverse('common:api_settings'))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
response = self.client.get(reverse('common:view_api_settings',args=(self.api_settings.id,)))
|
||||
response = self.client.get(
|
||||
reverse('common:view_api_settings', args=(self.api_settings.id,)))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class TestDocumentDetailViewPermissionDenied(ObjectsCreation, TestCase):
|
||||
|
||||
def test_document_detail_view_permission(self):
|
||||
self.client.login(username='mp2@micropyramid.com', password='mp')
|
||||
response = self.client.get(reverse('common:view_doc', args=(self.document.id,)))
|
||||
response = self.client.get(
|
||||
reverse('common:view_doc', args=(self.document.id,)))
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
|
||||
|
|
@ -476,7 +483,7 @@ class TestChangePasswordByAdmin(ObjectsCreation, TestCase):
|
|||
|
||||
def test_change_password_by_admin(self):
|
||||
response = self.client.post(reverse('common:change_passsword_by_admin'),
|
||||
{'useer_id':self.user2.id,'new_passwoord':'new password'})
|
||||
{'useer_id': self.user2.id, 'new_passwoord': 'new password'})
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
|
||||
|
|
@ -485,20 +492,22 @@ class TestChangePasswordByAdminPermission(ObjectsCreation, TestCase):
|
|||
def test_change_password_by_admin_permission(self):
|
||||
self.client.login(username='mp2@micropyramid.com', password='mp')
|
||||
response = self.client.post(reverse('common:change_passsword_by_admin'),
|
||||
{'useer_id':self.user2.id,'new_passwoord':'new password'})
|
||||
{'useer_id': self.user2.id, 'new_passwoord': 'new password'})
|
||||
self.assertEqual(response.status_code, 403)
|
||||
self.client.logout()
|
||||
|
||||
|
||||
class TestDocumentCreateForm(ObjectsCreation, TestCase):
|
||||
|
||||
def test_document_create_form(self):
|
||||
upload_file = open('static/images/user.png', 'rb')
|
||||
response = self.client.post(reverse('common:create_doc'),
|
||||
{'title': 'doc',
|
||||
'document_file': SimpleUploadedFile(upload_file.name, upload_file.read()),
|
||||
'shared_to':str(self.user1.id)})
|
||||
{'title': 'doc',
|
||||
'document_file': SimpleUploadedFile(upload_file.name, upload_file.read()),
|
||||
'shared_to': str(self.user1.id)})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class TestCommentDelete(ObjectsCreation, TestCase):
|
||||
|
||||
def test_comment_delete_form(self):
|
||||
|
|
@ -519,10 +528,11 @@ class TestCommentDelete(ObjectsCreation, TestCase):
|
|||
description="Iam an Lead",
|
||||
created_by=self.user_admin)
|
||||
self.comment_user = Comment.objects.create(comment='comment 1',
|
||||
commented_by=self.user_admin,lead=self.lead)
|
||||
commented_by=self.user_admin, lead=self.lead)
|
||||
response = self.client.post(reverse('common:remove_comment'),
|
||||
{'comment_id':self.comment_user.id })
|
||||
self.assertJSONEqual(force_text(response.content), {"cid": str(self.comment_user.id)})
|
||||
{'comment_id': self.comment_user.id})
|
||||
self.assertJSONEqual(force_text(response.content), {
|
||||
"cid": str(self.comment_user.id)})
|
||||
|
||||
|
||||
class TestCommentEditErrors(ObjectsCreation, TestCase):
|
||||
|
|
@ -545,15 +555,17 @@ class TestCommentEditErrors(ObjectsCreation, TestCase):
|
|||
description="Iam an Lead",
|
||||
created_by=self.user_admin)
|
||||
self.comment_user = Comment.objects.create(comment='comment 1',
|
||||
commented_by=self.user_admin,lead=self.lead)
|
||||
commented_by=self.user_admin, lead=self.lead)
|
||||
response = self.client.post(reverse('common:edit_comment', args=(self.comment_user.id,)),
|
||||
{'pk':self.comment_user.id, 'comment':''})
|
||||
self.assertJSONEqual(force_text(response.content), {"error": ['This field is required.']})
|
||||
{'pk': self.comment_user.id, 'comment': ''})
|
||||
self.assertJSONEqual(force_text(response.content), {
|
||||
"error": ['This field is required.']})
|
||||
|
||||
response = self.client.post(reverse('common:edit_comment', args=(self.comment_user.id,)),
|
||||
{'pk':self.comment_user.id, 'comment':'asdf'})
|
||||
{'pk': self.comment_user.id, 'comment': 'asdf'})
|
||||
|
||||
self.assertJSONEqual(force_text(response.content), {"comment_id":self.comment_user.id, "comment": 'asdf'})
|
||||
self.assertJSONEqual(force_text(response.content), {
|
||||
"comment_id": self.comment_user.id, "comment": 'asdf'})
|
||||
|
||||
|
||||
class TestDocumentListUser(ObjectsCreation, TestCase):
|
||||
|
|
@ -568,38 +580,43 @@ class TestDocumentDelete(ObjectsCreation, TestCase):
|
|||
|
||||
def test_document_delete(self):
|
||||
self.client.login(username='mp2@micropyramid.com', password='mp')
|
||||
response = self.client.get(reverse('common:remove_doc', args=(self.document.id,)))
|
||||
response = self.client.get(
|
||||
reverse('common:remove_doc', args=(self.document.id,)))
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
|
||||
class TestDocumentUpdate(ObjectsCreation, TestCase):
|
||||
|
||||
def test_document_update(self):
|
||||
response = self.client.get(reverse('common:edit_doc', args=(self.document.id,)), {'title':"abc"})
|
||||
response = self.client.get(
|
||||
reverse('common:edit_doc', args=(self.document.id,)), {'title': "abc"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
class TestUserUpdate(ObjectsCreation, TestCase):
|
||||
|
||||
def test_user_update(self):
|
||||
response = self.client.post(reverse('common:edit_user', args=(self.user2.id,)), {})
|
||||
response = self.client.post(
|
||||
reverse('common:edit_user', args=(self.user2.id,)), {})
|
||||
self.assertTrue('error' in str(response.content))
|
||||
response = self.client.post(reverse('common:edit_user', args=(self.user2.id,)), {
|
||||
'first_name':'mp2',
|
||||
'last_name':'mp22',
|
||||
'username':'mp2',
|
||||
'role':'USER',
|
||||
'email':'mp2@micropyramid.com'
|
||||
'first_name': 'mp2',
|
||||
'last_name': 'mp22',
|
||||
'username': 'mp2',
|
||||
'role': 'USER',
|
||||
'email': 'mp2@micropyramid.com',
|
||||
'has_sales_access': 'true'
|
||||
}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertEqual(force_text(response.content), json.dumps(
|
||||
{'success_url': reverse('common:users_list'), 'error': False}))
|
||||
|
||||
response = self.client.post(reverse('common:edit_user', args=(self.user2.id,)), {},
|
||||
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertJSONEqual(force_text(response.content),
|
||||
json.dumps({"error": True, "errors": {"email": ["This field is required."],
|
||||
"first_name": ["This field is required."], "username": ["This field is required."],
|
||||
"role": ["This field is required."]}}))
|
||||
|
||||
json.dumps({"error": True, "errors": {"email": ["This field is required."],
|
||||
"first_name": ["This field is required."], "username": ["This field is required."],
|
||||
"role": ["This field is required."],
|
||||
'has_sales_access': ['Select atleast one option']}}))
|
||||
|
||||
def test_user_update_permissions(self):
|
||||
self.user_obj = User.objects.create(
|
||||
|
|
@ -611,37 +628,44 @@ class TestUserUpdate(ObjectsCreation, TestCase):
|
|||
self.user_obj.save()
|
||||
self.client.login(username='mp2@micropyramid.com', password='mp')
|
||||
response = self.client.post(reverse('common:edit_user', args=(self.user_obj.id,)), {
|
||||
'first_name':'mp2',
|
||||
'last_name':'mp22',
|
||||
'username':'mp222',
|
||||
'role':'USER',
|
||||
'email':'mp2@mssicropyramid.com'},
|
||||
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertJSONEqual(force_text(response.content), json.dumps({"error_403": True, "error": True}))
|
||||
|
||||
response = self.client.post(reverse('common:edit_user', args=(self.user2.id,)), {
|
||||
'first_name':'mp2',
|
||||
'last_name':'mp22',
|
||||
'username':'mp2',
|
||||
'role':'USER',
|
||||
'email':'mp2@micropyramid.com'},
|
||||
'first_name': 'mp2',
|
||||
'last_name': 'mp22',
|
||||
'username': 'mp222',
|
||||
'role': 'USER',
|
||||
'email': 'mp2@mssicropyramid.com',
|
||||
'has_sales_access': 'true'},
|
||||
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertJSONEqual(force_text(response.content),
|
||||
json.dumps({'success_url': reverse('common:profile'), 'error': False}))
|
||||
json.dumps({"error_403": True, "error": True}))
|
||||
|
||||
response = self.client.post(reverse('common:edit_user', args=(self.user2.id,)), {
|
||||
'first_name': 'mp2',
|
||||
'last_name': 'mp22',
|
||||
'username': 'mp2',
|
||||
'role': 'USER',
|
||||
'email': 'mp2@micropyramid.com',
|
||||
'has_sales_access': 'true'},
|
||||
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertJSONEqual(force_text(response.content),
|
||||
json.dumps({'success_url': reverse('common:profile'), 'error': False}))
|
||||
|
||||
|
||||
class TestAPISettingsDelete(ObjectsCreation, TestCase):
|
||||
|
||||
def test_api_settings_delete(self):
|
||||
self.api_settings = APISettings.objects.create(title='api key',
|
||||
apikey='a45fds54fds54',
|
||||
website='https://micropyramid.com')
|
||||
apikey='a45fds54fds54',
|
||||
website='https://micropyramid.com')
|
||||
|
||||
response = self.client.get(reverse('common:delete_api_settings',args=(self.api_settings.id,)))
|
||||
response = self.client.get(
|
||||
reverse('common:delete_api_settings', args=(self.api_settings.id,)))
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
response = self.client.get(reverse('common:delete_api_settings',args=(self.api_settings.id,)))
|
||||
response = self.client.get(
|
||||
reverse('common:delete_api_settings', args=(self.api_settings.id,)))
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
|
||||
class TestGetFullNameModel(ObjectsCreation, TestCase):
|
||||
|
||||
def test_get_full_name(self):
|
||||
|
|
@ -675,100 +699,116 @@ class TestGetFullNameModel(ObjectsCreation, TestCase):
|
|||
self.document_code = Document.objects.create(
|
||||
title="code_file", document_file="doc.py", created_by=self.user)
|
||||
|
||||
self.assertEqual(("text", "fa fa-file-alt"), self.document_txt.file_type())
|
||||
self.assertEqual(("sheet", "fa fa-file-excel"), self.document_csv.file_type())
|
||||
self.assertEqual(("zip", "fa fa-file-archive"), self.document_zip.file_type())
|
||||
self.assertEqual(("pdf", "fa fa-file-pdf"), self.document_pdf.file_type())
|
||||
self.assertEqual(("file", "fa fa-file"), self.document_other_format.file_type())
|
||||
self.assertEqual(("image", "fa fa-file-image"), self.document_image.file_type())
|
||||
self.assertEqual(("video", "fa fa-file-video"), self.document_video.file_type())
|
||||
self.assertEqual(("audio", "fa fa-file-audio"), self.document_audio.file_type())
|
||||
self.assertEqual(("code", "fa fa-file-code"), self.document_code.file_type())
|
||||
self.assertEqual(("text", "fa fa-file-alt"),
|
||||
self.document_txt.file_type())
|
||||
self.assertEqual(("sheet", "fa fa-file-excel"),
|
||||
self.document_csv.file_type())
|
||||
self.assertEqual(("zip", "fa fa-file-archive"),
|
||||
self.document_zip.file_type())
|
||||
self.assertEqual(("pdf", "fa fa-file-pdf"),
|
||||
self.document_pdf.file_type())
|
||||
self.assertEqual(("file", "fa fa-file"),
|
||||
self.document_other_format.file_type())
|
||||
self.assertEqual(("image", "fa fa-file-image"),
|
||||
self.document_image.file_type())
|
||||
self.assertEqual(("video", "fa fa-file-video"),
|
||||
self.document_video.file_type())
|
||||
self.assertEqual(("audio", "fa fa-file-audio"),
|
||||
self.document_audio.file_type())
|
||||
self.assertEqual(("code", "fa fa-file-code"),
|
||||
self.document_code.file_type())
|
||||
|
||||
|
||||
class TestUserCreationView(ObjectsCreation, TestCase):
|
||||
|
||||
def test_user_creation_view(self):
|
||||
response = self.client.post(reverse('common:create_user'),{},
|
||||
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
response = self.client.post(reverse('common:create_user'), {},
|
||||
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertEqual(force_text(response.content),
|
||||
json.dumps({"error": True, "errors": {"email": ["This field is required."], "first_name": ["This field is required."], "username": ["This field is required."], "role": ["This field is required."], "password": ["This field is required."]}}))
|
||||
json.dumps({"error": True, "errors": {"email": ["This field is required."],
|
||||
"first_name": ["This field is required."],
|
||||
"username": ["This field is required."],
|
||||
"role": ["This field is required."],
|
||||
"has_sales_access": ["Select atleast one option"],
|
||||
"password": ["This field is required."]}}))
|
||||
|
||||
response = self.client.post(reverse('common:create_user'),{
|
||||
'email':'user@create.com',
|
||||
'first_name':'first name?',
|
||||
'username':'joe',
|
||||
'role':'USER',
|
||||
'password':'testpassword'
|
||||
},HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertEqual(force_text(response.content), json.dumps({"success_url": "/users/list/", "error": False}))
|
||||
response=self.client.post(reverse('common:create_user'), {
|
||||
'email': 'user@create.com',
|
||||
'first_name': 'first name?',
|
||||
'username': 'joe',
|
||||
'role': 'USER',
|
||||
'password': 'testpassword',
|
||||
'has_sales_access':'true',
|
||||
}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
|
||||
self.assertEqual(force_text(response.content), json.dumps(
|
||||
{"success_url": "/users/list/", "error": False}))
|
||||
|
||||
def test_add_api_settings(self):
|
||||
response = self.client.post(reverse('common:add_api_settings'), {})
|
||||
response=self.client.post(reverse('common:add_api_settings'), {})
|
||||
self.assertTrue('error' in str(response.content))
|
||||
response = self.client.post(reverse('common:add_api_settings'), {
|
||||
'title':'api title','lead_assigned_to':str(self.user2.id),'website':'https://micropyramid.com',
|
||||
'tags':'api_tag, tag1'
|
||||
response=self.client.post(reverse('common:add_api_settings'), {
|
||||
'title': 'api title', 'lead_assigned_to': str(self.user2.id), 'website': 'https://micropyramid.com',
|
||||
'tags': 'api_tag, tag1'
|
||||
})
|
||||
self.assertJSONEqual(force_text(response.content),
|
||||
json.dumps({'success_url': reverse("common:api_settings"), 'error': False}))
|
||||
json.dumps({'success_url': reverse("common:api_settings"), 'error': False}))
|
||||
|
||||
response = self.client.post(reverse('common:add_api_settings'), {
|
||||
'title':'api title','lead_assigned_to':str(self.user2.id),'website':'https://micropyramid.com',
|
||||
'tags':'api_tag, tag1', 'savenewform':'true'
|
||||
response=self.client.post(reverse('common:add_api_settings'), {
|
||||
'title': 'api title', 'lead_assigned_to': str(self.user2.id), 'website': 'https://micropyramid.com',
|
||||
'tags': 'api_tag, tag1', 'savenewform': 'true'
|
||||
})
|
||||
self.assertJSONEqual(force_text(response.content),
|
||||
json.dumps({'success_url': reverse("common:add_api_settings"), 'error': False}))
|
||||
json.dumps({'success_url': reverse("common:add_api_settings"), 'error': False}))
|
||||
|
||||
response = self.client.post(reverse('common:add_api_settings'), {
|
||||
'title':'','lead_assigned_to':str(self.user2.id),'website':'micropyramid.com',
|
||||
'tags':'api_tag, tag1', 'savenewform':'true'
|
||||
response=self.client.post(reverse('common:add_api_settings'), {
|
||||
'title': '', 'lead_assigned_to': str(self.user2.id), 'website': 'micropyramid.com',
|
||||
'tags': 'api_tag, tag1', 'savenewform': 'true'
|
||||
})
|
||||
self.assertJSONEqual(force_text(response.content),
|
||||
json.dumps({"error": True, "errors": {"title": ["This field is required."], "website": ["Please provide valid schema"]}}))
|
||||
|
||||
json.dumps({"error": True, "errors": {"title": ["This field is required."], "website": ["Please provide valid schema"]}}))
|
||||
|
||||
def test_update_api_settings(self):
|
||||
self.api_settings_update = APISettings.objects.create(title='api key update',
|
||||
apikey='asdfasd',
|
||||
website='https://example.com')
|
||||
response = self.client.post(reverse('common:update_api_settings', args=(self.api_settings_update.id,)), {})
|
||||
self.api_settings_update=APISettings.objects.create(title='api key update',
|
||||
apikey='asdfasd',
|
||||
website='https://example.com')
|
||||
response=self.client.post(
|
||||
reverse('common:update_api_settings', args=(self.api_settings_update.id,)), {})
|
||||
self.assertTrue('error' in str(response.content))
|
||||
response = self.client.post(reverse('common:update_api_settings', args=(self.api_settings_update.id,)), {
|
||||
'title':'api key update',
|
||||
'apikey':'asdfasd',
|
||||
'website':'http://example.com',
|
||||
'lead_assigned_to':str(self.user2.id),
|
||||
'tags':'api_tag_new, tag1'
|
||||
response=self.client.post(reverse('common:update_api_settings', args=(self.api_settings_update.id,)), {
|
||||
'title': 'api key update',
|
||||
'apikey': 'asdfasd',
|
||||
'website': 'http://example.com',
|
||||
'lead_assigned_to': str(self.user2.id),
|
||||
'tags': 'api_tag_new, tag1'
|
||||
})
|
||||
|
||||
response = self.client.post(reverse('common:update_api_settings', args=(self.api_settings_update.id,)), {
|
||||
'title':'api title','lead_assigned_to':str(self.user2.id),'website':'https://micropyramid.com',
|
||||
'tags':'api_tag, tag1', 'savenewform':'true'
|
||||
response=self.client.post(reverse('common:update_api_settings', args=(self.api_settings_update.id,)), {
|
||||
'title': 'api title', 'lead_assigned_to': str(self.user2.id), 'website': 'https://micropyramid.com',
|
||||
'tags': 'api_tag, tag1', 'savenewform': 'true'
|
||||
})
|
||||
self.assertJSONEqual(force_text(response.content),
|
||||
json.dumps({'success_url': reverse("common:add_api_settings"), 'error': False}))
|
||||
json.dumps({'success_url': reverse("common:add_api_settings"), 'error': False}))
|
||||
|
||||
response = self.client.post(reverse('common:update_api_settings', args=(self.api_settings_update.id,)), {
|
||||
'title':'','lead_assigned_to':str(self.user2.id),'website':'micropyramid.com',
|
||||
'tags':'api_tag, tag1', 'savenewform':'true'
|
||||
response=self.client.post(reverse('common:update_api_settings', args=(self.api_settings_update.id,)), {
|
||||
'title': '', 'lead_assigned_to': str(self.user2.id), 'website': 'micropyramid.com',
|
||||
'tags': 'api_tag, tag1', 'savenewform': 'true'
|
||||
})
|
||||
self.assertJSONEqual(force_text(response.content),
|
||||
json.dumps({"error": True, "errors": {"title": ["This field is required."], "website": ["Please provide valid schema"]}}))
|
||||
|
||||
json.dumps({"error": True, "errors": {"title": ["This field is required."], "website": ["Please provide valid schema"]}}))
|
||||
|
||||
def test_document_list_user_view(self):
|
||||
self.client.login(username='mp2@micropyramid.com', password='mp')
|
||||
self.document = Document.objects.create(
|
||||
self.document=Document.objects.create(
|
||||
title="user 2 doc", document_file="1.png", created_by=self.user2)
|
||||
self.document.shared_to.add(self.user2.id)
|
||||
response = self.client.get(reverse('common:doc_list'))
|
||||
response=self.client.get(reverse('common:doc_list'))
|
||||
self.assertEqual(200, response.status_code)
|
||||
|
||||
upload_file = open('static/images/user.png', 'rb')
|
||||
response = self.client.post(reverse('common:edit_doc', args=(self.document.id,)), {
|
||||
'title':'user 2 doc',
|
||||
'document_file':SimpleUploadedFile(upload_file.name, upload_file.read()),
|
||||
'shared_to':str(self.user2.id)
|
||||
upload_file=open('static/images/user.png', 'rb')
|
||||
response=self.client.post(reverse('common:edit_doc', args=(self.document.id,)), {
|
||||
'title': 'user 2 doc',
|
||||
'document_file': SimpleUploadedFile(upload_file.name, upload_file.read()),
|
||||
'shared_to': str(self.user2.id)
|
||||
})
|
||||
self.assertEqual(200, response.status_code)
|
||||
# self.assertEqual(force_text(response.content),
|
||||
|
|
@ -777,17 +817,19 @@ class TestUserCreationView(ObjectsCreation, TestCase):
|
|||
# response = self.client.get(reverse('common:download_document', args=(self.document.id,)))
|
||||
# self.assertEqual(200, response.status_code)
|
||||
|
||||
self.attachment = Attachments.objects.create(
|
||||
self.attachment=Attachments.objects.create(
|
||||
attachment=SimpleUploadedFile(upload_file.name, upload_file.read()), created_by=self.user)
|
||||
response = self.client.get(reverse('common:download_attachment', kwargs=({'pk':self.attachment.id})))
|
||||
response=self.client.get(
|
||||
reverse('common:download_attachment', kwargs=({'pk': self.attachment.id})))
|
||||
|
||||
def test_document_update(self):
|
||||
self.client.login(username='mp@micropyramid.com', password='mp')
|
||||
response = self.client.get(reverse('common:download_document', args=(self.document.id,)))
|
||||
response=self.client.get(
|
||||
reverse('common:download_document', args=(self.document.id,)))
|
||||
self.assertEqual(403, response.status_code)
|
||||
|
||||
def test_user_status(self):
|
||||
self.user_status = User.objects.create(
|
||||
self.user_status=User.objects.create(
|
||||
first_name="mpus",
|
||||
username='mpus',
|
||||
email='mpus@micropyramid.com',
|
||||
|
|
@ -796,5 +838,6 @@ class TestUserCreationView(ObjectsCreation, TestCase):
|
|||
)
|
||||
self.user_status.set_password('mp')
|
||||
self.user_status.save()
|
||||
response = self.client.get(reverse('common:change_user_status', kwargs={'pk': self.user_status.id}))
|
||||
self.assertEqual(302, response.status_code)
|
||||
response=self.client.get(
|
||||
reverse('common:change_user_status', kwargs={'pk': self.user_status.id}))
|
||||
self.assertEqual(302, response.status_code)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ from common.forms import (
|
|||
APISettingsForm
|
||||
)
|
||||
from django.contrib.auth.views import PasswordResetView
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.urls import reverse_lazy, reverse
|
||||
from django.conf import settings
|
||||
|
|
@ -39,6 +40,9 @@ import botocore
|
|||
|
||||
from common.utils import ROLES
|
||||
from common.tasks import send_email_user_status, send_email_user_delete, send_email_to_new_user
|
||||
from teams.models import Teams
|
||||
from common.access_decorators_mixins import (
|
||||
sales_access_required, marketing_access_required, SalesAccessRequiredMixin, MarketingAccessRequiredMixin)
|
||||
|
||||
|
||||
def handler404(request, exception):
|
||||
|
|
@ -62,7 +66,7 @@ class AdminRequiredMixin(AccessMixin):
|
|||
request, *args, **kwargs)
|
||||
|
||||
|
||||
class HomeView(LoginRequiredMixin, TemplateView):
|
||||
class HomeView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateView):
|
||||
template_name = "sales/index.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
|
@ -257,6 +261,10 @@ class CreateUserView(AdminRequiredMixin, CreateView):
|
|||
user.set_password(form.cleaned_data.get("password"))
|
||||
user.save()
|
||||
|
||||
if self.request.POST.getlist('teams'):
|
||||
for team in self.request.POST.getlist('teams'):
|
||||
Teams.objects.filter(id=team).first().users.add(user)
|
||||
|
||||
current_site = self.request.get_host()
|
||||
protocol = self.request.scheme
|
||||
send_email_to_new_user.delay(user.email, self.request.user.email,
|
||||
|
|
@ -286,6 +294,7 @@ class CreateUserView(AdminRequiredMixin, CreateView):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = super(CreateUserView, self).get_context_data(**kwargs)
|
||||
context["user_form"] = context["form"]
|
||||
context["teams"] = Teams.objects.all()
|
||||
if "errors" in kwargs:
|
||||
context["errors"] = kwargs["errors"]
|
||||
return context
|
||||
|
|
@ -334,6 +343,17 @@ class UpdateUserView(LoginRequiredMixin, UpdateView):
|
|||
if user.role == "USER":
|
||||
user.is_superuser = False
|
||||
user.save()
|
||||
|
||||
if self.request.POST.getlist('teams'):
|
||||
user_teams = user.user_teams.all()
|
||||
# this is for removing the user from previous team
|
||||
for user_team in user_teams:
|
||||
user_team.users.remove(user)
|
||||
# this is for assigning the user to new team
|
||||
for team in self.request.POST.getlist('teams'):
|
||||
team_obj = Teams.objects.filter(id=team).first()
|
||||
team_obj.users.add(user)
|
||||
|
||||
if (self.request.user.role == "ADMIN" and
|
||||
self.request.user.is_superuser):
|
||||
if self.request.is_ajax():
|
||||
|
|
@ -359,6 +379,7 @@ class UpdateUserView(LoginRequiredMixin, UpdateView):
|
|||
user_profile_name = user_profile_name[-1]
|
||||
context["user_profile_name"] = user_profile_name
|
||||
context["user_form"] = context["form"]
|
||||
context["teams"] = Teams.objects.all()
|
||||
if "errors" in kwargs:
|
||||
context["errors"] = kwargs["errors"]
|
||||
return context
|
||||
|
|
@ -382,6 +403,8 @@ class PasswordResetView(PasswordResetView):
|
|||
email_template_name = 'registration/password_reset_email.html'
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def document_create(request):
|
||||
template_name = "doc_create.html"
|
||||
users = []
|
||||
|
|
@ -413,7 +436,7 @@ def document_create(request):
|
|||
return render(request, template_name, context)
|
||||
|
||||
|
||||
class DocumentListView(LoginRequiredMixin, TemplateView):
|
||||
class DocumentListView(SalesAccessRequiredMixin,LoginRequiredMixin, TemplateView):
|
||||
model = Document
|
||||
context_object_name = "documents"
|
||||
template_name = "doc_list.html"
|
||||
|
|
@ -486,7 +509,8 @@ class DocumentDeleteView(LoginRequiredMixin, DeleteView):
|
|||
self.object.delete()
|
||||
return redirect("common:doc_list")
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def document_update(request, pk):
|
||||
template_name = "doc_create.html"
|
||||
users = []
|
||||
|
|
@ -526,7 +550,7 @@ def document_update(request, pk):
|
|||
return render(request, template_name, context)
|
||||
|
||||
|
||||
class DocumentDetailView(LoginRequiredMixin, DetailView):
|
||||
class DocumentDetailView(SalesAccessRequiredMixin, LoginRequiredMixin, DetailView):
|
||||
model = Document
|
||||
template_name = "doc_detail.html"
|
||||
|
||||
|
|
@ -866,7 +890,8 @@ def google_login(request):
|
|||
email=email,
|
||||
first_name=first_name,
|
||||
last_name=last_name,
|
||||
role="USER"
|
||||
role="USER",
|
||||
has_sales_access=True
|
||||
)
|
||||
|
||||
google, _ = Google.objects.get_or_create(user=user)
|
||||
|
|
@ -911,10 +936,12 @@ def create_lead_from_site(request):
|
|||
lead = Lead.objects.create(title=request.POST.get('full_name'), email=request.POST.get(
|
||||
'email'), phone=request.POST.get('phone'), description=request.POST.get('message'),
|
||||
created_from_site=True)
|
||||
recipients = User.objects.filter(role='ADMIN').values_list('id', flat=True)
|
||||
recipients = User.objects.filter(
|
||||
role='ADMIN').values_list('id', flat=True)
|
||||
lead.assigned_to.add(*recipients)
|
||||
from leads.tasks import send_email_to_assigned_user
|
||||
send_email_to_assigned_user(recipients, lead.id, domain='sales.micropyramid.com')
|
||||
send_email_to_assigned_user(
|
||||
recipients, lead.id, domain='sales.micropyramid.com')
|
||||
return HttpResponse('Lead Created')
|
||||
from django.http import HttpResponseBadRequest
|
||||
return HttpResponseBadRequest('Bad Request')
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"> <a href="{% url 'contacts:list' %}">Contacts</a></li>
|
||||
<li class="breadcrumb-item active">view</li>
|
||||
<li class="breadcrumb-item active">{{contact_record.first_name}} {{contact_record.last_name}}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,11 @@ from django.core.exceptions import PermissionDenied
|
|||
from django.db.models import Q
|
||||
from common.tasks import send_email_user_mentions
|
||||
from contacts.tasks import send_email_to_assigned_user
|
||||
from common.access_decorators_mixins import (
|
||||
sales_access_required, marketing_access_required, SalesAccessRequiredMixin, MarketingAccessRequiredMixin)
|
||||
|
||||
|
||||
class ContactsListView(LoginRequiredMixin, TemplateView):
|
||||
class ContactsListView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateView):
|
||||
model = Contact
|
||||
context_object_name = "contact_obj_list"
|
||||
template_name = "contacts.html"
|
||||
|
|
@ -78,7 +80,7 @@ class ContactsListView(LoginRequiredMixin, TemplateView):
|
|||
return self.render_to_response(context)
|
||||
|
||||
|
||||
class CreateContactView(LoginRequiredMixin, CreateView):
|
||||
class CreateContactView(SalesAccessRequiredMixin, LoginRequiredMixin, CreateView):
|
||||
model = Contact
|
||||
form_class = ContactForm
|
||||
template_name = "create_contact.html"
|
||||
|
|
@ -185,7 +187,7 @@ class CreateContactView(LoginRequiredMixin, CreateView):
|
|||
return context
|
||||
|
||||
|
||||
class ContactDetailView(LoginRequiredMixin, DetailView):
|
||||
class ContactDetailView(SalesAccessRequiredMixin, LoginRequiredMixin, DetailView):
|
||||
model = Contact
|
||||
context_object_name = "contact_record"
|
||||
template_name = "view_contact.html"
|
||||
|
|
@ -229,7 +231,7 @@ class ContactDetailView(LoginRequiredMixin, DetailView):
|
|||
return context
|
||||
|
||||
|
||||
class UpdateContactView(LoginRequiredMixin, UpdateView):
|
||||
class UpdateContactView(SalesAccessRequiredMixin, LoginRequiredMixin, UpdateView):
|
||||
model = Contact
|
||||
form_class = ContactForm
|
||||
template_name = "create_contact.html"
|
||||
|
|
@ -357,7 +359,7 @@ class UpdateContactView(LoginRequiredMixin, UpdateView):
|
|||
return context
|
||||
|
||||
|
||||
class RemoveContactView(LoginRequiredMixin, View):
|
||||
class RemoveContactView(SalesAccessRequiredMixin, LoginRequiredMixin, View):
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return self.post(request, *args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ INSTALLED_APPS = [
|
|||
'tasks',
|
||||
'invoices',
|
||||
'events',
|
||||
'teams',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ urlpatterns = [
|
|||
path('tasks/', include('tasks.urls', namespace="tasks")),
|
||||
path('invoices/', include('invoices.urls', namespace="invoices")),
|
||||
path('events/', include('events.urls', namespace="events")),
|
||||
path('teams/', include('teams.urls', namespace="teams")),
|
||||
path('emails/', include('emails.urls', namespace="emails")),
|
||||
# path('planner/', include('planner.urls', namespace="planner")),
|
||||
path('logout/', views.LogoutView, {'next_page': '/login/'}, name="logout"),
|
||||
|
|
|
|||
|
|
@ -263,4 +263,4 @@ texinfo_documents = [
|
|||
#texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
||||
#texinfo_no_detailmenu = False
|
||||
|
|
@ -177,14 +177,18 @@
|
|||
<td>{{ event.end_date }} </td>
|
||||
<td>{{ event.created_on|date:'d-m-Y' }}</td>
|
||||
<td>
|
||||
{% if event.created_by %}
|
||||
{% if event.created_by.profile_pic %}
|
||||
{% thumbnail event.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
|
||||
title="{{ event.created_by }}" style="border-radius: 50%" />
|
||||
title="{{ event.created_by }}" style="border-radius: 50%" />
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}" alt="Micro profile pic"
|
||||
style="width: 40px;height: 40px;border-radius: 50%;" />
|
||||
style="width: 40px;height: 40px;border-radius: 50%;" title="{{ event.created_by }}" />
|
||||
{% endif %}
|
||||
{% else %}
|
||||
None
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="actions">
|
||||
|
|
|
|||
|
|
@ -15,9 +15,12 @@ from common.tasks import send_email_user_mentions
|
|||
from events.forms import EventAttachmentForm, EventCommentForm, EventForm
|
||||
from events.models import Event
|
||||
from events.tasks import send_email
|
||||
from common.access_decorators_mixins import (
|
||||
sales_access_required, marketing_access_required, SalesAccessRequiredMixin, MarketingAccessRequiredMixin)
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def events_list(request):
|
||||
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser:
|
||||
|
|
@ -51,7 +54,8 @@ def events_list(request):
|
|||
Q(created_by=request.user) | Q(assigned_to=request.user)).distinct()
|
||||
|
||||
if request.POST.get('event_name', None):
|
||||
events = events.filter(name__icontains=request.POST.get('event_name'))
|
||||
events = events.filter(
|
||||
name__icontains=request.POST.get('event_name'))
|
||||
|
||||
if request.POST.get('created_by', None):
|
||||
events = events.filter(
|
||||
|
|
@ -63,13 +67,15 @@ def events_list(request):
|
|||
context['assigned_to'] = request.POST.getlist('assigned_to')
|
||||
|
||||
if request.POST.get('date_of_meeting', None):
|
||||
events = events.filter(date_of_meeting=request.POST.get('date_of_meeting'))
|
||||
events = events.filter(
|
||||
date_of_meeting=request.POST.get('date_of_meeting'))
|
||||
|
||||
context['events'] = events.distinct().order_by('id')
|
||||
return render(request, 'events_list.html', context)
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def event_create(request):
|
||||
if request.method == 'GET':
|
||||
context = {}
|
||||
|
|
@ -89,7 +95,8 @@ def event_create(request):
|
|||
event.created_by = request.user
|
||||
event.save()
|
||||
form.save_m2m()
|
||||
send_email.delay(event.id, domain=request.get_host(), protocol=request.scheme)
|
||||
send_email.delay(
|
||||
event.id, domain=request.get_host(), protocol=request.scheme)
|
||||
|
||||
if form.cleaned_data.get('event_type') == 'Recurring':
|
||||
delta = end_date - start_date
|
||||
|
|
@ -113,7 +120,8 @@ def event_create(request):
|
|||
)
|
||||
event.contacts.add(*request.POST.getlist('contacts'))
|
||||
event.assigned_to.add(*request.POST.getlist('assigned_to'))
|
||||
send_email.delay(event.id, domain=request.get_host(), protocol=request.scheme)
|
||||
send_email.delay(
|
||||
event.id, domain=request.get_host(), protocol=request.scheme)
|
||||
|
||||
return JsonResponse({'error': False, 'success_url': reverse('events:events_list')})
|
||||
else:
|
||||
|
|
@ -121,6 +129,7 @@ def event_create(request):
|
|||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def event_detail_view(request, event_id):
|
||||
event = get_object_or_404(Event, pk=event_id)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or event.created_by == request.user or request.user in event.assigned_to.all()):
|
||||
|
|
@ -144,6 +153,7 @@ def event_detail_view(request, event_id):
|
|||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def event_update(request, event_id):
|
||||
event_obj = get_object_or_404(Event, pk=event_id)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or event_obj.created_by == request.user or request.user in event_obj.assigned_to.all()):
|
||||
|
|
@ -176,14 +186,15 @@ def event_update(request, event_id):
|
|||
# event.created_by = request.user
|
||||
event.save()
|
||||
form.save_m2m()
|
||||
send_email.delay(event.id, domain=request.get_host(), protocol=request.scheme)
|
||||
|
||||
send_email.delay(
|
||||
event.id, domain=request.get_host(), protocol=request.scheme)
|
||||
|
||||
if form.cleaned_data.get('event_type') == 'Recurring':
|
||||
event = form.save(commit=False)
|
||||
event.save()
|
||||
form.save_m2m()
|
||||
send_email.delay(event.id, domain=request.get_host(), protocol=request.scheme)
|
||||
send_email.delay(
|
||||
event.id, domain=request.get_host(), protocol=request.scheme)
|
||||
|
||||
# event.contacts.add(*request.POST.getlist('contacts'))
|
||||
# event.assigned_to.add(*request.POST.getlist('assigned_to'))
|
||||
|
|
@ -194,6 +205,7 @@ def event_update(request, event_id):
|
|||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def event_delete(request, event_id):
|
||||
event = get_object_or_404(Event, pk=event_id)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or event.created_by == request.user):
|
||||
|
|
|
|||
532
invoices/templates/invoices_detail_1.html
Normal file
532
invoices/templates/invoices_detail_1.html
Normal file
|
|
@ -0,0 +1,532 @@
|
|||
{% extends 'sales/base.html' %}
|
||||
{% load staticfiles %}
|
||||
{% load thumbnail %}
|
||||
{% block breadcrumb %}
|
||||
{% block extralinks %}
|
||||
<link rel="stylesheet" href="{% static 'css/bootstrap-suggest.css' %}">
|
||||
<style>
|
||||
.opacity_block {
|
||||
opacity: 0.2;
|
||||
}
|
||||
</style>
|
||||
{% endblock extralinks %}
|
||||
<!-- breadcrumb starts here -->
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{% url 'invoices:invoices_list' %}">Invoice</a></li>
|
||||
<li class="active breadcrumb-item">{{invoice.invoice_title}}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
{% endblock breadcrumb %}
|
||||
{% block content %}
|
||||
<!-- Task VIEW STARTS -->
|
||||
<div class="crm_invoice" style="">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="crm_form">
|
||||
<div class="row">
|
||||
<div class="col-md-9 p-5 m-auto" style=" background: #fff!important;">
|
||||
<!-- <h1 class="text-center pb-3">{{ invoice.invoice_title }}</h1> -->
|
||||
<div class="card-title text-right">
|
||||
<h5>
|
||||
<span class="float-left title">Overview</span>
|
||||
<span style="margin-top: 0px">
|
||||
<div class="dropdown buttons_row">
|
||||
<a href="{% url 'invoices:invoice_download' invoice.id %}" id="download_btn_" class="btn btn-info"
|
||||
style="padding: 0.12em 0.6em;border-radius: 0;">Download</a>
|
||||
<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 'invoices:invoice_edit' invoice.id %}">Edit</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</span>
|
||||
</h5>
|
||||
</div>
|
||||
<hr>
|
||||
<form id="formid" action='' method="POST" novalidate>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{% if invoice.invoice_title %}
|
||||
<div class="form-group row">
|
||||
<label for="staticEmail" class="col-sm-4 col-form-label">Invoice
|
||||
Title</label>
|
||||
<div class="col-sm-8 pl-0 col-form-label">
|
||||
{{ invoice.invoice_title }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if invoice.invoice_number %}
|
||||
<div class="form-group row">
|
||||
<label for="inputPassword" class="col-sm-4 col-form-label">Invoice
|
||||
Number </label>
|
||||
<div class="col-sm-8 pl-0 col-form-label">
|
||||
{{ invoice.invoice_number }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
{% if invoice.status %}
|
||||
<div class="form-group row">
|
||||
<label for="staticEmail" class="col-sm-4 col-form-label">Status </label>
|
||||
<div class="col-sm-8 pl-0 col-form-label">
|
||||
{{ invoice.status }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
<!-- <div class="col-md-6">
|
||||
<div class="form-group row">
|
||||
<label for="id_contacts" class="col-sm-4 col-form-label">Status{% if form.status.field.required %}<span
|
||||
class="error_marker" style="color:red">*</span>{% endif %}</label>
|
||||
{{ form.status }}
|
||||
<span class="error" id="id__status">{{ form.status.errors }}</span>
|
||||
</div> -->
|
||||
<!-- <div class="row">
|
||||
<div class="col-sm-8 pl-0">
|
||||
<div class="form-group ">
|
||||
<label for="id_contacts" class="required">Status{% if form.status.field.required %}<span
|
||||
class="error_marker" style="color:red">*</span>{% endif %}</label>
|
||||
{{ form.status }}
|
||||
<span class="error" id="id__status">{{ form.status.errors }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <label>Status</label>
|
||||
<button class="btn status btn-primary">Sent</button> -->
|
||||
<!-- </div> -->
|
||||
<div class="col-md-12">
|
||||
<div class="row">
|
||||
<div class="form-group mt-5 col-md-6">
|
||||
<!-- <label for="exampleFormControlTextarea1">From Address</label>
|
||||
<textarea class="form-control" id="exampleFormControlTextarea1"
|
||||
placeholder="Micropyramid Informatics, 6th Floor, Krish saphire Building, Madhapur"
|
||||
rows="6"></textarea> -->
|
||||
<div class="form-group">
|
||||
{% if invoice.from_address.address_line or invoice.from_address.street or invoice.from_address.city or invoice.from_address.state or invoice.from_address.postcode or invoice.from_address.country %}
|
||||
<label for="exampleInputEmail1">From Address</label>
|
||||
<div>
|
||||
{{invoice.from_address.get_complete_address}}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<br>
|
||||
</div>
|
||||
<div class="form-group mt-5 col-md-6">
|
||||
<!-- <label for="exampleFormControlTextarea1">To Address</label>
|
||||
<textarea class="form-control" id="exampleFormControlTextarea1" rows="6"
|
||||
placeholder="Micropyramid Informatics, 6th Floor, Krish saphire Building, Madhapur"></textarea> -->
|
||||
<div class="form-group">
|
||||
{% if invoice.to_address.address_line or invoice.to_address.street or invoice.to_address.city or invoice.to_address.state or invoice.to_address.postcode or invoice.to_address.country %}
|
||||
<label for="exampleInputEmail1">From Address</label>
|
||||
<div>
|
||||
{{invoice.to_address.get_complete_address}}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 mt-5">
|
||||
<div class="form-group row">
|
||||
{% if invoice.name %}
|
||||
<label for="staticEmail" class="col-sm-4 col-form-label">Name
|
||||
</label>
|
||||
<div class="col-sm-8 pl-0 col-form-label">
|
||||
{{ invoice.name }}
|
||||
<span class="error" id="id__name">{{ form.name.errors }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
{% if invoice.email %}
|
||||
<label for="staticEmail" class="col-sm-4 col-form-label">Email</label>
|
||||
<div class="col-sm-8 pl-0 col-form-label">
|
||||
{{ invoice.email }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
{% if invoice.email %}
|
||||
<label for="staticEmail" class="col-sm-4 col-form-label">Phone</label>
|
||||
<div class="col-sm-8 pl-0 col-form-label">
|
||||
{{ invoice.phone }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 mt-5">
|
||||
<div class="form-group row">
|
||||
{% if invoice.currency %}
|
||||
<label for="inputState" class="col-sm-4">Currency{% if form.currency.field.required %}<span
|
||||
class="error_marker" style="color:red"> * </span>{% endif %}</label>
|
||||
<div class="col-sm-8 pl-0">
|
||||
{{ invoice.currency }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
{% if invoice.assigned_to.all %}
|
||||
<label for="staticEmail" class="col-sm-4 col-form-label">Assign To</label>
|
||||
<div class="col-sm-8 pl-0 col-form-label">
|
||||
{% for user in invoice.assigned_to.all %}
|
||||
<div>
|
||||
{{user}}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
{% if invoice.due_date %}
|
||||
<label for="inputState" class="col-sm-4">Due Date</label>
|
||||
<div class="col-sm-8 pl-0">
|
||||
{{ invoice.due_date }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 mt-5">
|
||||
<div class="row pt-0 pb-4">
|
||||
<div class="form-group col-md-4">
|
||||
{% if invoice.quantity %}
|
||||
<label for="inputCity">Quality Hours</label>
|
||||
{{ invoice.quantity }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
{% if invoice.rate %}
|
||||
<label for="inputCity">Rate</label>
|
||||
{{ invoice.rate }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
{% if invoice.total_amount %}
|
||||
<label for="inputCity">Total Amount</label>
|
||||
{{ invoice.total_amount }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 mt-1">
|
||||
<div class="form-group">
|
||||
{% if invoice.details %}
|
||||
<label for="inputZip">Details</label>
|
||||
<br>
|
||||
{{ invoice.details }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<hr>
|
||||
<div class="col-md-12 " style="padding:0">
|
||||
<!-- Attachment Section start -->
|
||||
<div class="card-body mar-top" id="datashow">
|
||||
<div class="card-title view-pad">
|
||||
<h5>Attachments</h5>
|
||||
</div>
|
||||
<div class="row marl">
|
||||
<div class="col-md-12">
|
||||
<form id="attachment_form" method="POST" enctype="multipart/form-data">
|
||||
<div class="form-group ">
|
||||
<input type="file" class="form-control-file" cols="40" id="id_attachments" name="attachment">
|
||||
<div>
|
||||
<p id="AttachmentError" style="display:none; color:red"></p>
|
||||
</div>
|
||||
<br>
|
||||
<div class="buttons_row">
|
||||
<button class="btn btn-default save" style="text-align: center;"
|
||||
id="attachment_submit">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" value="{{invoice.id}}" name="invoice_id">
|
||||
</form>
|
||||
<ul class="list-group" id="attachment_div">
|
||||
{% for attachment in attachments %}
|
||||
<li class="list-group-item list-row" id="attachment{{attachment.id}}">
|
||||
{% if request.user.is_superuser or request.user.role == 'ADMIN' or request.user == attachment.created_by %}
|
||||
<div class="float-right right-container">
|
||||
<div class="list-row-buttons btn-group float-right">
|
||||
<button class="action btn primary_btn"
|
||||
onclick="remove_attachment({{attachment.id}})">Remove</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="stream-post-container" id="attachment_name{{attachment.id}}">
|
||||
{% if attachment.attachment %}
|
||||
{% if 'image' in attachment.file_type %}
|
||||
{% thumbnail attachment.attachment "80x80" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" class="mb-2">
|
||||
{% endthumbnail %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<pre> <span class="icon"><i style="font-size:1.5rem;" class="{{attachment.get_file_type_display}}"></i> </span>{{attachment.file_name}} <a href="{% url 'common:download_attachment' attachment.id %}">Download</a></pre>
|
||||
</div>
|
||||
<div class="stream-container">
|
||||
<pre class="float-left">Uploaded by :{{ attachment.created_by }}</pre>
|
||||
<pre class="float-right date">{{ attachment.created_on|date:'m/d/Y, h:i A' }}</pre>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Attachment Section end -->
|
||||
<hr>
|
||||
<!-- Comments Section starts-->
|
||||
<div class="card-body" id="datashow">
|
||||
<div class="card-title">
|
||||
<h5>Comments</h5>
|
||||
</div>
|
||||
<div class="row marl">
|
||||
<div class="col-md-12">
|
||||
<form id="comment_form" method="POST" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<textarea class="form-control mentions" textarea cols="40" rows="3" id="id_comments"
|
||||
name="comment" placeholder="Submit Your Comments Here"></textarea>
|
||||
<div>
|
||||
<p id="CommentError" style="display:none; color:red"></p>
|
||||
</div>
|
||||
</br>
|
||||
<div class="buttons_row">
|
||||
<button class="btn btn-default save" style="text-align: center;" id="comment_submit"
|
||||
type="submit">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" value="{{ invoice.id }}" name="invoice_id">
|
||||
</form>
|
||||
<ul class="list-group" id="comments_div">
|
||||
{% for comment in comments %}
|
||||
<li class="list-group-item list-row" id="comment{{comment.id}}">
|
||||
{% if request.user.is_superuser or request.user.role == 'ADMIN' or request.user == comment.commented_by %}
|
||||
<div class="list-row-buttons btn-group float-right">
|
||||
<button class="btn primary_btn btn-sm dropdown-toggle" data-toggle="dropdown"
|
||||
type="button">Actions<span class="caret"></span></button>
|
||||
<ul class="dropdown-menu text-center">
|
||||
<li>
|
||||
<a class="action" onclick="edit_comment({{comment.id}})">Edit</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="action" onclick="remove_comment({{comment.id}})">Remove</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="stream-post-container" id="comment_name{{comment.id}}">
|
||||
<pre>{{ comment.comment }}</pre>
|
||||
</div>
|
||||
<div class="stream-container">
|
||||
<pre class="float-left">{{ comment.commented_by }}</pre>
|
||||
<pre class="float-right date">{{ comment.commented_on|date:'m/d/Y, h:i:s A' }}</pre>
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="Comments_Accounts_Modal" role="dialog" data-keyboard="false"
|
||||
data-backdrop="static">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Update Your Comment</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
|
||||
</div>
|
||||
<form id="comment_edit_form" method="POST">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<textarea class="form-control mentions" textarea cols="40" rows="3" id="id_editcomment"
|
||||
name="comment" placeholder="Submit Your Comments" style="color:black;"></textarea><span>
|
||||
<p id="CommentEditError" style="display:none; color:red"></p>
|
||||
</span>
|
||||
<input type="hidden" value="{{ invoice.id }}" name="invoice_id">
|
||||
<input type="hidden" value="" name="commentid" id="commentid">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-default save" id="comment_edit" type="submit">Update</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Comments Section Ends-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
{% block js_block %}
|
||||
<script type="text/javascript">
|
||||
$('#loading_spinner').hide()
|
||||
$("#comment_form").submit(function (e) {
|
||||
e.preventDefault()
|
||||
var formData = new FormData($("#comment_form")[0]);
|
||||
$.ajax({
|
||||
url: "{% url 'invoices:add_comment' %}",
|
||||
type: "POST",
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
if (data.error) {
|
||||
$("#CommentError").html(data.error).show()
|
||||
} else {
|
||||
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 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>" +
|
||||
"<div class='stream-post-container' id='comment_name" + data.comment_id + "'><pre>" + data.comment + "</pre></div>" +
|
||||
"<div class='stream-container'><pre class='float-left'>" + data.commented_by + "</pre><pre class='float-right'>" + d.toLocaleString('en-US', { hour12: true }) + "</pre></div>"
|
||||
)
|
||||
$("#id_comments").val("")
|
||||
alert("Comment Submitted")
|
||||
$("#CommentError").html("")
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function edit_comment(x) {
|
||||
$('#Comments_Accounts_Modal').modal('show');
|
||||
comment = $("#comment_name" + x).text()
|
||||
$("#commentid").val(x)
|
||||
$("#id_editcomment").val(comment)
|
||||
$("#edit_file_field").html($("#comment_file_div" + x).clone())
|
||||
}
|
||||
|
||||
$("#comment_edit").click(function (e) {
|
||||
e.preventDefault()
|
||||
var formData = new FormData($("#comment_edit_form")[0]);
|
||||
$.ajax({
|
||||
url: "{% url 'invoices:edit_comment' %}",
|
||||
type: "POST",
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
if (data.error) {
|
||||
$("#CommentEditError").html(data.error).show()
|
||||
} else {
|
||||
console.log($("#comment_name" + data.comment_id))
|
||||
$("#comment_name" + data.comment_id).html('<pre>' + data.comment + '</pre>')
|
||||
$('#Comments_Accounts_Modal').modal('hide');
|
||||
$("#id_editcomment").val("")
|
||||
$("#CommentEditError").html('')
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/*Comment Edit Js Ends*/
|
||||
|
||||
function HideError(e) {
|
||||
$("#CommentError").hide()
|
||||
$("#CommentEditError").hide()
|
||||
}
|
||||
|
||||
/*Comment Remove Js Start*/
|
||||
|
||||
function remove_comment(x) {
|
||||
var con = confirm("Do you want to Delete it for Sure!?")
|
||||
if (con == true) {
|
||||
$.post('{% url "accounts:remove_comment" %}', {
|
||||
"comment_id": x
|
||||
}, function (data) {
|
||||
if (data.error) {
|
||||
alert(data.error)
|
||||
} else {
|
||||
$("#comment" + data.cid).remove()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function remove_attachment(x) {
|
||||
const con = confirm("Do you want to Delete it for Sure!?");
|
||||
if (con == true) {
|
||||
$.post('{% url "leads:remove_attachment" %}', {
|
||||
"attachment_id": x
|
||||
}, function (data) {
|
||||
if (data.error) {
|
||||
alert(data.error)
|
||||
} else {
|
||||
$("#attachment" + data.aid).remove()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
$("#attachment_form").submit(function (e) {
|
||||
e.preventDefault()
|
||||
const formData = new FormData($("#attachment_form")[0]);
|
||||
$.ajax({
|
||||
url: "{% url 'invoices:add_attachment' %}",
|
||||
type: "POST",
|
||||
data: formData,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
beforeSend: function () {
|
||||
$('#loading_spinner').show()
|
||||
$('#opacity_block').addClass('opacity_block')
|
||||
},
|
||||
success: function (data) {
|
||||
if (data.error) {
|
||||
$("#AttachmentError").html(data.error).show()
|
||||
$('#loading_spinner').hide()
|
||||
$('#opacity_block').removeClass('opacity_block')
|
||||
} else {
|
||||
d = new Date(data.created_on)
|
||||
$("#attachment_div").prepend(
|
||||
"<li class='list-group-item list-row' id='attachment" + data.attachment_id + "'>" +
|
||||
"<div class='float-right right-container'><div class='list-row-buttons btn-group float-right'><button class='action btn primary_btn' onclick='remove_attachment(" + data.attachment_id + ")''>Remove</button></div></div>" +
|
||||
"<div class='stream-post-container' id='attachment_name" + data.attachment_id + "'>" +
|
||||
`${(data.file_type[0]).startsWith('image') ? `<img src=${data.attachment_url} width="80px" height="80px" class="mb-2">` : ''}` +
|
||||
"<pre><span class='icon'><i style='font-size:1.5rem;' class='" + data.attachment_display + "'></i> </span>" + data.attachment + " <a href='" + data.download_url + "'>Download</a></pre></div>" +
|
||||
"<div class='stream-container'><pre class='float-left'>" + data.created_by + "</pre><pre class='float-right date'>" + d.toLocaleString('en-US', { hour12: true }) + "</pre></div>" +
|
||||
"</li>"
|
||||
)
|
||||
$("#AttachmentError").html("")
|
||||
$("#id_attachments").val("")
|
||||
$('#loading_spinner').hide()
|
||||
$('#opacity_block').removeClass('opacity_block')
|
||||
setTimeout(() => {
|
||||
alert("Attachment Saved")
|
||||
}, 100)
|
||||
// alert("Attachment Saved")
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
</script>
|
||||
<script src="{% static 'js/bootstrap-suggest.js' %}"></script>
|
||||
<script>
|
||||
$('.mentions').suggest('@', {
|
||||
data: {{ users_mention| safe}},
|
||||
map: function (user) {
|
||||
return {
|
||||
value: user.username,
|
||||
text: '<strong>' + user.username + '</strong>'
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
{% endblock js_block %}
|
||||
|
|
@ -40,7 +40,8 @@
|
|||
<option value="">
|
||||
------------------</option>
|
||||
{% for user in users %}
|
||||
<option value="{{user.id}}" {% if user.id|slugify == request.POST.created_by %} selected="" {% endif %}>
|
||||
<option value="{{user.id}}" {% if user.id|slugify == request.POST.created_by %} selected=""
|
||||
{% endif %}>
|
||||
{{user.email}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
|
@ -164,14 +165,18 @@
|
|||
{% endwith %}
|
||||
</td>
|
||||
<td>
|
||||
{% if invoice.created_by %}
|
||||
{% if invoice.created_by.profile_pic %}
|
||||
{% thumbnail invoice.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
|
||||
title="{{ lead.created_by }}" style="border-radius: 50%" />
|
||||
title="{{ invoice.created_by }}" style="border-radius: 50%" />
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}" alt="Micro profile pic"
|
||||
style="width: 40px;height: 40px;border-radius: 50%;" />
|
||||
style="width: 40px;height: 40px;border-radius: 50%;" title="{{ invoice.created_by }}" />
|
||||
{% endif %}
|
||||
{% else %}
|
||||
None
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ invoice.created_on|date:'d-m-Y' }}</td>
|
||||
|
|
@ -191,13 +196,15 @@
|
|||
<a href="{% url 'invoices:invoice_change_status_paid' invoice.id %}" title="Paid"
|
||||
class="btn btn-info"><i class="fas fa-check-square"></i></a>
|
||||
<a href="{% url 'invoices:invoice_change_status_cancelled' invoice.id %}" title="Cancel"
|
||||
class="btn btn-danger " style="background-color: red;"><i class="fas fa-window-close"></i></a>
|
||||
class="btn btn-danger " style="background-color: red;"><i
|
||||
class="fas fa-window-close"></i></a>
|
||||
{% endif %}
|
||||
{% if invoice.is_resent %}
|
||||
<a href="{% url 'invoices:invoice_change_status_paid' invoice.id %}" title="Paid"
|
||||
class="btn btn-info"><i class="fas fa-check-square"></i></a>
|
||||
<a href="{% url 'invoices:invoice_change_status_cancelled' invoice.id %}" title="Cancel"
|
||||
class="btn btn-danger " style="background-color: red;"><i class="fas fa-window-close"></i></a>
|
||||
class="btn btn-danger " style="background-color: red;"><i
|
||||
class="fas fa-window-close"></i></a>
|
||||
{% endif %}
|
||||
{% if invoice.is_paid_or_cancelled == True %}
|
||||
<!-- <a title="re send mail" class="btn btn-secondary">no actions</a> -->
|
||||
|
|
|
|||
|
|
@ -19,9 +19,12 @@ from invoices.forms import (InvoiceAddressForm, InvoiceAttachmentForm,
|
|||
InvoiceCommentForm, InvoiceForm)
|
||||
from invoices.models import Invoice
|
||||
from invoices.tasks import send_email, send_invoice_email, send_invoice_email_cancel
|
||||
from common.access_decorators_mixins import (
|
||||
sales_access_required, marketing_access_required, SalesAccessRequiredMixin, MarketingAccessRequiredMixin)
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def invoices_list(request):
|
||||
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser:
|
||||
|
|
@ -88,6 +91,7 @@ def invoices_list(request):
|
|||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def invoices_create(request):
|
||||
if request.method == 'GET':
|
||||
context = {}
|
||||
|
|
@ -127,6 +131,7 @@ def invoices_create(request):
|
|||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def invoice_details(request, invoice_id):
|
||||
invoice = get_object_or_404(Invoice.objects.select_related(
|
||||
'from_address', 'to_address'), pk=invoice_id)
|
||||
|
|
@ -147,10 +152,11 @@ def invoice_details(request, invoice_id):
|
|||
else:
|
||||
context['users_mention'] = list(
|
||||
invoice.assigned_to.all().values('username'))
|
||||
return render(request, 'invoices_detail.html', context)
|
||||
return render(request, 'invoices_detail_1.html', context)
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def invoice_edit(request, invoice_id):
|
||||
invoice_obj = get_object_or_404(Invoice, pk=invoice_id)
|
||||
|
||||
|
|
@ -194,6 +200,7 @@ def invoice_edit(request, invoice_id):
|
|||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def invoice_delete(request, invoice_id):
|
||||
invoice = get_object_or_404(Invoice, pk=invoice_id)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or invoice.created_by == request.user):
|
||||
|
|
@ -205,6 +212,7 @@ def invoice_delete(request, invoice_id):
|
|||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def invoice_send_mail(request, invoice_id):
|
||||
invoice = get_object_or_404(Invoice, pk=invoice_id)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or invoice.created_by == request.user):
|
||||
|
|
@ -219,6 +227,7 @@ def invoice_send_mail(request, invoice_id):
|
|||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def invoice_change_status_paid(request, invoice_id):
|
||||
invoice = get_object_or_404(Invoice, pk=invoice_id)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or invoice.created_by == request.user):
|
||||
|
|
@ -231,6 +240,7 @@ def invoice_change_status_paid(request, invoice_id):
|
|||
return redirect('invoices:invoices_list')
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def invoice_change_status_cancelled(request, invoice_id):
|
||||
invoice = get_object_or_404(Invoice, pk=invoice_id)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or invoice.created_by == request.user):
|
||||
|
|
@ -243,6 +253,7 @@ def invoice_change_status_cancelled(request, invoice_id):
|
|||
return redirect('invoices:invoices_list')
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def invoice_download(request, invoice_id):
|
||||
invoice = get_object_or_404(Invoice.objects.select_related(
|
||||
'from_address', 'to_address'), pk=invoice_id)
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@
|
|||
<td><a href="{% url 'leads:view_lead' lead.id %}">
|
||||
{{ lead.title }} </a></td>
|
||||
<td>
|
||||
{% if lead.created_by %}
|
||||
{% if lead.created_by.profile_pic %}
|
||||
{% thumbnail lead.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
|
||||
|
|
@ -154,7 +155,10 @@
|
|||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}" alt="Micro profile pic"
|
||||
style="width: 40px;height: 40px;" />
|
||||
style="width: 40px;height: 40px;" title="{{ lead.created_by }}" />
|
||||
{% endif %}
|
||||
{% else %}
|
||||
None
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ lead.source }}</td>
|
||||
|
|
|
|||
|
|
@ -476,7 +476,7 @@ class TestLeadListView(TestCase):
|
|||
self.client = Client()
|
||||
|
||||
self.user = User.objects.create(
|
||||
username='gorge', email='g@mp.com')
|
||||
username='gorge', email='g@mp.com', has_sales_access=True)
|
||||
self.user.set_password('jorge2293')
|
||||
self.user.save()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import json
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.core.mail import EmailMessage
|
||||
|
|
@ -24,8 +25,11 @@ from leads.tasks import send_lead_assigned_emails
|
|||
from django.core.exceptions import PermissionDenied
|
||||
from common.tasks import send_email_user_mentions
|
||||
from leads.tasks import send_email_to_assigned_user
|
||||
from common.access_decorators_mixins import (
|
||||
sales_access_required, marketing_access_required, SalesAccessRequiredMixin, MarketingAccessRequiredMixin)
|
||||
|
||||
class LeadListView(LoginRequiredMixin, TemplateView):
|
||||
|
||||
class LeadListView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateView):
|
||||
model = Lead
|
||||
context_object_name = "lead_obj"
|
||||
template_name = "leads.html"
|
||||
|
|
@ -102,6 +106,8 @@ class LeadListView(LoginRequiredMixin, TemplateView):
|
|||
return self.render_to_response(context)
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def create_lead(request):
|
||||
template_name = "create_lead.html"
|
||||
users = []
|
||||
|
|
@ -217,7 +223,7 @@ def create_lead(request):
|
|||
return render(request, template_name, context)
|
||||
|
||||
|
||||
class LeadDetailView(LoginRequiredMixin, DetailView):
|
||||
class LeadDetailView(SalesAccessRequiredMixin, LoginRequiredMixin, DetailView):
|
||||
model = Lead
|
||||
context_object_name = "lead_record"
|
||||
template_name = "view_leads.html"
|
||||
|
|
@ -273,6 +279,8 @@ class LeadDetailView(LoginRequiredMixin, DetailView):
|
|||
return context
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def update_lead(request, pk):
|
||||
lead_record = Lead.objects.filter(pk=pk).first()
|
||||
template_name = "create_lead.html"
|
||||
|
|
@ -437,7 +445,7 @@ def update_lead(request, pk):
|
|||
return render(request, template_name, context)
|
||||
|
||||
|
||||
class DeleteLeadView(LoginRequiredMixin, View):
|
||||
class DeleteLeadView(SalesAccessRequiredMixin, LoginRequiredMixin, View):
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return self.post(request, *args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -197,12 +197,13 @@ class ContactForm(forms.ModelForm):
|
|||
self.fields['city'].required = True
|
||||
self.fields['state'].required = True
|
||||
self.fields['email'].required = True
|
||||
self.fields['company_name'].required = True
|
||||
self.fields['contact_list'].required = False
|
||||
|
||||
class Meta:
|
||||
model = Contact
|
||||
fields = ["name", "email", "contact_number",
|
||||
"last_name", "city", "state"]
|
||||
"last_name", "city", "state", "company_name"]
|
||||
|
||||
def clean_email(self):
|
||||
email = self.cleaned_data.get('email')
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class ContactList(models.Model):
|
|||
User, related_name="contact_lists_visible_to")
|
||||
|
||||
class Meta:
|
||||
ordering = ('id',)
|
||||
ordering = ('-created_on',)
|
||||
|
||||
@property
|
||||
def created_by_user(self):
|
||||
|
|
@ -264,6 +264,15 @@ class Campaign(models.Model):
|
|||
def get_all_emails_subscribed_count(self):
|
||||
return self.get_all_emails_count - self.get_all_email_bounces_count - self.get_all_emails_unsubscribed_count
|
||||
|
||||
@property
|
||||
def get_all_emails_contacts_opened(self):
|
||||
contact_ids = CampaignOpen.objects.filter(
|
||||
campaign=self).values_list('contact_id', flat=True)
|
||||
# opened_contacts = Contact.objects.filter(id__in=contact_ids)
|
||||
# return opened_contacts
|
||||
return contact_ids.count()
|
||||
|
||||
|
||||
|
||||
@receiver(models.signals.pre_delete, sender=Campaign)
|
||||
def comment_attachments_delete(sender, instance, **kwargs):
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb mb-3">
|
||||
<li class="breadcrumb-item"><a href="{% url 'marketing:contacts_list' %}">Contacts</a></li>
|
||||
<li class="breadcrumb-item active">{{contact_obj.email}}</li>
|
||||
<li class="breadcrumb-item active">{{contact_obj.name}}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
<div class="main_container ml-5 mr-5">
|
||||
|
|
@ -31,6 +31,15 @@
|
|||
{{contact_obj.email}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1" class="required">
|
||||
Company{% if form.email.field.required %}<span class="error_marker"
|
||||
style="color:red">*</span>{% endif %}</label>
|
||||
<br>
|
||||
{{contact_obj.company_name}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1" class="required">First
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ from marketing.models import (Campaign, CampaignLinkClick, CampaignLog,
|
|||
CampaignOpen, Contact, ContactList,
|
||||
EmailTemplate, Link, Tag, FailedContact, ContactUnsubscribedCampaign)
|
||||
from marketing.tasks import run_campaign, upload_csv_file
|
||||
from common.access_decorators_mixins import marketing_access_required, MarketingAccessRequiredMixin
|
||||
|
||||
TIMEZONE_CHOICES = [(tz, tz) for tz in pytz.common_timezones]
|
||||
|
||||
|
|
@ -39,6 +40,7 @@ def get_exact_match(query, m2m_field, ids):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def dashboard(request):
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser:
|
||||
email_templates = EmailTemplate.objects.all()
|
||||
|
|
@ -51,16 +53,34 @@ def dashboard(request):
|
|||
campaign = Campaign.objects.filter(created_by=request.user)
|
||||
contacts_list = ContactList.objects.filter(created_by=request.user)
|
||||
|
||||
x_axis_titles = [
|
||||
campaign_obj.title for campaign_obj in campaign[:5]]
|
||||
y_axis_bounces = [
|
||||
campaign_obj.get_all_email_bounces_count for campaign_obj in campaign[:5]]
|
||||
y_axis_unsubscribed = [
|
||||
campaign_obj.get_all_emails_unsubscribed_count for campaign_obj in campaign[:5]]
|
||||
y_axis_subscribed = [
|
||||
campaign_obj.get_all_emails_subscribed_count for campaign_obj in campaign[:5]]
|
||||
y_axis_opened = [
|
||||
campaign_obj.get_all_emails_contacts_opened for campaign_obj in campaign[:5]]
|
||||
|
||||
|
||||
context = {
|
||||
'email_templates': email_templates,
|
||||
'contacts': contacts,
|
||||
'campaigns': campaign,
|
||||
'contacts_list': contacts_list
|
||||
'contacts_list': contacts_list,
|
||||
'y_axis_subscribed': y_axis_subscribed,
|
||||
'y_axis_unsubscribed': y_axis_unsubscribed,
|
||||
'y_axis_bounces': y_axis_bounces,
|
||||
'y_axis_opened': y_axis_opened,
|
||||
'x_axis_titles': x_axis_titles,
|
||||
}
|
||||
return render(request, 'marketing/dashboard.html', context)
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def contact_lists(request):
|
||||
tags = Tag.objects.all()
|
||||
if (request.user.role == "ADMIN"):
|
||||
|
|
@ -94,6 +114,7 @@ def contact_lists(request):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def contacts_list(request):
|
||||
if (request.user.role == "ADMIN"):
|
||||
contacts = Contact.objects.all()
|
||||
|
|
@ -126,6 +147,7 @@ def contacts_list(request):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def contact_list_new(request):
|
||||
data = {}
|
||||
if request.method == "POST":
|
||||
|
|
@ -158,6 +180,7 @@ def contact_list_new(request):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def edit_contact_list(request, pk):
|
||||
user = request.user
|
||||
try:
|
||||
|
|
@ -198,6 +221,7 @@ def edit_contact_list(request, pk):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def view_contact_list(request, pk):
|
||||
contact_list = get_object_or_404(ContactList, pk=pk)
|
||||
contacts = Contact.objects.filter(contact_list__in=[contact_list])
|
||||
|
|
@ -222,6 +246,7 @@ def view_contact_list(request, pk):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def delete_contact_list(request, pk):
|
||||
contact_list_obj = get_object_or_404(ContactList, pk=pk)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or contact_list_obj.created_by == request.user):
|
||||
|
|
@ -233,6 +258,7 @@ def delete_contact_list(request, pk):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def contacts_list_new(request):
|
||||
if request.POST:
|
||||
form = ContactForm(request.POST)
|
||||
|
|
@ -256,6 +282,7 @@ def contacts_list_new(request):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def edit_contact(request, pk):
|
||||
url_redirect_to = None
|
||||
contact_obj = get_object_or_404(Contact, pk=pk)
|
||||
|
|
@ -269,18 +296,33 @@ def edit_contact(request, pk):
|
|||
if request.method == 'POST':
|
||||
form = ContactForm(request.POST, instance=contact_obj)
|
||||
if form.is_valid():
|
||||
contact = form.save(commit=False)
|
||||
contact.save()
|
||||
form.save_m2m()
|
||||
if form.has_changed():
|
||||
if contact_obj.contact_list.count() > 1:
|
||||
contact_list_obj = ContactList.objects.filter(
|
||||
id=request.POST.get('from_url')).first()
|
||||
if contact_list_obj:
|
||||
contact_obj.contact_list.remove(contact_list_obj)
|
||||
updated_contact = ContactForm(request.POST)
|
||||
updated_contact_obj = updated_contact.save()
|
||||
updated_contact_obj.contact_list.add(contact_list_obj)
|
||||
else:
|
||||
contact = form.save(commit=False)
|
||||
contact.save()
|
||||
form.save_m2m()
|
||||
else:
|
||||
contact = form.save(commit=False)
|
||||
contact.save()
|
||||
form.save_m2m()
|
||||
if request.POST.get('from_url'):
|
||||
return JsonResponse({'error': False,
|
||||
'success_url': reverse('marketing:contact_list_detail', args=(request.POST.get('from_url'),))})
|
||||
'success_url': reverse('marketing:contact_list_detail', args=(request.POST.get('from_url'),))})
|
||||
return JsonResponse({'error': False, 'success_url': reverse('marketing:contacts_list')})
|
||||
else:
|
||||
return JsonResponse({'error': True, 'errors': form.errors, })
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def delete_contact(request, pk):
|
||||
contact_obj = get_object_or_404(Contact, pk=pk)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or contact_obj.created_by == request.user or
|
||||
|
|
@ -293,6 +335,7 @@ def delete_contact(request, pk):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def contact_list_detail(request, pk):
|
||||
contact_list = get_object_or_404(ContactList, pk=pk)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or contact_list.created_by == request.user):
|
||||
|
|
@ -313,6 +356,7 @@ def contact_list_detail(request, pk):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def failed_contact_list_detail(request, pk):
|
||||
contact_list = get_object_or_404(ContactList, pk=pk)
|
||||
failed_contacts_list = contact_list.failed_contacts.all()
|
||||
|
|
@ -322,6 +366,7 @@ def failed_contact_list_detail(request, pk):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def failed_contact_list_download_delete(request, pk):
|
||||
contact_list = get_object_or_404(ContactList, pk=pk)
|
||||
failed_contacts_list = contact_list.failed_contacts.all()
|
||||
|
|
@ -342,6 +387,7 @@ def failed_contact_list_download_delete(request, pk):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def email_template_list(request):
|
||||
# users = User.objects.all()
|
||||
if (request.user.is_admin or request.user.is_superuser):
|
||||
|
|
@ -365,6 +411,7 @@ def email_template_list(request):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def email_template_new(request):
|
||||
if request.POST:
|
||||
form = EmailTemplateForm(request.POST)
|
||||
|
|
@ -380,6 +427,7 @@ def email_template_new(request):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def email_template_edit(request, pk):
|
||||
email_template = get_object_or_404(EmailTemplate, pk=pk)
|
||||
|
||||
|
|
@ -397,6 +445,7 @@ def email_template_edit(request, pk):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def email_template_detail(request, pk):
|
||||
queryset = get_object_or_404(EmailTemplate, id=pk)
|
||||
data = {'email_template': queryset}
|
||||
|
|
@ -404,6 +453,7 @@ def email_template_detail(request, pk):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def email_template_delete(request, pk):
|
||||
try:
|
||||
EmailTemplate.objects.get(id=pk).delete()
|
||||
|
|
@ -414,6 +464,7 @@ def email_template_delete(request, pk):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def campaign_list(request):
|
||||
# users = User.objects.all()
|
||||
if (request.user.role == "ADMIN"):
|
||||
|
|
@ -438,6 +489,7 @@ def campaign_list(request):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def campaign_new(request):
|
||||
if request.method == 'GET':
|
||||
if request.user.is_admin or request.user.is_superuser:
|
||||
|
|
@ -533,11 +585,13 @@ def campaign_new(request):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def campaign_edit(request):
|
||||
return render(request, 'marketing/campaign/edit.html')
|
||||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def campaign_details(request, pk):
|
||||
try:
|
||||
campaign = Campaign.objects.get(pk=pk)
|
||||
|
|
@ -559,12 +613,12 @@ def campaign_details(request, pk):
|
|||
|
||||
all_contacts = contacts
|
||||
bounced_contacts = contacts.filter(is_bounced=True).distinct()
|
||||
# unsubscribe_contacts = contacts.filter(
|
||||
# is_unsubscribed=True).distinct()
|
||||
unsubscribe_contacts_ids = ContactUnsubscribedCampaign.objects.filter(
|
||||
campaigns=campaign, is_unsubscribed=True).values_list('contacts_id', flat=True)
|
||||
unsubscribe_contacts = Contact.objects.filter(
|
||||
id__in=unsubscribe_contacts_ids)
|
||||
unsubscribe_contacts = contacts.filter(
|
||||
is_unsubscribed=True).distinct()
|
||||
# unsubscribe_contacts_ids = ContactUnsubscribedCampaign.objects.filter(
|
||||
# campaigns=campaign, is_unsubscribed=True).values_list('contacts_id', flat=True)
|
||||
# unsubscribe_contacts = Contact.objects.filter(
|
||||
# id__in=unsubscribe_contacts_ids)
|
||||
# read_contacts = campaign.marketing_links.filter(Q(clicks__gt=0)).distinct()
|
||||
contact_ids = CampaignOpen.objects.filter(
|
||||
campaign=campaign).values_list('contact_id', flat=True)
|
||||
|
|
@ -671,6 +725,7 @@ def campaign_details(request, pk):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def campaign_delete(request, pk):
|
||||
try:
|
||||
campaign = Campaign.objects.get(id=pk)
|
||||
|
|
@ -762,6 +817,7 @@ def unsubscribe_from_campaign(request, contact_id, campaign_id):
|
|||
|
||||
|
||||
@login_required
|
||||
@marketing_access_required
|
||||
def contact_detail(request, contact_id):
|
||||
contact_obj = get_object_or_404(Contact, pk=contact_id)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or contact_obj.created_by == request.user or
|
||||
|
|
@ -774,6 +830,7 @@ def contact_detail(request, contact_id):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def edit_failed_contact(request, pk):
|
||||
contact_obj = get_object_or_404(FailedContact, pk=pk)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or contact_obj.created_by == request.user):
|
||||
|
|
@ -794,6 +851,7 @@ def edit_failed_contact(request, pk):
|
|||
|
||||
|
||||
@login_required(login_url='/login')
|
||||
@marketing_access_required
|
||||
def delete_failed_contact(request, pk):
|
||||
contact_obj = get_object_or_404(FailedContact, pk=pk)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or contact_obj.created_by == request.user):
|
||||
|
|
@ -804,6 +862,7 @@ def delete_failed_contact(request, pk):
|
|||
|
||||
|
||||
@login_required
|
||||
@marketing_access_required
|
||||
def download_contacts_for_campaign(request, compaign_id):
|
||||
campaign_obj = get_object_or_404(Campaign, pk=compaign_id)
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser or campaign_obj.created_by == request.user):
|
||||
|
|
@ -817,11 +876,11 @@ def download_contacts_for_campaign(request, compaign_id):
|
|||
|
||||
if request.GET.get('is_unsubscribed') == 'true':
|
||||
|
||||
unsubscribe_contacts_ids = ContactUnsubscribedCampaign.objects.filter(
|
||||
campaigns=campaign_obj, is_unsubscribed=True).values_list('contacts_id', flat=True)
|
||||
# contact_ids = campaign_obj.contact_lists.filter(contacts__is_unsubscribed=True).values_list(
|
||||
# 'contacts__id', flat=True)
|
||||
contacts = Contact.objects.filter(id__in=unsubscribe_contacts_ids).values(
|
||||
# unsubscribe_contacts_ids = ContactUnsubscribedCampaign.objects.filter(
|
||||
# campaigns=campaign_obj, is_unsubscribed=True).values_list('contacts_id', flat=True)
|
||||
contact_ids = campaign_obj.contact_lists.filter(contacts__is_unsubscribed=True).values_list(
|
||||
'contacts__id', flat=True)
|
||||
contacts = Contact.objects.filter(id__in=contact_ids).values(
|
||||
'company_name', 'email', 'name', 'last_name', 'city', 'state')
|
||||
|
||||
if request.GET.get('is_opened') == 'true':
|
||||
|
|
@ -843,6 +902,7 @@ def download_contacts_for_campaign(request, compaign_id):
|
|||
|
||||
|
||||
@login_required
|
||||
@marketing_access_required
|
||||
def create_campaign_from_template(request, template_id):
|
||||
email_template_obj = get_object_or_404(EmailTemplate, pk=template_id)
|
||||
if request.method == 'GET':
|
||||
|
|
|
|||
|
|
@ -294,7 +294,8 @@ class TestOpportunityListViewForUser(OpportunityModel, TestCase):
|
|||
first_name="mpmp",
|
||||
username='mpmp',
|
||||
email='mpmp@micropyramid.com',
|
||||
role="USER")
|
||||
role="USER",
|
||||
has_sales_access=True)
|
||||
self.usermp.set_password('mp')
|
||||
self.usermp.save()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import json
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.core.mail import EmailMessage
|
||||
|
|
@ -19,9 +20,11 @@ from django.db.models import Q
|
|||
from django.core.exceptions import PermissionDenied
|
||||
from common.tasks import send_email_user_mentions
|
||||
from opportunity.tasks import send_email_to_assigned_user
|
||||
from common.access_decorators_mixins import (
|
||||
sales_access_required, marketing_access_required, SalesAccessRequiredMixin, MarketingAccessRequiredMixin)
|
||||
|
||||
|
||||
class OpportunityListView(LoginRequiredMixin, TemplateView):
|
||||
class OpportunityListView(SalesAccessRequiredMixin, LoginRequiredMixin, TemplateView):
|
||||
model = Opportunity
|
||||
context_object_name = "opportunity_list"
|
||||
template_name = "opportunity.html"
|
||||
|
|
@ -91,6 +94,8 @@ class OpportunityListView(LoginRequiredMixin, TemplateView):
|
|||
return self.render_to_response(context)
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def create_opportunity(request):
|
||||
accounts = Account.objects.filter(status="open")
|
||||
contacts = Contact.objects.all()
|
||||
|
|
@ -168,7 +173,7 @@ def create_opportunity(request):
|
|||
from_account = request.POST.get('from_account')
|
||||
success_url = reverse("accounts:view_account", kwargs={
|
||||
'pk': from_account})
|
||||
print(success_url)
|
||||
# print(success_url)
|
||||
return JsonResponse({'error': False, 'success_url': success_url})
|
||||
return JsonResponse({'error': True, 'errors': form.errors})
|
||||
context = {}
|
||||
|
|
@ -191,7 +196,7 @@ def create_opportunity(request):
|
|||
return render(request, "create_opportunity.html", context)
|
||||
|
||||
|
||||
class OpportunityDetailView(LoginRequiredMixin, DetailView):
|
||||
class OpportunityDetailView(SalesAccessRequiredMixin, LoginRequiredMixin, DetailView):
|
||||
model = Opportunity
|
||||
context_object_name = "opportunity_record"
|
||||
template_name = "view_opportunity.html"
|
||||
|
|
@ -237,6 +242,8 @@ class OpportunityDetailView(LoginRequiredMixin, DetailView):
|
|||
return context
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def update_opportunity(request, pk):
|
||||
opportunity_object = Opportunity.objects.filter(pk=pk).first()
|
||||
accounts = Account.objects.filter(status="open")
|
||||
|
|
@ -362,7 +369,7 @@ def update_opportunity(request, pk):
|
|||
return render(request, "create_opportunity.html", context)
|
||||
|
||||
|
||||
class DeleteOpportunityView(LoginRequiredMixin, View):
|
||||
class DeleteOpportunityView(SalesAccessRequiredMixin, LoginRequiredMixin, View):
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
return self.post(request, *args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ class TaskForm(forms.ModelForm):
|
|||
|
||||
if request_user.role == 'USER':
|
||||
self.fields["account"].queryset = Account.objects.filter(
|
||||
created_by=request_user)
|
||||
created_by=request_user).filter(status="open")
|
||||
|
||||
self.fields["contacts"].queryset = Contact.objects.filter(
|
||||
Q(assigned_to__in=[request_user]) | Q(created_by=request_user))
|
||||
|
||||
if request_user.role == 'ADMIN' or request_user.is_superuser:
|
||||
self.fields["account"].queryset = Account.objects.filter()
|
||||
self.fields["account"].queryset = Account.objects.filter(status="open")
|
||||
|
||||
self.fields["contacts"].queryset = Contact.objects.filter()
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Status{% if form.status.field.required %}<span
|
||||
class="error">*</span>{% endif %}</label>
|
||||
class="error_marker" style="color:red">*</span>{% endif %}</label>
|
||||
{{ form.status }}
|
||||
<span class="error" id="id__status">{{ form.status.errors }}</span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
<span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{% url 'tasks:task_edit' task.id %}">Edit</a></li>
|
||||
<li><a href="{% url 'tasks:task_delete' task.id %}">Delete</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -116,16 +116,22 @@
|
|||
{% if task.due_date < today and task.status != 'completed' %}
|
||||
<tr id="task_{{task.id}}" class="text-center due-date">
|
||||
<td scope="row">{{ forloop.counter }}</td>
|
||||
<td>{% if task.title %}<a href="{% url 'tasks:task_detail' task.id %}">{{ task.title }}</a>{% endif %}
|
||||
<td>{% if task.title %}<a href="{% url 'tasks:task_detail' task.id %}"
|
||||
style="color:red;">{{ task.title }}</a>{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if document.created_by.profile_pic %}
|
||||
{% thumbnail document.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
{% if task.created_by %}
|
||||
{% if task.created_by.profile_pic %}
|
||||
{% thumbnail task.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
|
||||
title="{{ document.created_by }}">
|
||||
title="{{ task.created_by }}" style="border-radius: 50%" />
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}" title="{{ document.created_by }}" width="40" height="40">
|
||||
<img src="{% static 'images/user.png' %}" alt="Micro profile pic"
|
||||
style="width: 40px;height: 40px;border-radius: 50%;" title="{{ task.created_by }}" />
|
||||
{% endif %}
|
||||
{% else %}
|
||||
None
|
||||
{% endif %}
|
||||
</td>
|
||||
<!-- <td>{{document.created_on}}</td> -->
|
||||
|
|
@ -165,13 +171,18 @@
|
|||
<td>{% if task.title %}<a href="{% url 'tasks:task_detail' task.id %}">{{ task.title }}</a>{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if document.created_by.profile_pic %}
|
||||
{% thumbnail document.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
{% if task.created_by %}
|
||||
{% if task.created_by.profile_pic %}
|
||||
{% thumbnail task.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
|
||||
title="{{ document.created_by }}">
|
||||
title="{{ task.created_by }}" style="border-radius: 50%" />
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}" title="{{ document.created_by }}" width="40" height="40">
|
||||
<img src="{% static 'images/user.png' %}" alt="Micro profile pic"
|
||||
style="width: 40px;height: 40px;border-radius: 50%;" title="{{ task.created_by }}" />
|
||||
{% endif %}
|
||||
{% else %}
|
||||
None
|
||||
{% endif %}
|
||||
</td>
|
||||
<!-- <td>{{document.created_on}}</td> -->
|
||||
|
|
@ -211,13 +222,18 @@
|
|||
<td>{% if task.title %}<a href="{% url 'tasks:task_detail' task.id %}">{{ task.title }}</a>{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if document.created_by.profile_pic %}
|
||||
{% thumbnail document.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
{% if task.created_by %}
|
||||
{% if task.created_by.profile_pic %}
|
||||
{% thumbnail task.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
|
||||
title="{{ document.created_by }}">
|
||||
title="{{ task.created_by }}" style="border-radius: 50%" />
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}" title="{{ document.created_by }}" width="40" height="40">
|
||||
<img src="{% static 'images/user.png' %}" alt="Micro profile pic"
|
||||
style="width: 40px;height: 40px;border-radius: 50%;" title="{{ task.created_by }}" />
|
||||
{% endif %}
|
||||
{% else %}
|
||||
None
|
||||
{% endif %}
|
||||
</td>
|
||||
<!-- <td>{{document.created_on}}</td> -->
|
||||
|
|
|
|||
|
|
@ -18,9 +18,12 @@ from tasks.celery_tasks import send_email
|
|||
from tasks.forms import TaskAttachmentForm, TaskCommentForm, TaskForm
|
||||
from tasks.models import Task
|
||||
from tasks.utils import *
|
||||
from common.access_decorators_mixins import (
|
||||
sales_access_required, marketing_access_required, SalesAccessRequiredMixin, MarketingAccessRequiredMixin)
|
||||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def tasks_list(request):
|
||||
if request.method == 'GET':
|
||||
|
||||
|
|
@ -56,6 +59,7 @@ def tasks_list(request):
|
|||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def task_create(request):
|
||||
if request.method == 'GET':
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser:
|
||||
|
|
@ -83,6 +87,7 @@ def task_create(request):
|
|||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def task_detail(request, task_id):
|
||||
|
||||
task = get_object_or_404(Task, pk=task_id)
|
||||
|
|
@ -108,6 +113,7 @@ def task_detail(request, task_id):
|
|||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def task_edit(request, task_id):
|
||||
task_obj = get_object_or_404(Task, pk=task_id)
|
||||
|
||||
|
|
@ -143,6 +149,7 @@ def task_edit(request, task_id):
|
|||
|
||||
|
||||
@login_required
|
||||
@sales_access_required
|
||||
def task_delete(request, task_id):
|
||||
task_obj = get_object_or_404(Task, pk=task_id)
|
||||
|
||||
|
|
|
|||
0
teams/__init__.py
Normal file
0
teams/__init__.py
Normal file
3
teams/admin.py
Normal file
3
teams/admin.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
5
teams/apps.py
Normal file
5
teams/apps.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class TeamsConfig(AppConfig):
|
||||
name = 'teams'
|
||||
19
teams/forms.py
Normal file
19
teams/forms.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from django import forms
|
||||
from teams.models import Teams
|
||||
|
||||
|
||||
class TeamForm(forms.ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(TeamForm, self).__init__(*args, **kwargs)
|
||||
|
||||
for field in self.fields.values():
|
||||
field.widget.attrs = {"class": "form-control"}
|
||||
|
||||
self.fields['name'].required = True
|
||||
self.fields['description'].required = True
|
||||
self.fields['users'].required = False
|
||||
|
||||
class Meta:
|
||||
model = Teams
|
||||
fields = ('name', 'description', 'users',)
|
||||
25
teams/migrations/0001_initial.py
Normal file
25
teams/migrations/0001_initial.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# Generated by Django 2.2.2 on 2019-06-24 06:27
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Teams',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('description', models.TextField()),
|
||||
('users', models.ManyToManyField(related_name='user_teams', to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
||||
28
teams/migrations/0002_auto_20190624_1250.py
Normal file
28
teams/migrations/0002_auto_20190624_1250.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Generated by Django 2.2.2 on 2019-06-24 07:20
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('teams', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='teams',
|
||||
name='created_by',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='teams_created', to=settings.AUTH_USER_MODEL),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='teams',
|
||||
name='created_on',
|
||||
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now, verbose_name='Created on'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
||||
0
teams/migrations/__init__.py
Normal file
0
teams/migrations/__init__.py
Normal file
18
teams/models.py
Normal file
18
teams/models.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
from django.db import models
|
||||
from common.models import User
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
class Teams(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
description = models.TextField()
|
||||
users = models.ManyToManyField(User, related_name='user_teams')
|
||||
created_on = models.DateTimeField(_("Created on"), auto_now_add=True)
|
||||
created_by = models.ForeignKey(
|
||||
User, related_name='teams_created', blank=True, null=True, on_delete=models.SET_NULL)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
ordering = ('id',)
|
||||
103
teams/templates/team_create.html
Normal file
103
teams/templates/team_create.html
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
{% extends 'sales/base.html' %}
|
||||
{% load staticfiles %}
|
||||
{% block extralinks %}
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
|
||||
{% endblock %}
|
||||
|
||||
{% block breadcrumb %}
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{% url 'teams:teams_list' %}">Teams</a></li>
|
||||
<li class="breadcrumb-item">{% if team_obj %}Edit{% else %}Create{% endif %}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
{% endblock breadcrumb %}
|
||||
{% block content %}
|
||||
<form id="add_form" method="POST" action="" novalidate>
|
||||
<div class="overview_form_block row marl justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="card-title text-center">
|
||||
{% if team_obj %}EDIT{% else %}CREATE{% endif %} TEAM
|
||||
</div>
|
||||
<div class="row marl">
|
||||
<div class="col-md-12">
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="id_firstname">Name {% if form.name.field.required %}<span class="error_marker"
|
||||
style="color:red">*</span>{% endif %}</label>
|
||||
{{form.name}}
|
||||
</div>
|
||||
<span class="error" id="id__name"></span>
|
||||
</div>
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="id_firstname">Description {% if form.description.field.required %}<span
|
||||
class="error_marker" style="color:red">*</span>{% endif %}</label>
|
||||
{{form.description}}
|
||||
</div>
|
||||
<span class="error" id="id__description"></span>
|
||||
</div>
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="id_firstname">Assign Users {% if form.users.field.required %}<span class="error_marker"
|
||||
style="color:red">*</span>{% endif %}</label>
|
||||
{{form.users}}
|
||||
</div>
|
||||
<span class="error" id="id__users"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row marl buttons_row form_btn_row text-center">
|
||||
<button class="btn btn-default save" type="submit" id="submit_btn">Save</button>
|
||||
<a href="{% url 'teams:teams_list' %}" class="btn btn-default clear" id="create_doc_cancel">Cancel</a>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
{% endblock content %}
|
||||
{% block js_block %}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
|
||||
<script src="https://malsup.github.io/jquery.form.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#id_users').select2();
|
||||
});
|
||||
|
||||
|
||||
$('form#add_form').ajaxForm({
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
url: ".",
|
||||
data: $('#add_form').serialize(),
|
||||
beforeSubmit: disableButton,
|
||||
success: function (data) {
|
||||
if (data.error) {
|
||||
$('.error').html('')
|
||||
for (var key in data.errors) {
|
||||
$('#id__' + key).html("<p>" + data.errors[key][0] + "</p>");
|
||||
};
|
||||
$('#submit_btn').removeAttr('disabled')
|
||||
}
|
||||
else {
|
||||
window.location = data.success_url;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function disableButton() {
|
||||
// $('#progress_bar').show()
|
||||
$('#submit_btn').attr('disabled', 'disabled')
|
||||
}
|
||||
|
||||
</script>
|
||||
{% endblock js_block %}
|
||||
88
teams/templates/team_detail.html
Normal file
88
teams/templates/team_detail.html
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
{% extends 'sales/base.html' %}
|
||||
{% load staticfiles %}
|
||||
{% load thumbnail %}
|
||||
{% block content%}
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="{% url 'teams:teams_list' %}">Teams</a></li>
|
||||
<li class="breadcrumb-item" active>View</li>
|
||||
</ol>
|
||||
</nav>
|
||||
<!-- OPPORTUNITY VIEW STARTS -->
|
||||
<div class="main_container" id="maincontainer">
|
||||
<div class="overview_form_block row marl justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card">
|
||||
<div class="card-body" id="datashow">
|
||||
<div class="panel-heading card-title view-pad text-center">
|
||||
<h5>
|
||||
Team
|
||||
</h5>
|
||||
<a href="{% url 'teams:team_edit' team_obj.id %}" class="btn btn-success edit">Edit</a>
|
||||
</div>
|
||||
<div class="row marl no-gutters">
|
||||
<div class="col-md-8">
|
||||
{% if team_obj.name %}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="contact_field_label" for="id_title" data-name="title">Name</label>
|
||||
<div class="contact_field" id="doc_title" data-name="name">{{ team_obj.name }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if team_obj.description %}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="contact_field_label" for="id_status" data-name="status">Description</label>
|
||||
<div class="contact_field" id="doc_status" data-name="status">
|
||||
{{ team_obj.description }} </div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="contact_field_label" for="id_status" data-name="status">Assigned To</label>
|
||||
<br>
|
||||
{% with users=team_obj.users.all %}
|
||||
{% for user in users %}
|
||||
{% if user.profile_pic %}
|
||||
{% thumbnail user.profile_pic "40x40" crop="center" as im %}
|
||||
<span>
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" title="{{ user.email }}">
|
||||
</span>
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<span>
|
||||
<img src="{% static 'images/user.png' %}" title="{{ user.email }}" width="40" height="40">
|
||||
</span>
|
||||
{% endif %}
|
||||
{% empty %}
|
||||
None
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group mt-3">
|
||||
<label class="contact_field_label" for="id_created_by" data-name="created_by">Created By</label>
|
||||
<div class="contact_field" id="created_by" data-name="created_by">
|
||||
{{ team_obj.created_by }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="contact_field_label" for="id_created_on" data-name="created_on">Created On</label>
|
||||
<div class="contact_field" id="created_on" data-name="created_on">
|
||||
{{ team_obj.created_on }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- OPPORTUNITY VIEW ENDS -->
|
||||
{% endblock %}
|
||||
232
teams/templates/teams.html
Normal file
232
teams/templates/teams.html
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
{% extends 'sales/base.html' %}
|
||||
{% load staticfiles %}
|
||||
{% load paginate %}
|
||||
{% load thumbnail %}
|
||||
{% 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">
|
||||
<!-- heading_create starts here -->
|
||||
<div class="row marl">
|
||||
<div class="col-lg-12 text-right">
|
||||
<span class="d-inline"><a class="primary_btn" href="{% url 'teams:team_create'%}"><i class="fa fa-plus"></i>
|
||||
Add New
|
||||
Team</a></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- heading_create ends here -->
|
||||
<div class="filter_row list_filter_row row marl">
|
||||
<div class="col-md-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form id="leads_filter" action="" method="POST">
|
||||
<div class="card-body ">
|
||||
<div class="card-title">Filters</div>
|
||||
<div class="row marl">
|
||||
<div class="filter_col col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Team Name</label>
|
||||
<input type="text" class="form-control" placeholder="Team Name"
|
||||
name="team_name" value="{{request.POST.team_name}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-2">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Created By</label>
|
||||
<select name="created_by" id="" class="assigned_users_ form-control">
|
||||
<option value="">
|
||||
------------------</option>
|
||||
{% for user in users %}
|
||||
<option value="{{user.id}}" {% if user.id|slugify == request.POST.created_by %} selected=""
|
||||
{% endif %}>
|
||||
{{user.email}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</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|slugify in assigned_to %} selected="" {% endif %}>
|
||||
{{user.email}}</option>
|
||||
{% endfor %}
|
||||
</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>
|
||||
<a href="{% url 'teams:teams_list' %}" class="btn btn-default clear">Clear</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-12 col-xl-12">
|
||||
<div class="table_container_row row marl no-gutters">
|
||||
<div class="col-md-12">
|
||||
<!-- <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 ({{open_leads|length}})</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 ({{close_leads|length}})</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">Teams - {% if show_pageitems %}
|
||||
{% show_pageitems %}{% else %}
|
||||
{{ teams|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 teams|length > 0 %}
|
||||
<tr>
|
||||
<th width="5%">ID</th>
|
||||
<th width="5%">Team Name</th>
|
||||
<th width="15%">Team Description</th>
|
||||
<th width="10%">Assigned To</th>
|
||||
<th width="5%">Created by</th>
|
||||
<th width="5%">Created On</th>
|
||||
<th width="10%">Actions</th>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if per_page %}
|
||||
{% paginate per_page teams %}
|
||||
{% else %}
|
||||
{% paginate 10 teams %}
|
||||
{% endif %}
|
||||
{% for team in teams %}
|
||||
<tr class="text-center">
|
||||
<td scope="row">{{ forloop.counter }}</td>
|
||||
<td><a href="{% url 'teams:team_detail' team.id %}">
|
||||
{{ team.name }} </a></td>
|
||||
<td>{{ team.description }} </td>
|
||||
<td>
|
||||
{% with users=team.users.all %}
|
||||
{% for user in users %}
|
||||
{% if user.profile_pic %}
|
||||
{% thumbnail user.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
|
||||
title="{{ user.email }}">
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}" title="{{ user.email }}" width="40" height="40">
|
||||
{% endif %}
|
||||
{% empty %}
|
||||
None
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
<td>
|
||||
{% if team.created_by %}
|
||||
{% if team.created_by.profile_pic %}
|
||||
{% thumbnail team.created_by.profile_pic "40x40" crop="center" as im %}
|
||||
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"
|
||||
title="{{ team.created_by }}" style="border-radius: 50%" />
|
||||
{% endthumbnail %}
|
||||
{% else %}
|
||||
<img src="{% static 'images/user.png' %}"
|
||||
style="width: 40px;height: 40px;border-radius: 50%;" title="{{ team.created_by }}" />
|
||||
{% endif %}
|
||||
{% else %}
|
||||
None
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ team.created_on|date:'d-m-Y' }}</td>
|
||||
<td class="actions">
|
||||
{% if request.user == team.created_by or request.user.role == 'ADMIN' or reques.user.is_superuser %}
|
||||
<a href="{% url 'teams:team_edit' team.id %}" class="btn btn-success edit"><i
|
||||
class="fas fa-pencil-alt"></i></a>
|
||||
<a href="{% url 'teams:team_delete' team.id %}"
|
||||
class="btn btn-danger delete remove_document"><i class="fas fa-trash-alt"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{%ifequal teams|length 0%}
|
||||
<h6 class="text-center">No Teams Found</h6>
|
||||
{%endifequal%}
|
||||
<div class="marl row text-center">
|
||||
{% show_pages %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% 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 () {
|
||||
$('.assigned_users').select2();
|
||||
$('#id_tag').select2();
|
||||
$(".filter_toggle").click(function () {
|
||||
$(".list_filter_row").toggle();
|
||||
});
|
||||
});
|
||||
|
||||
search = "{{search}}"
|
||||
|
||||
if (search == 'True') {
|
||||
$(".list_filter_row").show();
|
||||
}
|
||||
|
||||
$("#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')
|
||||
if (!confirm('Are you sure you want to delete?'))
|
||||
return;
|
||||
window.location = $(this).attr('href')
|
||||
});
|
||||
|
||||
$("a[rel='page']").click(function (e) {
|
||||
e.preventDefault();
|
||||
$('#leads_filter').attr("action", $(this).attr("href"));
|
||||
$('#leads_filter').submit();
|
||||
});
|
||||
</script>
|
||||
{% endblock js_block %}
|
||||
3
teams/tests.py
Normal file
3
teams/tests.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
17
teams/urls.py
Normal file
17
teams/urls.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from django.urls import path
|
||||
from teams.views import (
|
||||
teams_list, team_create, team_edit, team_delete, team_detail
|
||||
)
|
||||
|
||||
|
||||
app_name = 'teams'
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('', teams_list, name='teams_list'),
|
||||
path('create/', team_create, name='team_create'),
|
||||
path('edit/<int:team_id>/', team_edit, name='team_edit'),
|
||||
path('delete/<int:team_id>/', team_delete, name='team_delete'),
|
||||
path('detail/<int:team_id>/', team_detail, name='team_detail'),
|
||||
|
||||
]
|
||||
455
teams/views.py
Normal file
455
teams/views.py
Normal file
|
|
@ -0,0 +1,455 @@
|
|||
from datetime import date, datetime, timedelta
|
||||
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.sites.shortcuts import get_current_site
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.db.models import Q
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
from django.shortcuts import get_object_or_404, redirect, render, reverse
|
||||
from django.views.generic import (CreateView, DeleteView, DetailView, FormView,
|
||||
TemplateView, UpdateView, View)
|
||||
|
||||
from common.models import User
|
||||
from teams.models import Teams
|
||||
from teams.forms import TeamForm
|
||||
|
||||
|
||||
@login_required
|
||||
def teams_list(request):
|
||||
context = {}
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser:
|
||||
queryset = Teams.objects.all()
|
||||
users = User.objects.all()
|
||||
context['teams'] = queryset
|
||||
context['users'] = users
|
||||
else:
|
||||
raise PermissionDenied
|
||||
|
||||
if request.method == 'GET':
|
||||
return render(request, 'teams.html', context)
|
||||
if request.method == 'POST':
|
||||
if request.POST.get('team_name'):
|
||||
queryset = queryset.filter(
|
||||
name__icontains=request.POST.get('team_name'))
|
||||
if request.POST.get('created_by'):
|
||||
queryset = queryset.filter(
|
||||
created_by=request.POST.get('created_by'))
|
||||
if request.POST.get('assigned_to'):
|
||||
queryset = queryset.filter(
|
||||
users__id__in=request.POST.getlist('assigned_to'))
|
||||
context['assigned_to'] = request.POST.getlist('assigned_to')
|
||||
context['teams'] = queryset
|
||||
return render(request, 'teams.html', context)
|
||||
|
||||
|
||||
@login_required
|
||||
def team_create(request):
|
||||
context = {}
|
||||
if request.user.role == 'ADMIN' or request.user.is_superuser:
|
||||
teams = Teams.objects.all()
|
||||
context['teams'] = teams
|
||||
else:
|
||||
raise PermissionDenied
|
||||
|
||||
if request.method == 'GET':
|
||||
form = TeamForm()
|
||||
context['form'] = TeamForm()
|
||||
return render(request, 'team_create.html', context)
|
||||
|
||||
if request.method == 'POST':
|
||||
form = TeamForm(request.POST)
|
||||
if form.is_valid():
|
||||
task_obj = form.save(commit=False)
|
||||
task_obj.created_by=request.user
|
||||
task_obj.save()
|
||||
form.save_m2m()
|
||||
return JsonResponse({'error': False, 'success_url': reverse('teams:teams_list')})
|
||||
else:
|
||||
return JsonResponse({'error': True, 'errors': form.errors})
|
||||
|
||||
|
||||
@login_required
|
||||
def team_detail(request, team_id):
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser):
|
||||
raise PermissionDenied
|
||||
team_obj = get_object_or_404(Teams, pk=team_id)
|
||||
context = {}
|
||||
|
||||
if request.method == 'GET':
|
||||
context['team_obj'] = team_obj
|
||||
return render(request, 'team_detail.html', context)
|
||||
|
||||
|
||||
@login_required
|
||||
def team_edit(request, team_id):
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser):
|
||||
raise PermissionDenied
|
||||
team_obj = get_object_or_404(Teams, pk=team_id)
|
||||
context = {}
|
||||
|
||||
if request.method == 'GET':
|
||||
form = TeamForm(instance=team_obj)
|
||||
context['form'] = form
|
||||
return render(request, 'team_create.html', context)
|
||||
|
||||
if request.method == 'POST':
|
||||
form = TeamForm(request.POST, instance=team_obj)
|
||||
if form.is_valid():
|
||||
task_obj = form.save(commit=False)
|
||||
task_obj.save()
|
||||
form.save_m2m()
|
||||
return JsonResponse({'error': False, 'success_url': reverse('teams:teams_list')})
|
||||
else:
|
||||
return JsonResponse({'error': True, 'errors': form.errors})
|
||||
|
||||
|
||||
@login_required
|
||||
def team_delete(request, team_id):
|
||||
if not (request.user.role == 'ADMIN' or request.user.is_superuser):
|
||||
raise PermissionDenied
|
||||
team_obj = get_object_or_404(Teams, pk=team_id)
|
||||
context = {}
|
||||
|
||||
if request.method == 'GET':
|
||||
team_obj.delete()
|
||||
return redirect('teams:teams_list')
|
||||
|
||||
|
||||
# @login_required
|
||||
# def events_list(request):
|
||||
|
||||
# if request.user.role == 'ADMIN' or request.user.is_superuser:
|
||||
# users = User.objects.all()
|
||||
# elif request.user.google.all():
|
||||
# users = User.objects.none()
|
||||
# elif request.user.role == 'USER':
|
||||
# users = User.objects.filter(role='ADMIN')
|
||||
|
||||
# if request.method == 'GET':
|
||||
# context = {}
|
||||
# if request.user.role == 'ADMIN' or request.user.is_superuser:
|
||||
# events = Event.objects.all().distinct()
|
||||
# else:
|
||||
# events = Event.objects.filter(
|
||||
# Q(created_by=request.user) | Q(assigned_to=request.user)).distinct()
|
||||
# context['events'] = events.order_by('id')
|
||||
# # context['status'] = status
|
||||
# context['users'] = users
|
||||
# return render(request, 'events_list.html', context)
|
||||
|
||||
# if request.method == 'POST':
|
||||
# context = {}
|
||||
# # context['status'] = status
|
||||
# context['users'] = users
|
||||
# events = Event.objects.filter()
|
||||
# if request.user.role == 'ADMIN' or request.user.is_superuser:
|
||||
# events = events
|
||||
# else:
|
||||
# events = events.filter(
|
||||
# Q(created_by=request.user) | Q(assigned_to=request.user)).distinct()
|
||||
|
||||
# if request.POST.get('event_name', None):
|
||||
# events = events.filter(name__icontains=request.POST.get('event_name'))
|
||||
|
||||
# if request.POST.get('created_by', None):
|
||||
# events = events.filter(
|
||||
# created_by__id=request.POST.get('created_by'))
|
||||
|
||||
# if request.POST.getlist('assigned_to', None):
|
||||
# events = events.filter(
|
||||
# assigned_to__in=request.POST.getlist('assigned_to'))
|
||||
# context['assigned_to'] = request.POST.getlist('assigned_to')
|
||||
|
||||
# if request.POST.get('date_of_meeting', None):
|
||||
# events = events.filter(date_of_meeting=request.POST.get('date_of_meeting'))
|
||||
|
||||
# context['events'] = events.distinct().order_by('id')
|
||||
# return render(request, 'events_list.html', context)
|
||||
|
||||
|
||||
# @login_required
|
||||
# def event_create(request):
|
||||
# if request.method == 'GET':
|
||||
# context = {}
|
||||
# context["form"] = EventForm(request_user=request.user)
|
||||
# return render(request, 'event_create.html', context)
|
||||
|
||||
# if request.method == 'POST':
|
||||
# form = EventForm(request.POST, request_user=request.user)
|
||||
# if form.is_valid():
|
||||
# start_date = form.cleaned_data.get('start_date')
|
||||
# end_date = form.cleaned_data.get('end_date')
|
||||
# # recurring_days
|
||||
# recurring_days = request.POST.getlist('recurring_days')
|
||||
# if form.cleaned_data.get('event_type') == 'Non-Recurring':
|
||||
# event = form.save(commit=False)
|
||||
# event.date_of_meeting = start_date
|
||||
# event.created_by = request.user
|
||||
# event.save()
|
||||
# form.save_m2m()
|
||||
# send_email.delay(event.id, domain=request.get_host(), protocol=request.scheme)
|
||||
|
||||
# if form.cleaned_data.get('event_type') == 'Recurring':
|
||||
# delta = end_date - start_date
|
||||
# all_dates = []
|
||||
# required_dates = []
|
||||
|
||||
# for day in range(delta.days + 1):
|
||||
# each_date = (start_date + timedelta(days=day))
|
||||
# if each_date.strftime("%A") in recurring_days:
|
||||
# required_dates.append(each_date)
|
||||
|
||||
# for each in required_dates:
|
||||
# each = datetime.strptime(str(each), '%Y-%m-%d').date()
|
||||
# data = form.cleaned_data
|
||||
|
||||
# event = Event.objects.create(
|
||||
# created_by=request.user, start_date=start_date, end_date=end_date,
|
||||
# name=data['name'], event_type=data['event_type'],
|
||||
# description=data['description'], start_time=data['start_time'],
|
||||
# end_time=data['end_time'], date_of_meeting=each
|
||||
# )
|
||||
# event.contacts.add(*request.POST.getlist('contacts'))
|
||||
# event.assigned_to.add(*request.POST.getlist('assigned_to'))
|
||||
# send_email.delay(event.id, domain=request.get_host(), protocol=request.scheme)
|
||||
|
||||
# return JsonResponse({'error': False, 'success_url': reverse('events:events_list')})
|
||||
# else:
|
||||
# return JsonResponse({'error': True, 'errors': form.errors, })
|
||||
|
||||
|
||||
# @login_required
|
||||
# def event_detail_view(request, event_id):
|
||||
# event = get_object_or_404(Event, pk=event_id)
|
||||
# if not (request.user.role == 'ADMIN' or request.user.is_superuser or event.created_by == request.user or request.user in event.assigned_to.all()):
|
||||
# raise PermissionDenied
|
||||
|
||||
# if request.method == 'GET':
|
||||
# context = {}
|
||||
# context['event'] = event
|
||||
# context['attachments'] = event.events_attachment.all()
|
||||
# context['comments'] = event.events_comments.all()
|
||||
# if request.user.is_superuser or request.user.role == 'ADMIN':
|
||||
# context['users_mention'] = list(
|
||||
# User.objects.all().values('username'))
|
||||
# elif request.user != event.created_by:
|
||||
# context['users_mention'] = [
|
||||
# {'username': event.created_by.username}]
|
||||
# else:
|
||||
# context['users_mention'] = list(
|
||||
# event.assigned_to.all().values('username'))
|
||||
# return render(request, 'event_detail.html', context)
|
||||
|
||||
|
||||
# @login_required
|
||||
# def event_update(request, event_id):
|
||||
# event_obj = get_object_or_404(Event, pk=event_id)
|
||||
# if not (request.user.role == 'ADMIN' or request.user.is_superuser or event_obj.created_by == request.user or request.user in event_obj.assigned_to.all()):
|
||||
# raise PermissionDenied
|
||||
|
||||
# if request.method == 'GET':
|
||||
# context = {}
|
||||
# context["event_obj"] = event_obj
|
||||
# context["form"] = EventForm(
|
||||
# instance=event_obj, request_user=request.user)
|
||||
# selected_recurring_days = Event.objects.filter(
|
||||
# name=event_obj.name).values_list('date_of_meeting', flat=True)
|
||||
# selected_recurring_days = [day.strftime(
|
||||
# '%A') for day in selected_recurring_days]
|
||||
# context['selected_recurring_days'] = selected_recurring_days
|
||||
# return render(request, 'event_create.html', context)
|
||||
|
||||
# if request.method == 'POST':
|
||||
# form = EventForm(request.POST, instance=event_obj,
|
||||
# request_user=request.user)
|
||||
# if form.is_valid():
|
||||
# start_date = form.cleaned_data.get('start_date')
|
||||
# end_date = form.cleaned_data.get('end_date')
|
||||
# # recurring_days
|
||||
# # recurring_days = request.POST.getlist('days')
|
||||
|
||||
# if form.cleaned_data.get('event_type') == 'Non-Recurring':
|
||||
# event = form.save(commit=False)
|
||||
# event.date_of_meeting = start_date
|
||||
# # event.created_by = request.user
|
||||
# event.save()
|
||||
# form.save_m2m()
|
||||
# send_email.delay(event.id, domain=request.get_host(), protocol=request.scheme)
|
||||
|
||||
|
||||
# if form.cleaned_data.get('event_type') == 'Recurring':
|
||||
# event = form.save(commit=False)
|
||||
# event.save()
|
||||
# form.save_m2m()
|
||||
# send_email.delay(event.id, domain=request.get_host(), protocol=request.scheme)
|
||||
|
||||
# # event.contacts.add(*request.POST.getlist('contacts'))
|
||||
# # event.assigned_to.add(*request.POST.getlist('assigned_to'))
|
||||
|
||||
# return JsonResponse({'error': False, 'success_url': reverse('events:events_list')})
|
||||
# else:
|
||||
# return JsonResponse({'error': True, 'errors': form.errors, })
|
||||
|
||||
|
||||
# @login_required
|
||||
# def event_delete(request, event_id):
|
||||
# event = get_object_or_404(Event, pk=event_id)
|
||||
# if not (request.user.role == 'ADMIN' or request.user.is_superuser or event.created_by == request.user):
|
||||
# raise PermissionDenied
|
||||
|
||||
# event.delete()
|
||||
# return redirect('events:events_list')
|
||||
|
||||
|
||||
# class AddCommentView(LoginRequiredMixin, CreateView):
|
||||
# model = Comment
|
||||
# form_class = EventCommentForm
|
||||
# http_method_names = ["post"]
|
||||
|
||||
# def post(self, request, *args, **kwargs):
|
||||
# self.object = None
|
||||
# self.event = get_object_or_404(
|
||||
# Event, id=request.POST.get('event_id'))
|
||||
# if (
|
||||
# request.user == self.event.created_by or request.user.is_superuser or
|
||||
# request.user.role == 'ADMIN'
|
||||
# ):
|
||||
# form = self.get_form()
|
||||
# if form.is_valid():
|
||||
# return self.form_valid(form)
|
||||
# return self.form_invalid(form)
|
||||
|
||||
# data = {
|
||||
# 'error': "You don't have permission to comment for this account."}
|
||||
# return JsonResponse(data)
|
||||
|
||||
# def form_valid(self, form):
|
||||
# comment = form.save(commit=False)
|
||||
# comment.commented_by = self.request.user
|
||||
# comment.event = self.event
|
||||
# comment.save()
|
||||
# comment_id = comment.id
|
||||
# current_site = get_current_site(self.request)
|
||||
# send_email_user_mentions.delay(comment_id, 'events', domain=current_site.domain,
|
||||
# protocol=self.request.scheme)
|
||||
# return JsonResponse({
|
||||
# "comment_id": comment.id, "comment": comment.comment,
|
||||
# "commented_on": comment.commented_on,
|
||||
# "commented_by": comment.commented_by.email
|
||||
# })
|
||||
|
||||
# def form_invalid(self, form):
|
||||
# return JsonResponse({"error": form['comment'].errors})
|
||||
|
||||
|
||||
# class UpdateCommentView(LoginRequiredMixin, View):
|
||||
# http_method_names = ["post"]
|
||||
|
||||
# def post(self, request, *args, **kwargs):
|
||||
# self.comment_obj = get_object_or_404(
|
||||
# Comment, id=request.POST.get("commentid"))
|
||||
# if request.user == self.comment_obj.commented_by:
|
||||
# form = EventCommentForm(request.POST, instance=self.comment_obj)
|
||||
# if form.is_valid():
|
||||
# return self.form_valid(form)
|
||||
|
||||
# return self.form_invalid(form)
|
||||
|
||||
# data = {'error': "You don't have permission to edit this comment."}
|
||||
# return JsonResponse(data)
|
||||
|
||||
# def form_valid(self, form):
|
||||
# self.comment_obj.comment = form.cleaned_data.get("comment")
|
||||
# self.comment_obj.save(update_fields=["comment"])
|
||||
# comment_id = self.comment_obj.id
|
||||
# current_site = get_current_site(self.request)
|
||||
# send_email_user_mentions.delay(comment_id, 'events', domain=current_site.domain,
|
||||
# protocol=self.request.scheme)
|
||||
# return JsonResponse({
|
||||
# "comment_id": self.comment_obj.id,
|
||||
# "comment": self.comment_obj.comment,
|
||||
# })
|
||||
|
||||
# def form_invalid(self, form):
|
||||
# return JsonResponse({"error": form['comment'].errors})
|
||||
|
||||
|
||||
# class DeleteCommentView(LoginRequiredMixin, View):
|
||||
|
||||
# def post(self, request, *args, **kwargs):
|
||||
# self.object = get_object_or_404(
|
||||
# Comment, id=request.POST.get("comment_id"))
|
||||
# if request.user == self.object.commented_by:
|
||||
# self.object.delete()
|
||||
# data = {"cid": request.POST.get("comment_id")}
|
||||
# return JsonResponse(data)
|
||||
|
||||
# data = {'error': "You don't have permission to delete this comment."}
|
||||
# return JsonResponse(data)
|
||||
|
||||
|
||||
# class AddAttachmentView(LoginRequiredMixin, CreateView):
|
||||
# model = Attachments
|
||||
# form_class = EventAttachmentForm
|
||||
# http_method_names = ["post"]
|
||||
|
||||
# def post(self, request, *args, **kwargs):
|
||||
# self.object = None
|
||||
# self.event = get_object_or_404(
|
||||
# Event, id=request.POST.get('event_id'))
|
||||
# if (
|
||||
# request.user == self.event.created_by or
|
||||
# request.user.is_superuser or
|
||||
# request.user.role == 'ADMIN'
|
||||
# ):
|
||||
# form = self.get_form()
|
||||
# if form.is_valid():
|
||||
# return self.form_valid(form)
|
||||
|
||||
# return self.form_invalid(form)
|
||||
|
||||
# data = {
|
||||
# 'error': "You don't have permission to add attachment \
|
||||
# for this account."}
|
||||
# return JsonResponse(data)
|
||||
|
||||
# def form_valid(self, form):
|
||||
# attachment = form.save(commit=False)
|
||||
# attachment.created_by = self.request.user
|
||||
# attachment.file_name = attachment.attachment.name
|
||||
# attachment.event = self.event
|
||||
# attachment.save()
|
||||
# return JsonResponse({
|
||||
# "attachment_id": attachment.id,
|
||||
# "attachment": attachment.file_name,
|
||||
# "attachment_url": attachment.attachment.url,
|
||||
# "download_url": reverse('common:download_attachment',
|
||||
# kwargs={'pk': attachment.id}),
|
||||
# "attachment_display": attachment.get_file_type_display(),
|
||||
# "created_on": attachment.created_on,
|
||||
# "created_by": attachment.created_by.email,
|
||||
# "file_type": attachment.file_type()
|
||||
# })
|
||||
|
||||
# def form_invalid(self, form):
|
||||
# return JsonResponse({"error": form['attachment'].errors})
|
||||
|
||||
|
||||
# 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.role == 'ADMIN'
|
||||
# ):
|
||||
# self.object.delete()
|
||||
# data = {"acd": request.POST.get("attachment_id")}
|
||||
# return JsonResponse(data)
|
||||
|
||||
# data = {
|
||||
# 'error': "You don't have permission to delete this attachment."}
|
||||
# return JsonResponse(data)
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
<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>
|
||||
GO back Home<a href="/"> CRM Sales</a> or <a href="/marketing"> CRM Marketing</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -3,26 +3,30 @@
|
|||
{% block main_menu %}
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<!-- add submenu for contacts-->
|
||||
<li class="nav-item"><a class="nav-link" id="marketing-dashboard" href="{% url 'marketing:dashboard' %}">Dashboard</a></li>
|
||||
{% if request.user.is_superuser or request.user.role == 'ADMIN' or request.user.has_marketing_access %}
|
||||
<li class="nav-item"><a class="nav-link" id="marketing-dashboard" href="{% url 'marketing:dashboard' %}">Dashboard</a>
|
||||
</li>
|
||||
<li class="nav-item mt-2 contact_class" id="contact">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
|
||||
style="box-shadow: none; color: #657b88">
|
||||
Contacts
|
||||
</button>
|
||||
<div class="dropdown-menu mt-2">
|
||||
<a class="dropdown-item contact-list" id="contact-list" href="{% url 'marketing:contact_lists' %}" >Contacts List</a>
|
||||
<!-- <div class="dropdown-divider"></div> -->
|
||||
<a class="dropdown-item contacts" id="contacts" href="{% url 'marketing:contacts_list' %}" >Contacts</a>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false" style="box-shadow: none; color: #657b88">
|
||||
Contacts
|
||||
</button>
|
||||
<div class="dropdown-menu mt-2">
|
||||
<a class="dropdown-item contact-list" id="contact-list" href="{% url 'marketing:contact_lists' %}">Contacts
|
||||
List</a>
|
||||
<!-- <div class="dropdown-divider"></div> -->
|
||||
<a class="dropdown-item contacts" id="contacts" href="{% url 'marketing:contacts_list' %}">Contacts</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</li>
|
||||
|
||||
<!-- <li class="nav-item"><a href="{% url 'marketing:contact_lists' %}" class="nav-link" id="contact_lists">Contacts</a>
|
||||
</li> -->
|
||||
<li class="nav-item"><a class="nav-link" id="email-templates" href="{% url 'marketing:email_template_list' %}">Email
|
||||
templates</a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="campaigns" href="{% url 'marketing:campaign_list' %}">Campaigns</a></li>
|
||||
{% endif %}
|
||||
<!-- <li class="nav-item"><a class="nav-link" id="leads" href="{% url 'leads:list' %}">Leads</a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="opportunities"href="{% url 'opportunities:list' %}">Opportunities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="cases" href="{% url 'cases:list' %}">Cases</a></li>
|
||||
|
|
|
|||
|
|
@ -41,19 +41,19 @@
|
|||
<div class="col-md-4">
|
||||
<div class="well">
|
||||
<span class="badge badge-success" style="font-size:16px;">Opened</span> <span
|
||||
class="label">{{read_contacts|length}}</span>
|
||||
class="label">{{campaign.get_all_emails_contacts_opened}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="well">
|
||||
<span class="badge badge-dark" style="font-size:16px;">Bounced</span> <span
|
||||
class="label">{{bounced_contacts|length}}</span>
|
||||
class="label">{{campaign.get_all_email_bounces_count}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="well">
|
||||
<span class="badge badge-secondary" style="font-size:16px;">Unsubscribed</span> <span
|
||||
class="label">{{unsubscribe_contacts|length}}</span>
|
||||
class="label">{{campaign.get_all_emails_unsubscribed_count}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
|
|
@ -153,7 +153,6 @@
|
|||
</div>
|
||||
<div class="table-responsive table-bordered">
|
||||
<table class="table">
|
||||
{% for contact in read_contacts|slice:"5" %}
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%">Name</th>
|
||||
|
|
@ -163,16 +162,21 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for contact in read_contacts|slice:"5" %}
|
||||
<tr>
|
||||
<td scope="row"><a href="{% url 'marketing:contact_detail' contact.id %}"
|
||||
class="anchor">{{contact.name}}</a></td>
|
||||
<td><a href="{% url 'marketing:contact_detail' contact.id %}"
|
||||
class="anchor">{{contact.email}}</a></td>
|
||||
{% with contacts=contact.contact_list.all %}
|
||||
{% for contact in contacts %}
|
||||
<td><a href="{% url 'marketing:contact_list_detail' contact.id %}"
|
||||
class="anchor">{{contact.name}} </a></td>
|
||||
{% endfor %}
|
||||
<td>
|
||||
{% for contact in contacts %}
|
||||
<div>
|
||||
<a href="{% url 'marketing:contact_list_detail' contact.id %}"
|
||||
class="anchor">{{contact.name}} </a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</td>
|
||||
{% endwith %}
|
||||
<!-- <td>
|
||||
<span class="badge badge-success">Subscribed</span>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,13 @@
|
|||
{% load staticfiles %}
|
||||
{% load common_tags %}
|
||||
{% load paginate %}
|
||||
{% block extralinks %}
|
||||
<style>
|
||||
.modebar{
|
||||
display: none
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
{{ block.super }}
|
||||
<div class="" style="">
|
||||
|
|
@ -53,6 +60,17 @@
|
|||
</div>
|
||||
<!-- count_blocks_row ends here -->
|
||||
<div class="open_sections row">
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="" id="graph">
|
||||
<!-- <a href="{% url 'marketing:contacts_list' %}">
|
||||
<div class="title">Contacts</div>
|
||||
<div class="count">{{contacts|length}}</div>
|
||||
</a> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-6 table_container_row">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
|
@ -70,7 +88,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for contact in contacts_list|slice:"10" %}
|
||||
{% for contact in contacts_list|slice:"5" %}
|
||||
<tr>
|
||||
<td><a href="{% url 'marketing:contact_list_detail' contact.id %}">{{contact.name}}</a>
|
||||
</td>
|
||||
|
|
@ -130,7 +148,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for campaign in campaigns|slice:"10" %}
|
||||
{% for campaign in campaigns|slice:"5" %}
|
||||
<tr>
|
||||
<td><a href="{% url 'marketing:campaign_details' campaign.id %}">{{campaign.title}}</a>
|
||||
</td>
|
||||
|
|
@ -155,17 +173,19 @@
|
|||
<div>
|
||||
<div>
|
||||
<span class="text-left" id="list_opp_users_">
|
||||
<a href="{% url 'marketing:contact_list_detail' contact.id %}">{{contact.name}}</a><span>
|
||||
<a
|
||||
href="{% url 'marketing:contact_list_detail' contact.id %}">{{contact.name}}</a><span>
|
||||
</div>
|
||||
{% empty %}
|
||||
<span class="text-left">None</span>
|
||||
{% endfor %}
|
||||
{% if contact|length > 3 %}
|
||||
{% if contacts_lists|length > 3 %}
|
||||
<div>
|
||||
<span style="color:white; background-color: #333; padding:0.15em; border-radius: 10%;"
|
||||
class="text-left ml-1" id="list_opp_users">{{contact|length|subtract:'3'}}<span>
|
||||
<a href="{% url 'marketing:campaign_details' campaign.id %}" style="color:white;">
|
||||
<span class="text-left" id="list_tag">{{contacts_lists|length|subtract:'3'}}<span>
|
||||
more
|
||||
</span></span>
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
|
@ -192,6 +212,7 @@
|
|||
|
||||
{% endblock %}
|
||||
{% block js_block %}
|
||||
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function () {
|
||||
|
|
@ -209,7 +230,83 @@
|
|||
url = url + "?tag=" + $(this).attr('data-link')
|
||||
window.location.href = url;
|
||||
});
|
||||
|
||||
{% if campaigns|length %}
|
||||
|
||||
var trace1 = {
|
||||
// x: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
// y: [20, 14, 25, 16, 18, 22, 19, 15, 12, 16, 14, 17],
|
||||
x:{{x_axis_titles|safe}},
|
||||
y:{{y_axis_unsubscribed}},
|
||||
type: 'bar',
|
||||
name: 'Unsubscribed',
|
||||
marker: {
|
||||
color: 'rgb(49,130,189)',
|
||||
opacity: 0.7
|
||||
}
|
||||
};
|
||||
|
||||
var trace2 = {
|
||||
// x: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
// y: [19, 14, 22, 14, 16, 19, 15, 14, 10, 12, 12, 16],
|
||||
x:{{x_axis_titles|safe}},
|
||||
y:{{y_axis_bounces}},
|
||||
type: 'bar',
|
||||
name: 'Bounces',
|
||||
marker: {
|
||||
color: '#e65c00',
|
||||
opacity: 0.5
|
||||
}
|
||||
};
|
||||
|
||||
var trace3 = {
|
||||
// x: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
// y: [19, 14, 22, 14, 16, 19, 15, 14, 10, 12, 12, 16],
|
||||
x:{{x_axis_titles|safe}},
|
||||
y:{{y_axis_subscribed}},
|
||||
type: 'bar',
|
||||
name: 'Subscribed',
|
||||
marker: {
|
||||
color: '#00cc00',
|
||||
opacity: 0.5
|
||||
}
|
||||
};
|
||||
|
||||
var trace4 = {
|
||||
// x: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
// y: [19, 14, 22, 14, 16, 19, 15, 14, 10, 12, 12, 16],
|
||||
x:{{x_axis_titles|safe}},
|
||||
y:{{y_axis_opened}},
|
||||
type: 'bar',
|
||||
name: 'Opened',
|
||||
marker: {
|
||||
color: '#00ffff',
|
||||
opacity: 0.5
|
||||
}
|
||||
};
|
||||
|
||||
var data = [trace1, trace2, trace3, trace4];
|
||||
|
||||
var layout = {
|
||||
title: 'Campaigns',
|
||||
margin:{
|
||||
b:160,
|
||||
l:120,
|
||||
},
|
||||
xaxis: {
|
||||
type: 'category',
|
||||
tickangle: -45,
|
||||
},
|
||||
barmode: 'group'
|
||||
};
|
||||
|
||||
Plotly.newPlot('graph', data, layout);
|
||||
|
||||
{% endif %}
|
||||
|
||||
});
|
||||
|
||||
// $('.modebar').css('display','none');
|
||||
|
||||
</script>
|
||||
{% endblock js_block %}
|
||||
|
|
@ -79,8 +79,9 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th width="5%">S. No</th>
|
||||
<th width="20%">Name</th>
|
||||
<th width="10%">Name</th>
|
||||
<th width="10%">Email</th>
|
||||
<th width="15%">Company</th>
|
||||
<th width="15%">Created by</th>
|
||||
<th width="15%">Created On</th>
|
||||
<th width="15%">Related Contact List</th>
|
||||
|
|
@ -99,6 +100,7 @@
|
|||
<td scope="row">{{ forloop.counter }}</td>
|
||||
<td><a href="{% url 'marketing:contact_detail' contact.id %}">{{ contact.name }}</td>
|
||||
<td class="text-center">{{ contact.email }}</td>
|
||||
<td class="text-center">{{ contact.company_name }}</td>
|
||||
<td>{{ contact.created_by }}</td>
|
||||
<td>{{ contact.created_on }}</td>
|
||||
<td>
|
||||
|
|
@ -173,13 +175,7 @@
|
|||
console.log(url)
|
||||
var contact_lists = parseInt($(this).attr('data-other-contacts-lists'));
|
||||
console.log(contact_lists);
|
||||
if (contact_lists > 1) {
|
||||
if (!confirm('Are you sure you want to edit? this contact exists in other contact lists, editing this will change this contact information in other contact lists too!'))
|
||||
return;
|
||||
window.location = $(this).attr('href');
|
||||
} else {
|
||||
window.location = $(this).attr('href');
|
||||
}
|
||||
window.location = $(this).attr('href');
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -165,13 +165,7 @@
|
|||
console.log(url)
|
||||
var contact_lists = parseInt($(this).attr('data-other-contacts-lists'));
|
||||
console.log(contact_lists);
|
||||
if (contact_lists > 1) {
|
||||
if (!confirm('Are you sure you want to edit? this contact exists in other contact lists, editing this will change this contact information in other contact lists too!'))
|
||||
return;
|
||||
window.location = $(this).attr('href');
|
||||
} else {
|
||||
window.location = $(this).attr('href');
|
||||
}
|
||||
window.location = $(this).attr('href');
|
||||
})
|
||||
|
||||
$("a[rel='page']").click(function (e) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,15 @@
|
|||
<span class="error" id="id__email">{{ form.email.errors }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1" class="required">
|
||||
Company{% if form.company_name.field.required %}<span class="error_marker"
|
||||
style="color:red">*</span>{% endif %}</label>
|
||||
{{ form.company_name }}
|
||||
<span class="error" id="id__company_name">{{ form.company_name.errors }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="filter_col col-md-12">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1" class="required">First
|
||||
|
|
@ -72,7 +81,9 @@
|
|||
<div class="col-md-12">
|
||||
<div class="row marl buttons_row text-center form_btn_row">
|
||||
<button class="btn btn-default save" type="submit">Update</button>
|
||||
<a href="{% url 'marketing:contacts_list' %}" class="btn btn-default clear">Cancel</a>
|
||||
<a {% if request.META.HTTP_REFERER %} href="{{ request.META.HTTP_REFERER }}" {% else %} href="/"
|
||||
{% endif %} class="btn btn-default clear">Cancel</a>
|
||||
<!-- <a href="#" onclick="window.history.back()" class="btn btn-default clear">Cancel</a> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,26 +3,29 @@
|
|||
{% load thumbnail %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Django CRM</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Muli" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" />
|
||||
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
|
||||
<link href="https://cdn.quilljs.com/1.3.6/quill.bubble.css" rel="stylesheet">
|
||||
<link href="https://cdn.quilljs.com/1.3.6/quill.core.css" rel="stylesheet">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Django CRM</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Muli" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
|
||||
<link rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.min.css" />
|
||||
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
|
||||
<link href="https://cdn.quilljs.com/1.3.6/quill.bubble.css" rel="stylesheet">
|
||||
<link href="https://cdn.quilljs.com/1.3.6/quill.core.css" rel="stylesheet">
|
||||
|
||||
{% compress css %}
|
||||
<link href="{% static 'css/main.scss' %}" type="text/x-scss" rel="stylesheet">
|
||||
<link href="{% static 'css/mention.scss' %}" type="text/x-scss" rel="stylesheet">
|
||||
{% endcompress %}
|
||||
{% compress css %}
|
||||
<link href="{% static 'css/main.scss' %}" type="text/x-scss" rel="stylesheet">
|
||||
<link href="{% static 'css/mention.scss' %}" type="text/x-scss" rel="stylesheet">
|
||||
{% endcompress %}
|
||||
|
||||
{% block extralinks %} {% endblock %}
|
||||
{% block extralinks %} {% endblock %}
|
||||
</head>
|
||||
|
||||
<body class="main_body_bg_color">
|
||||
<div class="wrapper">
|
||||
{% block header %}
|
||||
|
|
@ -30,52 +33,68 @@
|
|||
<nav class="navbar navbar-expand-lg navbar-dark fixed-top">
|
||||
<!-- <a class="navbar-brand" href="{% url 'common:home' %}">Django CRM</a> -->
|
||||
<div class="dropdown">
|
||||
<a class="dropdown-toggle navbar-brand" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="color:#44535c">
|
||||
<a class="dropdown-toggle navbar-brand" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="false" style="color:#44535c">
|
||||
Django CRM
|
||||
</a>
|
||||
|
||||
<div class="dropdown-menu mt-2" aria-labelledby="dropdownMenuLink">
|
||||
{% if user.is_superuser or user.role == 'ADMIN' %}
|
||||
<a class="dropdown-item" href="/">Sales</a>
|
||||
<a class="dropdown-item" href="{% url 'marketing:dashboard' %}">Marketing</a>
|
||||
{% elif user.has_sales_access and user.has_marketing_access %}
|
||||
<a class="dropdown-item" href="/">Sales</a>
|
||||
<a class="dropdown-item" href="{% url 'marketing:dashboard' %}">Marketing</a>
|
||||
{% elif user.has_sales_access and not user.has_marketing_access %}
|
||||
<a class="dropdown-item" href="/">Sales</a>
|
||||
{% elif not user.has_sales_access and user.has_marketing_access %}
|
||||
<a class="dropdown-item" href="{% url 'marketing:dashboard' %}">Marketing</a>
|
||||
{% else %}
|
||||
{{''}}
|
||||
{% endif %}
|
||||
<!-- <a class="dropdown-item" href="/">Sales</a>
|
||||
<a class="dropdown-item" href="{% url 'marketing:dashboard' %}">Marketing</a> -->
|
||||
</div>
|
||||
</div>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
|
||||
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<i class="fas fa-bars"></i>
|
||||
</button>
|
||||
{% if request.user.is_authenticated %}
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
{% block main_menu %}{% endblock %}
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
{% block main_menu %}{% endblock %}
|
||||
|
||||
<ul class="navbar-nav navbar-right my-2 my-lg-0">
|
||||
<li class="nav-item dropdown">
|
||||
<a href="#" class="dropdown-toggle abcd nav-link" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" >
|
||||
{% if not request.user.profile_pic %}
|
||||
<img src="{% static 'images/user.png' %}" alt="Micro profile pic">
|
||||
{% else %}
|
||||
{% thumbnail request.user.profile_pic "25x25" as im %}
|
||||
<img src="{{ im.url }}">
|
||||
{% endthumbnail %}
|
||||
{% endif %}
|
||||
<b class="caret"></b>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
|
||||
{% if request.user.role == "ADMIN" or request.user.is_superuser %}
|
||||
<a class="dropdown-item" href="{% url 'common:users_list' %}">Users</a>
|
||||
<a class="dropdown-item" href="{% url 'common:api_settings' %}">Settings</a>
|
||||
{% endif %}
|
||||
{% if request.user.email != "admin@micropyramid.com" %}
|
||||
<a class="dropdown-item" href="/change-password/">Change Password</a>
|
||||
{% endif %}
|
||||
<a class="dropdown-item" href="{% url 'common:profile' %}">Profile</a>
|
||||
<a class="dropdown-item" href="{% url 'common:logout' %}">Logout</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<ul class="navbar-nav navbar-right my-2 my-lg-0">
|
||||
<li class="nav-item dropdown">
|
||||
<a href="#" class="dropdown-toggle abcd nav-link" data-toggle="dropdown" role="button"
|
||||
aria-haspopup="true" aria-expanded="false">
|
||||
{% if not request.user.profile_pic %}
|
||||
<img src="{% static 'images/user.png' %}" alt="Micro profile pic">
|
||||
{% else %}
|
||||
{% thumbnail request.user.profile_pic "25x25" as im %}
|
||||
<img src="{{ im.url }}">
|
||||
{% endthumbnail %}
|
||||
{% endif %}
|
||||
<b class="caret"></b>
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
|
||||
{% if request.user.role == "ADMIN" or request.user.is_superuser %}
|
||||
<a class="dropdown-item" href="{% url 'common:users_list' %}">Users</a>
|
||||
<a class="dropdown-item" href="{% url 'common:api_settings' %}">Settings</a>
|
||||
{% endif %}
|
||||
{% if request.user.email != "admin@micropyramid.com" %}
|
||||
<a class="dropdown-item" href="/change-password/">Change Password</a>
|
||||
{% endif %}
|
||||
<a class="dropdown-item" href="{% url 'common:profile' %}">Profile</a>
|
||||
<a class="dropdown-item" href="{% url 'common:logout' %}">Logout</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
</nav>
|
||||
</nav>
|
||||
</header>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
<div id="mainbody" class="main_container" style="margin-top:65px;">
|
||||
{% block breadcrumb %}
|
||||
|
|
@ -85,66 +104,68 @@
|
|||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.min.js"></script>
|
||||
<script defer src="https://use.fontawesome.com/releases/v5.7.1/js/all.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" ></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js"></script>
|
||||
<script src="https://cdn.quilljs.com/1.3.6/quill.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.min.js"></script>
|
||||
<script defer src="https://use.fontawesome.com/releases/v5.7.1/js/all.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
|
||||
<script
|
||||
src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.5/js/select2.min.js"></script>
|
||||
<script src="https://cdn.quilljs.com/1.3.6/quill.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js"></script>
|
||||
|
||||
{% block js_block %}{% endblock js_block %}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
word = window.location.pathname.split('/')[1];
|
||||
if(word == ""){
|
||||
$("#dashboard").addClass('active');
|
||||
}
|
||||
else{
|
||||
$('#' + word).addClass('active');
|
||||
}
|
||||
marketing_word = window.location.pathname.split('/')[2];
|
||||
if(marketing_word == ""){
|
||||
$("#marketing-dashboard").addClass('active');
|
||||
}
|
||||
// console.log(marketing_word.substring(0,7) === 'contact');
|
||||
else if(marketing_word.substring(0,7) === "contact"){
|
||||
$("#contact").css({'border-bottom':'3px solid #099CBE,'});
|
||||
$(".contact_class").css('border-bottom','3px solid #099CBE');
|
||||
marketing_word = window.location.pathname.split('/')[2]
|
||||
// console.log(marketing_word)
|
||||
// console.log(marketing_word == 'contact-list')
|
||||
// console.log(marketing_word == 'contacts')
|
||||
if (marketing_word == 'contact-list'){
|
||||
$(".contact-list").css('background','#e5e5e5');
|
||||
{% block js_block %}{% endblock js_block %}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
word = window.location.pathname.split('/')[1];
|
||||
if (word == "") {
|
||||
$("#dashboard").addClass('active');
|
||||
}
|
||||
if (marketing_word == 'contacts'){
|
||||
$(".contacts").css('background','#e5e5e5');
|
||||
else {
|
||||
$('#' + word).addClass('active');
|
||||
}
|
||||
// $("#contacts").css('background','#e5e5e5');
|
||||
}
|
||||
else{
|
||||
$('#' + marketing_word).addClass('active')
|
||||
}
|
||||
});
|
||||
marketing_word = window.location.pathname.split('/')[2];
|
||||
if (marketing_word == "") {
|
||||
$("#marketing-dashboard").addClass('active');
|
||||
}
|
||||
// console.log(marketing_word.substring(0,7) === 'contact');
|
||||
else if (marketing_word.substring(0, 7) === "contact") {
|
||||
$("#contact").css({ 'border-bottom': '3px solid #099CBE,' });
|
||||
$(".contact_class").css('border-bottom', '3px solid #099CBE');
|
||||
marketing_word = window.location.pathname.split('/')[2]
|
||||
// console.log(marketing_word)
|
||||
// console.log(marketing_word == 'contact-list')
|
||||
// console.log(marketing_word == 'contacts')
|
||||
if (marketing_word == 'contact-list') {
|
||||
$(".contact-list").css('background', '#e5e5e5');
|
||||
}
|
||||
if (marketing_word == 'contacts') {
|
||||
$(".contacts").css('background', '#e5e5e5');
|
||||
}
|
||||
// $("#contacts").css('background','#e5e5e5');
|
||||
}
|
||||
else {
|
||||
$('#' + marketing_word).addClass('active')
|
||||
}
|
||||
});
|
||||
/*
|
||||
Usage is very simple; to block user activity for the page:
|
||||
$.blockUI();
|
||||
|
||||
Blocking with a custom message:
|
||||
$.blockUI({ message: '<h1><img src="busy.gif" /> Just a moment...</h1>' });
|
||||
|
||||
Blocking with custom style:
|
||||
$.blockUI({ css: { backgroundColor: '#f00', color: '#fff'} });
|
||||
|
||||
To unblock the page:
|
||||
$.unblockUI();
|
||||
|
||||
If you want to use the default settings and have the UI blocked for all ajax requests, it's as easy as this:
|
||||
$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);
|
||||
*/
|
||||
</script>
|
||||
Usage is very simple; to block user activity for the page:
|
||||
$.blockUI();
|
||||
|
||||
Blocking with a custom message:
|
||||
$.blockUI({ message: '<h1><img src="busy.gif" /> Just a moment...</h1>' });
|
||||
|
||||
Blocking with custom style:
|
||||
$.blockUI({ css: { backgroundColor: '#f00', color: '#fff'} });
|
||||
|
||||
To unblock the page:
|
||||
$.unblockUI();
|
||||
|
||||
If you want to use the default settings and have the UI blocked for all ajax requests, it's as easy as this:
|
||||
$(document).ajaxStart($.blockUI).ajaxStop($.unblockUI);
|
||||
*/
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</html>
|
||||
|
|
@ -2,15 +2,23 @@
|
|||
|
||||
{% block main_menu %}
|
||||
<ul class="navbar-nav mr-auto">
|
||||
{% if request.user.is_superuser or request.user.role == 'ADMIN' or request.user.has_sales_access %}
|
||||
<li class="nav-item"><a class="nav-link" id="dashboard" href="{% url 'common:home' %}">Dashboard</a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="accounts" href="{% url 'accounts:list' %}">Accounts</a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="contacts" href="{% url 'contacts:list' %}">Contacts</a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="leads" href="{% url 'leads:list' %}">Leads</a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="opportunities"href="{% url 'opportunities:list' %}">Opportunities</a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="opportunities" href="{% url 'opportunities:list' %}">Opportunities</a>
|
||||
</li>
|
||||
<li class="nav-item"><a class="nav-link" id="cases" href="{% url 'cases:list' %}">Cases</a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="documents" href="{% url 'common:doc_list' %}">Documents</a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="tasks" href="{% url 'tasks:tasks_list' %}">Tasks</a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="invoices" href="{% url 'invoices:invoices_list' %}">Invoices</a></li>
|
||||
<li class="nav-item"><a class="nav-link" id="events" href="{% url 'events:events_list' %}">Events</a></li>
|
||||
{% endif %}
|
||||
|
||||
{% if request.user.role == 'ADMIN' or request.user.is_superuser %}
|
||||
<li class="nav-item"><a class="nav-link" id="teams" href="{% url 'teams:teams_list' %}">Teams</a></li>
|
||||
{% endif %}
|
||||
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
|
@ -74,18 +74,26 @@
|
|||
<span class="text-left">No Tags</span>
|
||||
{% endfor %}
|
||||
{% if account.tags.all|length > 3 %}
|
||||
<span class="text-left" id="list_tag">{{account.tags.all|length|subtract:'3'}}<span> more
|
||||
</span></span>
|
||||
<a href="{% url 'accounts:view_account' account.id %}">
|
||||
<span class="text-left" id="list_tag">{{account.tags.all|length|subtract:'3'}}<span> more
|
||||
</span></span></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% with users=account.assigned_to.all %}
|
||||
{% if users %}
|
||||
{% for user in users %}
|
||||
{{user}}
|
||||
{% for user in users|slice:'3' %}
|
||||
<div>
|
||||
{{user}}
|
||||
</div>
|
||||
{% empty %}
|
||||
<span class="text-left">None</span>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
None
|
||||
{% if users|length > 3 %}
|
||||
<div>
|
||||
<a href="{% url 'accounts:view_account' account.id %}">
|
||||
<span class="text-left" id="list_tag">{{users|length|subtract:'3'}}<span> more
|
||||
</span></span></a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
|
|
@ -128,22 +136,25 @@
|
|||
<span class="text-left">No Tags</span>
|
||||
{% endfor %}
|
||||
{% if opportunity.tags.all|length > 3 %}
|
||||
<span class="text-left" id="list_tag">{{opportunity.tags.all|length|subtract:'3'}}<span> more
|
||||
</span></span>
|
||||
<a href="{% url 'opportunity:opp_view' opportunity.id %}">
|
||||
<span class="text-left" id="list_tag">{{opportunity.tags.all|length|subtract:'3'}}<span> more
|
||||
</span></span></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% with users=opportunity.assigned_to.all %}
|
||||
{% for user in users|slice:'3' %}
|
||||
<span class="text-left" id="list_opp_users_">{{user}}<span>
|
||||
{% empty %}
|
||||
<span class="text-left">None</span>
|
||||
{% endfor %}
|
||||
{% if users|length > 3 %}
|
||||
<span style="color:white; background-color: #333; padding:0.15em; border-radius: 10%;" class="text-left ml-1" id="list_opp_users">{{users|length|subtract:'3'}}<span> more
|
||||
</span></span>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% empty %}
|
||||
<span class="text-left">None</span>
|
||||
{% endfor %}
|
||||
{% if users|length > 3 %}
|
||||
<a href="{% url 'opportunity:opp_view' opportunity.id %}">
|
||||
<span class="text-left" id="list_tag">{{users|length|subtract:'3'}}<span> more
|
||||
</span></span>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue