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 @@

Customer Opportunities

//Do something with upload progress console.log(percentComplete); - $("#upload_percent").html(parseFloat(percentComplete * 100).toFixed(2) + "%"); - $("#upload_progress").css( + $("#upload_percent_contact").html(parseFloat(percentComplete * 100).toFixed(2) + "%"); + $("#upload_progress_contact").css( 'width', percentComplete * 100 + '%' ); } diff --git a/templates/NearBeach/customer_information/customer_contact_history.html b/templates/NearBeach/customer_information/customer_contact_history.html index bd39c5321..557b0d11a 100644 --- a/templates/NearBeach/customer_information/customer_contact_history.html +++ b/templates/NearBeach/customer_information/customer_contact_history.html @@ -9,8 +9,8 @@

Contact History

  • {{ contact_history_form.contact_attachment }}
  • - -
    + +
  • diff --git a/templates/NearBeach/email_history.html b/templates/NearBeach/email_history.html index 2144dccba..49c951256 100644 --- a/templates/NearBeach/email_history.html +++ b/templates/NearBeach/email_history.html @@ -1,6 +1,6 @@

    Email History

    Create a new email -{% if email_results %} +{% if email_results and not email_permission == 0 %} @@ -9,7 +9,9 @@

    Email History

    {% for row in email_results %} - + {% if email_permission > 1 %} + + {% endif %} diff --git a/templates/NearBeach/kanban_information.html b/templates/NearBeach/kanban_information.html index f71ed2639..8b3fd1cfa 100644 --- a/templates/NearBeach/kanban_information.html +++ b/templates/NearBeach/kanban_information.html @@ -122,6 +122,7 @@

    {{ kanban_board_results.kanban_board_name }}

    dataType: "HTML", success: function(data) { $("#new_card_form").html(data); + $("#id_kanban_card_text").focus(); }, error: function() { alert("We are sorry, something went wrong with getting the new card ready."); diff --git a/templates/NearBeach/permission_set_information.html b/templates/NearBeach/permission_set_information.html index 1de66f76a..b5138cee6 100644 --- a/templates/NearBeach/permission_set_information.html +++ b/templates/NearBeach/permission_set_information.html @@ -80,6 +80,7 @@

    Permission Set Information

    } function load_permission_edit(permission_set_id) { + if (permission_set_id == 1) {return false; } $.ajax({ url: '/permission_set_information_edit/' + permission_set_id + '/', data: {}, diff --git a/templates/NearBeach/permission_set_information/permission_set_edit.html b/templates/NearBeach/permission_set_information/permission_set_edit.html index 455d33984..0c8779ac1 100644 --- a/templates/NearBeach/permission_set_information/permission_set_edit.html +++ b/templates/NearBeach/permission_set_information/permission_set_edit.html @@ -1,4 +1,7 @@ {% csrf_token %} +{% if permission_set_id == '1' %} +

    Can not edit administration

    +{% else %} +{% endif %} \ No newline at end of file diff --git a/templates/NearBeach/permission_set_information/permission_set_list.html b/templates/NearBeach/permission_set_information/permission_set_list.html index dbd7b98be..914fc3dac 100644 --- a/templates/NearBeach/permission_set_information/permission_set_list.html +++ b/templates/NearBeach/permission_set_information/permission_set_list.html @@ -6,15 +6,22 @@ {% for row in permission_set_results %} - - - + {% if row.permission_set_id == 1 %} + + + + {% else %} + + + + {% endif %} + {% endfor %}
    Subject
    {{ row.email_subject }}{{ row.email_subject }}{{ row.date_created }} {{ row.change_user }}
    {{ row.permission_set_name }}{{ row.date_created }} - {% if row.is_deleted == 'FALSE' %} - Delete - {% else %} - Restore - {% endif %} - Administration{{ row.date_created }} --- {{ row.permission_set_name }}{{ row.date_created }} + {% if row.is_deleted == 'FALSE' %} + Delete + {% else %} + Restore + {% endif %} +
    \ No newline at end of file diff --git a/templates/NearBeach/project_information.html b/templates/NearBeach/project_information.html index c363063aa..776df7763 100755 --- a/templates/NearBeach/project_information.html +++ b/templates/NearBeach/project_information.html @@ -355,6 +355,8 @@

    Assigned Groups

    function complete_to_do(to_do_id) { + $("#to_do_"+to_do_id).html("Completing..."); + //Send data to the database $.ajaxSetup({ beforeSend: function (xhr, settings) { @@ -373,6 +375,7 @@

    Assigned Groups

    }, error: function() { alert("Can not complete To do :("); + $("#to_do_"+to_do_id).html('Complete') } }); } diff --git a/templates/NearBeach/task_information.html b/templates/NearBeach/task_information.html index 33386075a..19946fffb 100755 --- a/templates/NearBeach/task_information.html +++ b/templates/NearBeach/task_information.html @@ -392,6 +392,8 @@

    Assigned Groups

    function complete_to_do(to_do_id) { + $("#to_do_"+to_do_id).html("Completing..."); + //Send data to the database $.ajaxSetup({ beforeSend: function (xhr, settings) { @@ -410,6 +412,7 @@

    Assigned Groups

    }, error: function() { alert("Can not complete To do :("); + $("#to_do_"+to_do_id).html('Complete') } }); } diff --git a/templates/NearBeach/to_do/to_do.html b/templates/NearBeach/to_do/to_do.html index e034b2ad8..dbe19be33 100644 --- a/templates/NearBeach/to_do/to_do.html +++ b/templates/NearBeach/to_do/to_do.html @@ -12,7 +12,7 @@ {% for row in to_do_results %} {{ 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