diff --git a/forms.py b/forms.py
index fd9e4e718..e30bc484e 100644
--- a/forms.py
+++ b/forms.py
@@ -460,7 +460,7 @@ def __init__(self, *args, **kwargs):
elif destination == "quote":
customer_results = customers.objects.filter(
is_deleted="FALSE",
- organisations_id=quotes.objects.get(quote_id=location_id).organisation_id.organisations_id
+ organisations_id=quotes.objects.get(quote_id=location_id).project_id.organisations_id.organisations_id
)
else:
customer_results = ''
diff --git a/migrations/0005_permission_set_email.py b/migrations/0005_permission_set_email.py
new file mode 100644
index 000000000..bbe80a1b9
--- /dev/null
+++ b/migrations/0005_permission_set_email.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11 on 2018-06-15 04:37
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('NearBeach', '0004_email_content_is_private'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='permission_set',
+ name='email',
+ field=models.IntegerField(choices=[(0, 'No Permission'), (1, 'Read Only'), (2, 'Edit Only'), (3, 'Add and Edit'), (4, 'Full Permission')], default=0),
+ ),
+ ]
diff --git a/models.py b/models.py
index 2666215d2..e71791f8c 100755
--- a/models.py
+++ b/models.py
@@ -1509,6 +1509,7 @@ def get_by_natural_key(
bug,
bug_client,
customer,
+ email,
invoice,
invoice_product,
kanban,
@@ -1540,6 +1541,7 @@ def get_by_natural_key(
bug=bug,
bug_client=bug_client,
customer=customer,
+ email=email,
invoice=invoice,
invoice_product=invoice_product,
kanban=kanban,
@@ -1602,6 +1604,10 @@ class permission_set(models.Model):
choices=PERMISSION_LEVEL,
default=0,
)
+ email = models.IntegerField(
+ choices=PERMISSION_LEVEL,
+ default=0,
+ )
invoice = models.IntegerField(
choices=PERMISSION_LEVEL,
default=0,
diff --git a/templates/NearBeach/customer_information.html b/templates/NearBeach/customer_information.html
index 1070e1bb7..7d878ecf0 100644
--- a/templates/NearBeach/customer_information.html
+++ b/templates/NearBeach/customer_information.html
@@ -218,8 +218,8 @@
{{ row.to_do }} |
-
+ |
{% if row.to_do_completed %}
Completed
{% else %}
diff --git a/views.py b/views.py
index 681457179..608ba58c2 100755
--- a/views.py
+++ b/views.py
@@ -1388,6 +1388,11 @@ def delete_document(request, document_key):
@login_required(login_url='login')
def email(request,location_id,destination):
+ permission_results = return_user_permission_level(request, None, 'email')
+
+ if permission_results['email'] < 2:
+ return HttpResponseRedirect(reverse('permission_denied'))
+
"""
organisation
customer
@@ -1636,6 +1641,9 @@ def email(request,location_id,destination):
),
'destination': destination,
'location_id': location_id,
+ 'new_item_permission': permission_results['new_item'],
+ 'administration_permission': permission_results['administration'],
+
}
return HttpResponse(t.render(c, request))
@@ -1643,6 +1651,8 @@ def email(request,location_id,destination):
@login_required(login_url='login')
def email_history(request,location_id,destination):
+ permission_results = return_user_permission_level(request, None, 'email')
+
#Get data
if destination == "organisation":
email_results = email_content.objects.filter(
@@ -1699,25 +1709,25 @@ def email_history(request,location_id,destination):
email_results = email_content.objects.filter(
is_deleted="FALSE",
email_content_id__in=email_contact.objects.filter(
- Q(opportunity__isnull=False) &
+ Q(opportunity_id=location_id) &
Q(is_deleted="FALSE") &
Q(
Q(is_private=False) |
Q(change_user=request.user)
)
- )
+ ).values('email_content_id')
)
elif destination == "quote":
email_results = email_content.objects.filter(
is_deleted="FALSE",
email_content_id__in=email_contact.objects.filter(
- Q(quotes__isnull=False) &
+ Q(quotes=location_id) &
Q(is_deleted="FALSE") &
Q(
Q(is_private=False) |
Q(change_user=request.user)
)
- )
+ ).values('email_content_id')
)
else:
email_results = ''
@@ -1732,6 +1742,7 @@ def email_history(request,location_id,destination):
'destination': destination,
'location_id': location_id,
'email_results': email_results,
+ 'email_permission': permission_results['email'],
}
return HttpResponse(t.render(c, request))
@@ -1739,6 +1750,11 @@ def email_history(request,location_id,destination):
@login_required(login_url='login')
def email_information(request,email_content_id):
+ permission_results = return_user_permission_level(request, None, 'email')
+
+ if permission_results['email'] < 1:
+ return HttpResponseRedirect(reverse('permission_denied'))
+
email_content_results = email_content.objects.get(
is_deleted="FALSE",
email_content_id=email_content_id,
@@ -1774,6 +1790,9 @@ def email_information(request,email_content_id):
'to_email_results': to_email_results,
'cc_email_results': cc_email_results,
'bcc_email_results': bcc_email_results,
+ 'new_item_permission': permission_results['new_item'],
+ 'administration_permission': permission_results['administration'],
+
}
return HttpResponse(t.render(c, request))
@@ -2353,18 +2372,26 @@ def login(request):
administration_create_users=4,
assign_campus_to_customer=4,
associate_project_and_tasks=4,
+ bug=4,
+ bug_client=4,
customer=4,
+ email=4,
invoice=4,
invoice_product=4,
+ kanban=4,
+ kanban_card=4,
opportunity=4,
organisation=4,
organisation_campus=4,
project=4,
+ quote=4,
requirement=4,
requirement_link=4,
task=4,
+ tax=4,
documents=1,
contact_history=1,
+ kanban_comment=1,
project_history=1,
task_history=1,
change_user=request.user,
@@ -4649,6 +4676,8 @@ def task_information(request, task_id):
@login_required(login_url='login')
def timeline(request):
+ permission_results = return_user_permission_level(request, [],[])
+
t = loader.get_template('NearBeach/timeline.html')
# context
@@ -4656,6 +4685,8 @@ def timeline(request):
'timeline_form': timeline_form(),
'start_date': datetime.datetime.now(),
'end_date': datetime.datetime.now() + datetime.timedelta(days=31),
+ 'new_item_permission': permission_results['new_item'],
+ 'administration_permission': permission_results['administration'],
}
return HttpResponse(t.render(c, request))
diff --git a/views_administration.py b/views_administration.py
index f1c097013..6f9e7ce38 100644
--- a/views_administration.py
+++ b/views_administration.py
@@ -552,7 +552,7 @@ def permission_set_information_edit(request, permission_set_id):
c = {
'permission_set_form': permission_set_form(initial=initial),
'save_errors': save_errors,
- 'permission_set_id': permission_set_id
+ 'permission_set_id': permission_set_id,
}
return HttpResponse(t.render(c, request))
diff --git a/views_project_information.py b/views_project_information.py
index 7aeef9b24..ed8222795 100644
--- a/views_project_information.py
+++ b/views_project_information.py
@@ -162,9 +162,12 @@ def information_project_customers(request, project_id):
organisations_id=project_results.organisations_id,
is_deleted="FALSE",
).exclude(
- customer_id__in=tasks_customers.objects.filter(tasks_id=project_results.project_id).values('customer_id')
+ customer_id__in=project_customers.objects.filter(
+ project_id=project_results.project_id
+ ).values('customer_id')
)
+
#Cursor for custom SQL :)
cursor = connection.cursor()
cursor.execute("""
diff --git a/views_requirements.py b/views_requirements.py
index cae4f2270..2a727a73c 100644
--- a/views_requirements.py
+++ b/views_requirements.py
@@ -345,7 +345,7 @@ def requirement_items_new_link(request, requirement_item_id, location_id= '', de
cursor = connection.cursor()
cursor.execute("""
- SELECT
+ SELECT DISTINCT
project.project_id
, project.project_name
@@ -369,7 +369,7 @@ def requirement_items_new_link(request, requirement_item_id, location_id= '', de
project_results = namedtuplefetchall(cursor)
cursor.execute("""
- select
+ select DISTINCT
tasks.tasks_id
, tasks.task_short_description
@@ -495,7 +495,7 @@ def requirement_new_link(request, requirement_id, location_id='', destination=''
cursor = connection.cursor()
cursor.execute("""
- SELECT
+ SELECT DISTINCT
project.project_id
, project.project_name
@@ -519,7 +519,7 @@ def requirement_new_link(request, requirement_id, location_id='', destination=''
project_results = namedtuplefetchall(cursor)
cursor.execute("""
- select
+ select DISTINCT
tasks.tasks_id
, tasks.task_short_description
|