diff --git a/hr/doctype/job_applicant/get_job_applications.py b/hr/doctype/job_applicant/get_job_applications.py new file mode 100644 index 0000000000..c5066dcc4e --- /dev/null +++ b/hr/doctype/job_applicant/get_job_applications.py @@ -0,0 +1,55 @@ +# ERPNext - web based ERP (http://erpnext.com) +# Copyright (C) 2012 Web Notes Technologies Pvt Ltd +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cstr, cint +from webnotes.utils.email_lib.receive import POP3Mailbox +from core.doctype.communication.communication import make + +class JobsMailbox(POP3Mailbox): + def setup(self): + self.settings = webnotes.doc("Jobs Email Settings", "Jobs Email Settings") + + def check_mails(self): + return webnotes.conn.sql("select user from tabSessions where \ + time_to_sec(timediff(now(), lastupdate)) < 1800") + + def get_existing_application(self, email_id): + name = webnotes.conn.sql("""select name from `tabJob Applicant` where + email_id = %s""", email_id) + return name and name[0][0] or None + + def process_message(self, mail): + name = self.get_existing_application(mail.from_email) + if name: + applicant = webnotes.model_wrapper("Job Applicant", name) + else: + applicant = webnotes.model_wrapper({ + "doctype":"Job Applicant", + "applicant_name": mail.from_real_name or mail.from_email, + "email_id": mail.from_email + }) + applicant.insert() + + mail.save_attachments_in_doc(applicant.doc) + + make(content=mail.content, sender=mail.from_email, + doctype="Job Applicant", name=applicant.doc.name, set_lead=False) + +def get_job_applications(): + if cint(webnotes.conn.get_value('Jobs Email Settings', None, 'extract_emails')): + JobsMailbox() \ No newline at end of file diff --git a/hr/doctype/job_applicant/job_applicant.js b/hr/doctype/job_applicant/job_applicant.js new file mode 100644 index 0000000000..2b8e064e8d --- /dev/null +++ b/hr/doctype/job_applicant/job_applicant.js @@ -0,0 +1,22 @@ +// For license information, please see license.txt + +cur_frm.cscript = { + refresh: function(doc) { + cur_frm.set_intro(""); + if(doc.extract_emails) { + cur_frm.set_intro(wn._("Active: Will extract emails from ") + doc.email_id); + } else { + cur_frm.set_intro(wn._("Not Active")); + } + cur_frm.cscript.make_listing(doc); + }, + make_listing: function(doc) { + var wrapper = cur_frm.fields_dict['thread_html'].wrapper; + cur_frm.communication_view = new wn.views.CommunicationList({ + list: comm_list, + parent: wn.model.get("Communication", {"job_applicant": doc.name}), + doc: doc, + recipients: doc.email_id + }) + }, +} \ No newline at end of file diff --git a/hr/doctype/job_applicant/job_applicant.txt b/hr/doctype/job_applicant/job_applicant.txt index 3031211f3b..390b659a99 100644 --- a/hr/doctype/job_applicant/job_applicant.txt +++ b/hr/doctype/job_applicant/job_applicant.txt @@ -4,7 +4,7 @@ "docstatus": 0, "creation": "2013-01-15 16:32:13", "modified_by": "Administrator", - "modified": "2013-01-15 16:32:13" + "modified": "2013-01-15 17:08:46" }, { "autoname": "field:applicant_name", @@ -47,6 +47,12 @@ "fieldtype": "Data", "reqd": 1 }, + { + "doctype": "DocField", + "label": "Email Id", + "fieldname": "email_id", + "fieldtype": "Data" + }, { "doctype": "DocField", "label": "Status", diff --git a/hr/doctype/job_opening/job_opening.txt b/hr/doctype/job_opening/job_opening.txt index bd994c6ad9..5e26f0d1c1 100644 --- a/hr/doctype/job_opening/job_opening.txt +++ b/hr/doctype/job_opening/job_opening.txt @@ -4,9 +4,10 @@ "docstatus": 0, "creation": "2013-01-15 16:13:36", "modified_by": "Administrator", - "modified": "2013-01-15 16:13:36" + "modified": "2013-01-15 16:43:05" }, { + "autoname": "field:job_title", "description": "Description of a Job Opening", "doctype": "DocType", "module": "HR", diff --git a/setup/doctype/jobs_email_settings/__init__.py b/setup/doctype/jobs_email_settings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/setup/doctype/jobs_email_settings/jobs_email_settings.js b/setup/doctype/jobs_email_settings/jobs_email_settings.js new file mode 100644 index 0000000000..0a75b89360 --- /dev/null +++ b/setup/doctype/jobs_email_settings/jobs_email_settings.js @@ -0,0 +1,12 @@ +// For license information, please see license.txt + +cur_frm.cscript = { + refresh: function(doc) { + cur_frm.set_intro(""); + if(doc.extract_emails) { + cur_frm.set_intro(wn._("Active: Will extract emails from ") + doc.email_id); + } else { + cur_frm.set_intro(wn._("Not Active")); + } + } +} \ No newline at end of file diff --git a/setup/doctype/jobs_email_settings/jobs_email_settings.py b/setup/doctype/jobs_email_settings/jobs_email_settings.py new file mode 100644 index 0000000000..b09cefd5e2 --- /dev/null +++ b/setup/doctype/jobs_email_settings/jobs_email_settings.py @@ -0,0 +1,17 @@ +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes import _ +from webnotes.utils import cint + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl + + def validate(self): + if cint(self.doc.extract_emails) and not (self.doc.email_id and self.doc.host and \ + self.doc.username and self.doc.password): + + webnotes.msgprint(_("""Host, Email and Password required if emails are to be pulled"""), + raise_exception=True) \ No newline at end of file diff --git a/setup/doctype/jobs_email_settings/jobs_email_settings.txt b/setup/doctype/jobs_email_settings/jobs_email_settings.txt new file mode 100644 index 0000000000..788f51b7e9 --- /dev/null +++ b/setup/doctype/jobs_email_settings/jobs_email_settings.txt @@ -0,0 +1,89 @@ +[ + { + "owner": "Administrator", + "docstatus": 0, + "creation": "2013-01-15 16:50:01", + "modified_by": "Administrator", + "modified": "2013-01-15 16:57:08" + }, + { + "issingle": 1, + "description": "Email settings for jobs email id \"jobs@example.com\"", + "doctype": "DocType", + "module": "Setup", + "name": "__common__" + }, + { + "name": "__common__", + "parent": "Jobs Email Settings", + "doctype": "DocField", + "parenttype": "DocType", + "permlevel": 0, + "parentfield": "fields" + }, + { + "parent": "Jobs Email Settings", + "read": 1, + "name": "__common__", + "create": 1, + "doctype": "DocPerm", + "write": 1, + "parenttype": "DocType", + "role": "System Manager", + "permlevel": 0, + "parentfield": "permissions" + }, + { + "name": "Jobs Email Settings", + "doctype": "DocType" + }, + { + "description": "Settings to extract Job Applicants from a mailbox e.g. \"jobs@example.com\"", + "doctype": "DocField", + "label": "POP3 Mail Settings", + "fieldname": "pop3_mail_settings", + "fieldtype": "Section Break" + }, + { + "description": "Check to activate", + "doctype": "DocField", + "label": "Extract Emails", + "fieldname": "extract_emails", + "fieldtype": "Check" + }, + { + "description": "Email Id where a job applicant will email e.g. \"jobs@example.com\"", + "doctype": "DocField", + "label": "Email Id", + "fieldname": "email_id", + "fieldtype": "Data" + }, + { + "description": "POP3 server e.g. (pop.gmail.com)", + "doctype": "DocField", + "label": "Host", + "fieldname": "host", + "fieldtype": "Data" + }, + { + "doctype": "DocField", + "label": "Use SSL", + "fieldname": "use_ssl", + "fieldtype": "Check" + }, + { + "doctype": "DocField", + "label": "Username", + "fieldname": "username", + "fieldtype": "Data" + }, + { + "doctype": "DocField", + "label": "Password", + "fieldname": "password", + "fieldtype": "Password" + }, + { + "doctype": "DocPerm" + } +] \ No newline at end of file diff --git a/startup/schedule_handlers.py b/startup/schedule_handlers.py index 54b9892b13..ab53b211ed 100644 --- a/startup/schedule_handlers.py +++ b/startup/schedule_handlers.py @@ -28,6 +28,9 @@ def execute_all(): # pull emails from support.doctype.support_ticket.get_support_mails import get_support_mails run_fn(get_support_mails) + + from hr.doctype.job_applicant.get_job_applications import get_job_applications + run_fn(get_job_applications) # bulk email from webnotes.utils.email_lib.bulk import flush diff --git a/support/doctype/support_ticket/support_ticket.js b/support/doctype/support_ticket/support_ticket.js index 28b08f8ccb..bbaf95b523 100644 --- a/support/doctype/support_ticket/support_ticket.js +++ b/support/doctype/support_ticket/support_ticket.js @@ -69,16 +69,7 @@ $.extend(cur_frm.cscript, { }) }, - - send: function(doc, dt, dn) { - $c_obj(make_doclist(doc.doctype, doc.name), 'send_response', '', function(r,rt) { - locals[dt][dn].new_response = ''; - if(!(r.exc || r.server_messages)) { - cur_frm.refresh(); - } - }); - }, - + customer: function(doc, dt, dn) { var callback = function(r,rt) { var doc = locals[cur_frm.doctype][cur_frm.docname];