Skip to content

Commit

Permalink
Merge pull request #49 from robotichead/development-0.14.1
Browse files Browse the repository at this point in the history
Development 0.14.1
  • Loading branch information
robotichead authored Jun 20, 2018
2 parents 936039e + 36e7ef4 commit c309a79
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 27 deletions.
2 changes: 1 addition & 1 deletion forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down
20 changes: 20 additions & 0 deletions migrations/0005_permission_set_email.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
6 changes: 6 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,7 @@ def get_by_natural_key(
bug,
bug_client,
customer,
email,
invoice,
invoice_product,
kanban,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions templates/NearBeach/customer_information.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ <h2>Customer Opportunities</h2>
//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 + '%'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ <h2>Contact History</h2>
<li>{{ contact_history_form.contact_attachment }}</li>
<li>
<div id="progress" style="border: none; width: 100%;">
<span id="upload_percent"><input type="submit" name="submit_contact" value="Submit Contact"/></span>
<div id="upload_progress" style="background-color: green; width: 0%; height: 20px;"></div>
<span id="upload_percent_contact"><input type="submit" name="submit_contact" value="Submit Contact"/></span>
<div id="upload_progress_contact" style="background-color: green; width: 0%; height: 20px;"></div>
</div>
</li>
</ul>
Expand Down
6 changes: 4 additions & 2 deletions templates/NearBeach/email_history.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h2>Email History</h2>
<a href="{% url 'email' location_id destination %}">Create a new email</a>
{% if email_results %}
{% if email_results and not email_permission == 0 %}
<table>
<tr>
<td width="70%">Subject</td>
Expand All @@ -9,7 +9,9 @@ <h2>Email History</h2>
</tr>
{% for row in email_results %}
<tr>
<td><a href="{% url 'email_information' row.email_content_id %}">{{ row.email_subject }}</a></td>
{% if email_permission > 1 %}
<td><a href="{% url 'email_information' row.email_content_id %}">{{ row.email_subject }}</a></td>
{% endif %}
<td>{{ row.date_created }}</td>
<td>{{ row.change_user }}</td>
</tr>
Expand Down
1 change: 1 addition & 0 deletions templates/NearBeach/kanban_information.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ <h2>{{ kanban_board_results.kanban_board_name }}</h2>
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.");
Expand Down
1 change: 1 addition & 0 deletions templates/NearBeach/permission_set_information.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ <h2>Permission Set Information</h2>
}

function load_permission_edit(permission_set_id) {
if (permission_set_id == 1) {return false; }
$.ajax({
url: '/permission_set_information_edit/' + permission_set_id + '/',
data: {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{% csrf_token %}
{% if permission_set_id == '1' %}
<p>Can not edit administration</p>
{% else %}
<ul style="background-color: lightgreen">
{% if save_errors %}
<li><b>THERE WAS AN ERROR SAVING!</b></li>
Expand All @@ -9,3 +12,4 @@
<li><input type="submit" value="Submit Permission Set"></li>
<li id="permission_set_id" value="{{ permission_set_id }}"></li>
</ul>
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@
</tr>
{% for row in permission_set_results %}
<tr>
<td><a href="javascript:void(0)" onclick="load_permission_edit({{ row.permission_set_id }})">{{ row.permission_set_name }}</a></td>
<td>{{ row.date_created }}</td>
<td>
{% if row.is_deleted == 'FALSE' %}
<a href="javascript:void(0)" onclick="alert('write function')">Delete</a>
{% else %}
<a href="javascript:void(0)" onclick="alert('write function')">Restore</a>
{% endif %}
</td>
{% if row.permission_set_id == 1 %}
<td>Administration</td>
<td>{{ row.date_created }}</td>
<td> --- </td>
{% else %}
<td><a href="javascript:void(0)" onclick="load_permission_edit({{ row.permission_set_id }})">{{ row.permission_set_name }}</a></td>
<td>{{ row.date_created }}</td>
<td>
{% if row.is_deleted == 'FALSE' %}
<a href="javascript:void(0)" onclick="alert('write function')">Delete</a>
{% else %}
<a href="javascript:void(0)" onclick="alert('write function')">Restore</a>
{% endif %}
</td>
{% endif %}

</tr>
{% endfor %}
</table>
3 changes: 3 additions & 0 deletions templates/NearBeach/project_information.html
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ <h2>Assigned Groups</h2>


function complete_to_do(to_do_id) {
$("#to_do_"+to_do_id).html("Completing...");

//Send data to the database
$.ajaxSetup({
beforeSend: function (xhr, settings) {
Expand All @@ -373,6 +375,7 @@ <h2>Assigned Groups</h2>
},
error: function() {
alert("Can not complete To do :(");
$("#to_do_"+to_do_id).html('<a href="javascript:void(0)" onclick="complete_to_do(' + to_do_id + '">Complete</a>')
}
});
}
Expand Down
3 changes: 3 additions & 0 deletions templates/NearBeach/task_information.html
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ <h2>Assigned Groups</h2>


function complete_to_do(to_do_id) {
$("#to_do_"+to_do_id).html("Completing...");

//Send data to the database
$.ajaxSetup({
beforeSend: function (xhr, settings) {
Expand All @@ -410,6 +412,7 @@ <h2>Assigned Groups</h2>
},
error: function() {
alert("Can not complete To do :(");
$("#to_do_"+to_do_id).html('<a href="javascript:void(0)" onclick="complete_to_do(' + to_do_id + '">Complete</a>')
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion templates/NearBeach/to_do/to_do.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% for row in to_do_results %}
<tr>
<td>{{ row.to_do }}</td>
<td>
<td id="to_do_{{ row.to_do_id }}" >
{% if row.to_do_completed %}
Completed
{% else %}
Expand Down
39 changes: 35 additions & 4 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1636,13 +1641,18 @@ 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))


@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(
Expand Down Expand Up @@ -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 = ''
Expand All @@ -1732,13 +1742,19 @@ 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))


@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,
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -4649,13 +4676,17 @@ 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
c = {
'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))
Expand Down
2 changes: 1 addition & 1 deletion views_administration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 4 additions & 1 deletion views_project_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("""
Expand Down
8 changes: 4 additions & 4 deletions views_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c309a79

Please sign in to comment.