added job application

This commit is contained in:
Rushabh Mehta 2013-01-15 17:23:23 +05:30
parent 0e7751b9fe
commit 3169ef0691
10 changed files with 208 additions and 12 deletions

View File

@ -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 <http://www.gnu.org/licenses/>.
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()

View File

@ -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
})
},
}

View File

@ -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",

View File

@ -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",

View File

@ -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"));
}
}
}

View File

@ -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)

View File

@ -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"
}
]

View File

@ -29,6 +29,9 @@ def execute_all():
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
run_fn(flush)

View File

@ -70,15 +70,6 @@ $.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];