mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-06 05:39:12 +00:00
[fix] back links from project web view
This commit is contained in:
@@ -2,13 +2,15 @@
|
||||
|
||||
{% block title %}{{ doc.project_name }}{% endblock %}
|
||||
|
||||
{%- from "templates/includes/projects/macros.html" import back_link -%}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
<div class="page-breadcrumbs" data-html-block="breadcrumbs">
|
||||
<div class="page-breadcrumbs" data-html-block="breadcrumbs">
|
||||
<ul class="breadcrumb">
|
||||
<li>
|
||||
<span class="icon icon-angle-left"></span>
|
||||
<a href="/project">Projects</a>
|
||||
</li>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -23,7 +25,7 @@
|
||||
<style>
|
||||
{% include "templates/includes/projects.css" %}
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block page_content %}
|
||||
@@ -43,16 +45,15 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if doc.tasks %}
|
||||
<div class='padding'></div>
|
||||
|
||||
<h3>{{ _("Tasks") }}</h3>
|
||||
|
||||
{% if doc.tasks %}
|
||||
<div class='project-tasks-section'>
|
||||
<div>
|
||||
<a class="btn btn-xs btn-primary pull-right"
|
||||
href='/tasks?new=1&project={{ doc.project_name }}'>New</a>
|
||||
<h3>{{ _("Tasks") }}</h3>
|
||||
</div>
|
||||
<div class="btn-group btn-toggle">
|
||||
<div class="btn-group btn-toggle">
|
||||
<button class="btn btn-link btn-open-tasks"><span class="indicator orange"></span>Open</button>
|
||||
<button class="btn btn-link btn-closed-tasks"><span class="indicator green"></span>Closed</button>
|
||||
<button class="btn btn-link btn-closed-tasks"><span class="indicator green"></span>Closed</button>
|
||||
</div>
|
||||
<div class='project-tasks'>
|
||||
{% include "erpnext/templates/includes/projects/project_tasks.html" %}
|
||||
@@ -66,16 +67,16 @@
|
||||
<p class="text-muted">No tasks</p>
|
||||
{% endif %}
|
||||
|
||||
<p><a href='/tasks?new=1&project={{ doc.project_name }}{{ back_link(doc) }}'>Add a new task</a></p>
|
||||
|
||||
<div class='padding'></div>
|
||||
<h3>{{ _("Issues") }}</h3>
|
||||
|
||||
{% if doc.issues %}
|
||||
<div class='project-issues-section'>
|
||||
<div>
|
||||
<a class="btn btn-xs btn-primary pull-right"
|
||||
href='/issues?new=1&project={{ doc.project_name }}'>New</a>
|
||||
<h3>{{ _("Issues") }}</h3>
|
||||
</div>
|
||||
<div class="btn-group btn-toggle">
|
||||
<div class="btn-group btn-toggle">
|
||||
<button class="btn btn-link btn-open-issues"><span class="indicator red"></span>Open</button>
|
||||
<button class="btn btn-link btn-closed-issues"><span class="indicator green"></span>Closed</button>
|
||||
<button class="btn btn-link btn-closed-issues"><span class="indicator green"></span>Closed</button>
|
||||
</div>
|
||||
<div class='project-issues'>
|
||||
{% include "erpnext/templates/includes/projects/project_issues.html" %}
|
||||
@@ -84,13 +85,18 @@
|
||||
{% if doc.issues|length > 9 %}
|
||||
<p><a id='more-issues' class='more-issues small underline'>{{ _("More") }}</a><p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="text-muted">No Issues</p>
|
||||
{% endif %}
|
||||
|
||||
<p> <a href='/issues?new=1&project={{ doc.project_name }}{{ back_link(doc) }}'>Add a new issue</a></p>
|
||||
|
||||
<div class='padding'></div>
|
||||
|
||||
<h3>{{ _("Time Logs") }}</h3>
|
||||
|
||||
{% if doc.timelogs %}
|
||||
<h3>{{ _("Time Logs") }}</h3>
|
||||
<div class='project-timelogs'>
|
||||
{% include "erpnext/templates/includes/projects/project_timelogs.html" %}
|
||||
</div>
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe import _
|
||||
import json
|
||||
|
||||
def get_context(context):
|
||||
context.no_cache = 1
|
||||
@@ -17,46 +16,52 @@ def get_context(context):
|
||||
fields=['subject', 'opening_date', 'resolution_date', 'status', 'name', 'resolution_details','modified','modified_by'])
|
||||
|
||||
project.tasks = get_tasks(project.name, start=0, search=frappe.form_dict.get("q"))
|
||||
|
||||
|
||||
project.timelogs = get_timelogs(project.name, start=0, search=frappe.form_dict.get("q"))
|
||||
|
||||
|
||||
project.issues = get_issues(project.name, start=0, search=frappe.form_dict.get("q"))
|
||||
|
||||
|
||||
project.timelines = get_timeline(project.project_name, start=0)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
context.doc = project
|
||||
|
||||
|
||||
|
||||
|
||||
def get_timeline(project, start=10):
|
||||
issue_names = '({0})'.format(", ".join(["'{0}'".format(i.name) for i in get_issues(project)]))
|
||||
|
||||
|
||||
'''Get timeline from project, tasks, issues'''
|
||||
issues_condition = ''
|
||||
project_issues = get_issues(project)
|
||||
|
||||
if project_issues:
|
||||
issue_names = '({0})'.format(", ".join(["'{0}'".format(i.name) for i in project_issues]))
|
||||
issues_condition = """or (reference_doctype='Issue' and reference_name IN {issue_names})""".format(issue_names=issue_names)
|
||||
|
||||
|
||||
timelines = frappe.db.sql("""
|
||||
select
|
||||
sender_full_name,
|
||||
subject, communication_date, comment_type, name, creation, modified_by, reference_doctype, reference_name,
|
||||
_liked_by, comment_type, _comments
|
||||
from
|
||||
tabCommunication
|
||||
where
|
||||
select
|
||||
sender_full_name,
|
||||
subject, communication_date, comment_type, name, creation, modified_by, reference_doctype, reference_name,
|
||||
_liked_by, comment_type, _comments
|
||||
from
|
||||
tabCommunication
|
||||
where
|
||||
(reference_doctype='Project' and reference_name=%s)
|
||||
or (timeline_doctype='Project' and timeline_name=%s)
|
||||
or (reference_doctype='Issue' and reference_name IN {issue_names})
|
||||
order by
|
||||
{issues_condition}
|
||||
order by
|
||||
modified DESC limit {start}, {limit}""".format(
|
||||
issue_names=issue_names, start=start, limit=10),
|
||||
issues_condition=issues_condition, start=start, limit=10),
|
||||
(project, project), as_dict=True);
|
||||
for timeline in timelines:
|
||||
timeline.user_image = frappe.db.get_value('User', timeline.modified_by, 'user_image')
|
||||
return timelines
|
||||
|
||||
return timelines
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_timelines_html(project, start=0):
|
||||
return frappe.render_template("erpnext/templates/includes/projects/timeline.html",
|
||||
{"doc": {"timelines": get_timeline(project, start)}}, is_path=True)
|
||||
|
||||
return frappe.render_template("erpnext/templates/includes/projects/timeline.html",
|
||||
{"doc": {"timelines": get_timeline(project, start)}}, is_path=True)
|
||||
|
||||
def get_issue_list(project):
|
||||
return [issue.name for issue in get_issues(project)]
|
||||
|
||||
@@ -64,12 +69,12 @@ def get_tasks(project, start=0, search=None, item_status=None):
|
||||
filters = {"project": project}
|
||||
if search:
|
||||
filters["subject"] = ("like", "%{0}%".format(search))
|
||||
if item_status:
|
||||
filters = {"status": item_status}
|
||||
tasks = frappe.get_all("Task", filters=filters,
|
||||
fields=["name", "subject", "status", "exp_start_date", "exp_end_date", "priority"],
|
||||
limit_start=start, limit_page_length=10)
|
||||
|
||||
if item_status:
|
||||
filters = {"status": item_status}
|
||||
tasks = frappe.get_all("Task", filters=filters,
|
||||
fields=["name", "subject", "status", "exp_start_date", "exp_end_date", "priority"],
|
||||
limit_start=start, limit_page_length=10)
|
||||
|
||||
for task in tasks:
|
||||
print task._comments
|
||||
task.todo = frappe.get_all('ToDo',filters={'reference_name':task.name, 'reference_type':'Task'},
|
||||
@@ -78,67 +83,66 @@ def get_tasks(project, start=0, search=None, item_status=None):
|
||||
task.todo=task.todo[0]
|
||||
task.todo.user_image = frappe.db.get_value('User', task.todo.owner, 'user_image')
|
||||
if task._comments:
|
||||
task.comment_count = len(json.loads(_comments or "[]"))
|
||||
task.comment_count = len(json.loads(task._comments or "[]"))
|
||||
return tasks
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_tasks_html(project, start=0, item_status=None):
|
||||
return frappe.render_template("erpnext/templates/includes/projects/project_tasks.html",
|
||||
return frappe.render_template("erpnext/templates/includes/projects/project_tasks.html",
|
||||
{"doc": {"tasks": get_tasks(project, start, item_status=item_status)}}, is_path=True)
|
||||
|
||||
|
||||
|
||||
|
||||
def get_issues(project, start=0, search=None, item_status=None):
|
||||
filters = {"project": project}
|
||||
if search:
|
||||
filters["subject"] = ("like", "%{0}%".format(search))
|
||||
if item_status:
|
||||
filters = {"status": item_status}
|
||||
issues = frappe.get_all("Issue", filters=filters,
|
||||
fields=["name", "subject", "status", "opening_date", "resolution_date", "resolution_details"],
|
||||
if item_status:
|
||||
filters = {"status": item_status}
|
||||
issues = frappe.get_all("Issue", filters=filters,
|
||||
fields=["name", "subject", "status", "opening_date", "resolution_date", "resolution_details"],
|
||||
order_by='modified desc',
|
||||
limit_start=start, limit_page_length=10)
|
||||
|
||||
limit_start=start, limit_page_length=10)
|
||||
|
||||
for issue in issues:
|
||||
issue.todo = frappe.get_all('ToDo',filters={'reference_name':issue.name, 'reference_type':'Issue'},
|
||||
fields=["assigned_by", "owner", "modified", "modified_by"])
|
||||
if issue.todo:
|
||||
issue.todo=issue.todo[0]
|
||||
issue.todo.user_image = frappe.db.get_value('User', issue.todo.owner, 'user_image')
|
||||
|
||||
|
||||
return issues
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_issues_html(project, start=0, item_status=None):
|
||||
return frappe.render_template("erpnext/templates/includes/projects/project_issues.html",
|
||||
{"doc": {"issues": get_issues(project, start, item_status=item_status)}}, is_path=True)
|
||||
|
||||
return frappe.render_template("erpnext/templates/includes/projects/project_issues.html",
|
||||
{"doc": {"issues": get_issues(project, start, item_status=item_status)}}, is_path=True)
|
||||
|
||||
def get_timelogs(project, start=0, search=None):
|
||||
filters = {"project": project}
|
||||
if search:
|
||||
filters["title"] = ("like", "%{0}%".format(search))
|
||||
|
||||
timelogs = frappe.get_all('Time Log', filters=filters,
|
||||
|
||||
timelogs = frappe.get_all('Time Log', filters=filters,
|
||||
fields=['name','title','task','activity_type','from_time','to_time','hours','status','modified','modified_by'],
|
||||
limit_start=start, limit_page_length=10)
|
||||
limit_start=start, limit_page_length=10)
|
||||
for timelog in timelogs:
|
||||
timelog.user_image = frappe.db.get_value('User', timelog.modified_by, 'user_image')
|
||||
timelog.user_image = frappe.db.get_value('User', timelog.modified_by, 'user_image')
|
||||
return timelogs
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_timelogs_html(project, start=0):
|
||||
return frappe.render_template("erpnext/templates/includes/projects/project_timelogs.html",
|
||||
{"doc": {"timelogs": get_timelogs(project, start)}}, is_path=True)
|
||||
|
||||
@frappe.whitelist()
|
||||
return frappe.render_template("erpnext/templates/includes/projects/project_timelogs.html",
|
||||
{"doc": {"timelogs": get_timelogs(project, start)}}, is_path=True)
|
||||
|
||||
@frappe.whitelist()
|
||||
def set_task_status(project, item_name):
|
||||
task = frappe.get_doc("Task", item_name)
|
||||
task.status = 'Closed'
|
||||
task.save(ignore_permissions=True)
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
@frappe.whitelist()
|
||||
def set_issue_status(project, item_name):
|
||||
issue = frappe.get_doc("Issue", item_name)
|
||||
issue.status = 'Closed'
|
||||
issue.save(ignore_permissions=True)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user