From 17db39dc943d0a4cdb3dbb13fc3db3a0bfeb8b14 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Sat, 24 Nov 2012 14:45:31 +0530 Subject: [PATCH] moving support ticket response to communication (wip) --- .../doctype/support_ticket/support_ticket.js | 4 ++-- .../doctype/support_ticket/support_ticket.py | 22 +++++++++---------- utilities/page/calendar/calendar.html | 2 +- utilities/page/calendar/calendar.js | 13 ++++++++++- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/support/doctype/support_ticket/support_ticket.js b/support/doctype/support_ticket/support_ticket.js index 6ab2c68972..8828bbb2e2 100644 --- a/support/doctype/support_ticket/support_ticket.js +++ b/support/doctype/support_ticket/support_ticket.js @@ -86,8 +86,8 @@ $.extend(cur_frm.cscript, { parent: $a(cur_frm.fields_dict['thread_html'].wrapper, 'div'), no_result_message: 'No responses yet', get_query: function() { - return 'select mail, from_email, creation, content_type '+ - 'from `tabSupport Ticket Response` where parent="'+doc.name+'" order by creation asc' + return 'select content, email_address, creation '+ + 'from `tabCommunication` where support_ticket="'+doc.name+'" order by creation asc' }, as_dict: 1, render_row: function(parent, data, list, idx) { diff --git a/support/doctype/support_ticket/support_ticket.py b/support/doctype/support_ticket/support_ticket.py index 39686187b6..84bdfd2fff 100644 --- a/support/doctype/support_ticket/support_ticket.py +++ b/support/doctype/support_ticket/support_ticket.py @@ -64,8 +64,8 @@ class DocType(TransactionBase): def last_response(self): """return last response""" - tmp = webnotes.conn.sql("""select mail from `tabSupport Ticket Response` - where parent = %s order by creation desc limit 1 + tmp = webnotes.conn.sql("""select mail from `tabCommunication` + where support_ticket = %s order by creation desc limit 1 """, self.doc.name) if not tmp: @@ -84,17 +84,17 @@ class DocType(TransactionBase): def make_response_record(self, response, from_email = None, content_type='text/plain'): """ - Creates a new Support Ticket Response record + Creates a new Communication record """ - # add to Support Ticket Response + # add to Communication from webnotes.model.doc import Document - d = Document('Support Ticket Response') - d.from_email = from_email or webnotes.user.name - d.parent = self.doc.name - d.parenttype = "Support Ticket" - d.parentfield = "responses" - d.mail = response - d.content_type = content_type + d = Document('Communication') + d.naming_series = "COMM-" + d.subject = self.doc.subject + d.email_address = from_email or webnotes.user.name + d.support_ticket = self.doc.name + d.content = response + d.communication_medium = "Email" d.save(1) def close_ticket(self): diff --git a/utilities/page/calendar/calendar.html b/utilities/page/calendar/calendar.html index 11dd3bf98a..0f8cc0ea47 100644 --- a/utilities/page/calendar/calendar.html +++ b/utilities/page/calendar/calendar.html @@ -13,7 +13,7 @@ - diff --git a/utilities/page/calendar/calendar.js b/utilities/page/calendar/calendar.js index 0f4ff3b639..e7abbabb63 100644 --- a/utilities/page/calendar/calendar.js +++ b/utilities/page/calendar/calendar.js @@ -241,9 +241,19 @@ Calendar.prototype.set_event = function(ev) { //------------------------------------------------------ -Calendar.prototype.refresh = function(viewtype){//Sets the viewtype of the Calendar and Calls the View class based on the viewtype +Calendar.prototype.clear = function() { + this.events = {}; + this.events_by_name = {}; + locals.Event = {}; +} + +Calendar.prototype.refresh = function(viewtype, clear_events){//Sets the viewtype of the Calendar and Calls the View class based on the viewtype if(viewtype) this.viewtype = viewtype; + + if(clear_events) + this.clear(); + // switch view if reqd if(this.cur_view.viewtype!=this.viewtype) { this.cur_view.hide(); @@ -252,6 +262,7 @@ Calendar.prototype.refresh = function(viewtype){//Sets the viewtype of the Calen this.cur_view.show(); } else{ + this.cur_view.get_events(); this.cur_view.refresh(this); } }