From 6d76359c31e0a2abe297661516b19fa1b34251d0 Mon Sep 17 00:00:00 2001 From: Kanchan Chauhan Date: Tue, 5 Jul 2016 12:12:39 +0530 Subject: [PATCH] [WIP] Task statuses updated in website --- .../projects/doctype/timesheet/timesheet.json | 2 +- erpnext/projects/web_form/tasks/tasks.py | 7 ++- .../selling/doctype/quotation/quotation.json | 4 +- erpnext/templates/includes/macros.html | 1 - erpnext/templates/includes/projects.css | 1 + .../templates/includes/projects/macros.html | 2 - .../includes/projects/project_tasks.html | 35 ++++++++------ .../includes/projects/project_timelogs.html | 21 --------- .../includes/projects/project_timesheets.html | 23 +++++++++ erpnext/templates/pages/projects.html | 15 +++--- erpnext/templates/pages/projects.py | 47 ++++++++++--------- 11 files changed, 85 insertions(+), 73 deletions(-) delete mode 100644 erpnext/templates/includes/projects/macros.html delete mode 100644 erpnext/templates/includes/projects/project_timelogs.html create mode 100644 erpnext/templates/includes/projects/project_timesheets.html diff --git a/erpnext/projects/doctype/timesheet/timesheet.json b/erpnext/projects/doctype/timesheet/timesheet.json index 80c384e793..59af587a41 100644 --- a/erpnext/projects/doctype/timesheet/timesheet.json +++ b/erpnext/projects/doctype/timesheet/timesheet.json @@ -617,5 +617,5 @@ "read_only": 0, "read_only_onload": 0, "sort_order": "ASC", - "track_seen": 0 + "track_seen": 1 } \ No newline at end of file diff --git a/erpnext/projects/web_form/tasks/tasks.py b/erpnext/projects/web_form/tasks/tasks.py index 2334f8b26d..6f387fe222 100644 --- a/erpnext/projects/web_form/tasks/tasks.py +++ b/erpnext/projects/web_form/tasks/tasks.py @@ -3,5 +3,8 @@ from __future__ import unicode_literals import frappe def get_context(context): - # do your magic here - pass + if frappe.form_dict.project: + context.parents = [{'title': frappe.form_dict.project, 'route': '/projects?project='+ frappe.form_dict.project}] + + elif context.doc and context.doc.get('project'): + context.parents = [{'title': context.doc.project, 'route': '/projects?project='+ context.doc.project}] \ No newline at end of file diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json index 037f1e848d..f07bc8e535 100644 --- a/erpnext/selling/doctype/quotation/quotation.json +++ b/erpnext/selling/doctype/quotation/quotation.json @@ -6,6 +6,7 @@ "beta": 0, "creation": "2013-05-24 19:29:08", "custom": 0, + "default_print_format": "test123", "docstatus": 0, "doctype": "DocType", "document_type": "Document", @@ -2125,6 +2126,7 @@ "hide_toolbar": 0, "icon": "icon-shopping-cart", "idx": 82, + "image_view": 0, "in_create": 0, "in_dialog": 0, "is_submittable": 1, @@ -2132,7 +2134,7 @@ "istable": 0, "max_attachments": 1, "menu_index": 0, - "modified": "2016-05-10 12:16:13.978635", + "modified": "2016-07-05 16:44:01.301063", "modified_by": "Administrator", "module": "Selling", "name": "Quotation", diff --git a/erpnext/templates/includes/macros.html b/erpnext/templates/includes/macros.html index 8dc433a259..da21748f77 100644 --- a/erpnext/templates/includes/macros.html +++ b/erpnext/templates/includes/macros.html @@ -12,4 +12,3 @@ {%- endif %} {% endmacro %} - diff --git a/erpnext/templates/includes/projects.css b/erpnext/templates/includes/projects.css index 1f758e3bca..5a717fc669 100644 --- a/erpnext/templates/includes/projects.css +++ b/erpnext/templates/includes/projects.css @@ -21,6 +21,7 @@ .item-timestamp { font-size: 10px; + margin-left: 15px; } .page-container .project-item { padding-top: 5px; diff --git a/erpnext/templates/includes/projects/macros.html b/erpnext/templates/includes/projects/macros.html deleted file mode 100644 index 5b22583049..0000000000 --- a/erpnext/templates/includes/projects/macros.html +++ /dev/null @@ -1,2 +0,0 @@ -{% macro back_link(doc) %}&back-to=/projects?project={{ doc.name }}&back-to-title={{ doc.project_name }}{% endmacro %} - diff --git a/erpnext/templates/includes/projects/project_tasks.html b/erpnext/templates/includes/projects/project_tasks.html index b4e5cece54..e978a7d09a 100644 --- a/erpnext/templates/includes/projects/project_tasks.html +++ b/erpnext/templates/includes/projects/project_tasks.html @@ -1,27 +1,32 @@ -{%- from "templates/includes/projects/macros.html" import back_link -%} - {% for task in doc.tasks %}
+
- {% endfor %} diff --git a/erpnext/templates/includes/projects/project_timelogs.html b/erpnext/templates/includes/projects/project_timelogs.html deleted file mode 100644 index c9a40b350c..0000000000 --- a/erpnext/templates/includes/projects/project_timelogs.html +++ /dev/null @@ -1,21 +0,0 @@ -{%- from "templates/includes/projects/macros.html" import back_link -%} - -{% for timelog in doc.timelogs %} - -{% endfor %} \ No newline at end of file diff --git a/erpnext/templates/includes/projects/project_timesheets.html b/erpnext/templates/includes/projects/project_timesheets.html new file mode 100644 index 0000000000..fb44017fa8 --- /dev/null +++ b/erpnext/templates/includes/projects/project_timesheets.html @@ -0,0 +1,23 @@ +{% for timesheet in doc.timesheets %} + +{% endfor %} \ No newline at end of file diff --git a/erpnext/templates/pages/projects.html b/erpnext/templates/pages/projects.html index f50d455b17..aeee602877 100644 --- a/erpnext/templates/pages/projects.html +++ b/erpnext/templates/pages/projects.html @@ -2,7 +2,6 @@ {% block title %}{{ doc.project_name }}{% endblock %} -{%- from "templates/includes/projects/macros.html" import back_link -%} {% block header %}

