Collaborate PM permission fixes and daily tme log fix

This commit is contained in:
Kanchan Chauhan 2016-04-08 23:22:04 +05:30
parent 5ea0799f83
commit a4ff5d3195
4 changed files with 34 additions and 2 deletions

View File

@ -101,6 +101,11 @@ class Task(Document):
task.exp_end_date = add_days(task.exp_start_date, task_duration)
task.flags.ignore_recursion_check = True
task.save()
def has_webform_permission(doc):
project_user = frappe.db.get_value("Project User", {"parent": doc.project, "user":frappe.session.user} , "user")
if project_user:
return True
@frappe.whitelist()
def get_events(start, end, filters=None):
@ -134,7 +139,7 @@ def get_project(doctype, txt, searchfield, start, page_len, filters):
order by name
limit %(start)s, %(page_len)s """ % {'key': searchfield,
'txt': "%%%s%%" % frappe.db.escape(txt), 'mcond':get_match_cond(doctype),
'start': start, 'page_len': page_len})
'start': start, 'page_len': page_len})
@frappe.whitelist()
@ -150,3 +155,6 @@ def set_tasks_as_overdue():
where exp_end_date is not null
and exp_end_date < CURDATE()
and `status` not in ('Closed', 'Cancelled')""")

View File

@ -247,6 +247,11 @@ class TimeLog(Document):
elif self.project:
frappe.get_doc("Project", self.project).update_project()
def has_webform_permission(doc):
project_user = frappe.db.get_value("Project User", {"parent": doc.project, "user":frappe.session.user} , "user")
if project_user:
return True
@frappe.whitelist()

View File

@ -18,6 +18,7 @@ def execute(filters=None):
_("Task Subject") + "::180", _("Project") + ":Link/Project:120", _("Status") + "::70"]
user_map = get_user_map()
employee_map = get_employee_map()
task_map = get_task_map()
conditions = build_conditions(filters)
@ -30,12 +31,16 @@ def execute(filters=None):
data = []
total_hours = total_employee_hours = count = 0
for tl in time_logs:
if tl.employee:
employee=employee_map[tl.employee]
else:
employee=user_map[tl.owner]
if tl.owner not in users:
users.append(tl.owner)
data.append(["", "", "", "Total", total_employee_hours, "", "", "", "", ""])
total_employee_hours = 0
data.append([tl.name, user_map[tl.owner], tl.from_time, tl.to_time, tl.hours,
data.append([tl.name, employee, tl.from_time, tl.to_time, tl.hours,
tl.activity_type, tl.task, task_map.get(tl.task), tl.project, tl.status])
count += 1
@ -59,6 +64,16 @@ def get_user_map():
user_map.setdefault(p.name, []).append(p.fullname)
return user_map
def get_employee_map():
employees = frappe.db.sql("""select name,
employee_name as fullname
from tabEmployee""", as_dict=1)
employee_map = {}
for p in employees:
employee_map.setdefault(p.name, []).append(p.fullname)
return employee_map
def get_task_map():
tasks = frappe.db.sql("""select name, subject from tabTask""", as_dict=1)

View File

@ -6,6 +6,10 @@ import frappe
import json
def get_context(context):
project_user = frappe.db.get_value("Project User", {"parent": frappe.form_dict.project, "user": frappe.session.user} , "user")
if not project_user or frappe.session.user == 'Guest':
raise frappe.PermissionError
context.no_cache = 1
project = frappe.get_doc('Project', frappe.form_dict.project)