{{ doc.project_name }}

{% endblock %} @@ -25,11 +24,11 @@

{{ _("Tasks") }}

- New task + New task

-{{ _("Show closed") }} +

{% if doc.tasks %} @@ -46,17 +45,17 @@
-

{{ _("Time Logs") }}

+

{{ _("Timesheets") }}

-{% if doc.timelogs %} +{% if doc.timesheets %}
- {% include "erpnext/templates/includes/projects/project_timelogs.html" %} + {% include "erpnext/templates/includes/projects/project_timesheets.html" %}
- {% if doc.timelogs|length > 9 %} + {% if doc.timesheets|length > 9 %}

{{ _("More") }}

{% endif %} {% else %} -

No time logs

+

No time sheets

{% endif %}
diff --git a/erpnext/templates/pages/projects.py b/erpnext/templates/pages/projects.py index 25b3a672ce..d68770dc4d 100644 --- a/erpnext/templates/pages/projects.py +++ b/erpnext/templates/pages/projects.py @@ -11,7 +11,6 @@ def get_context(context): raise frappe.PermissionError context.no_cache = 1 - context.show_search = True context.show_sidebar = True project = frappe.get_doc('Project', frappe.form_dict.project) @@ -20,9 +19,8 @@ def get_context(context): project.tasks = get_tasks(project.name, start=0, item_status='open', search=frappe.form_dict.get("search")) - project.timelogs = [] - # project.timelogs = get_timelogs(project.name, start=0, - # search=frappe.form_dict.get("search")) + project.timesheets = get_timesheets(project.name, start=0, + search=frappe.form_dict.get("search")) context.doc = project @@ -32,8 +30,8 @@ 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 + # if item_status: +# filters["status"] = item_status tasks = frappe.get_all("Task", filters=filters, fields=["name", "subject", "status", "_seen", "_comments", "modified", "description"], limit_start=start, limit_page_length=10) @@ -65,27 +63,32 @@ def get_task_html(project, start=0, item_status=None): "tasks": get_tasks(project, start, item_status=item_status)} }, is_path=True) -def get_timelogs(project, start=0, search=None): +def get_timesheets(project, start=0, search=None): filters = {"project": project} if search: - filters["title"] = ("like", "%{0}%".format(search)) + filters["activity_type"] = ("like", "%{0}%".format(search)) - timelogs = frappe.get_all('Time Log', filters=filters, - fields=['name','title','task','activity_type','from_time','to_time','_comments','_seen','status','modified','modified_by'], + timesheets = frappe.get_all('Timesheet Detail', filters=filters, + fields=['project','activity_type','from_time','to_time','parent'], 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.comment_count = len(json.loads(timelog._comments or "[]")) + for timesheet in timesheets: + timesheet.infos = frappe.get_all('Timesheet', filters={"name": timesheet.parent}, + fields=['name','_comments','_seen','status','modified','modified_by'], + limit_start=start, limit_page_length=10) - timelog.css_seen = '' - if timelog._seen: - if frappe.session.user in json.loads(timelog._seen): - timelog.css_seen = 'seen' - return timelogs + for timesheet.info in timesheet.infos: + timesheet.info.user_image = frappe.db.get_value('User', timesheet.info.modified_by, 'user_image') + + timesheet.info.comment_count = len(json.loads(timesheet.info._comments or "[]")) + + timesheet.info.css_seen = '' + if timesheet.info._seen: + if frappe.session.user in json.loads(timesheet.info._seen): + timesheet.info.css_seen = 'seen' + return timesheets @frappe.whitelist() -def get_timelog_html(project, start=0): - return frappe.render_template("erpnext/templates/includes/projects/project_timelogs.html", - {"doc": {"timelogs": get_timelogs(project, start)}}, is_path=True) +def get_timesheet_html(project, start=0): + return frappe.render_template("erpnext/templates/includes/projects/project_timesheets.html", + {"doc": {"timesheets": get_timesheets(project, start)}}, is_path=True)