本文整理汇总了Python中webnotes.model.doc.Document.content_type方法的典型用法代码示例。如果您正苦于以下问题:Python Document.content_type方法的具体用法?Python Document.content_type怎么用?Python Document.content_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webnotes.model.doc.Document
的用法示例。
在下文中一共展示了Document.content_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_response_record
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import content_type [as 别名]
def make_response_record(self, response, from_email = None, content_type='text/plain'):
"""
Creates a new Support Ticket Response record
"""
# add to Support Ticket Response
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.mail = response
d.content_type = content_type
d.save(1)
示例2: process_message
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import content_type [as 别名]
def process_message(self, mail):
"""
Updates message from support email as either new or reply
"""
from home import update_feed
content, content_type = '[Blank Email]', 'text/plain'
if mail.text_content:
content, content_type = mail.text_content, 'text/plain'
else:
content, content_type = mail.html_content, 'text/html'
thread_id = mail.get_thread_id()
if webnotes.conn.exists('Support Ticket', thread_id):
from webnotes.model.code import get_obj
st = get_obj('Support Ticket', thread_id)
st.make_response_record(content, mail.mail['From'], content_type)
webnotes.conn.set(st.doc, 'status', 'Open')
update_feed(st.doc)
return
# new ticket
from webnotes.model.doc import Document
d = Document('Support Ticket')
d.description = content
d.subject = mail.mail['Subject']
d.raised_by = mail.mail['From']
d.content_type = content_type
d.status = 'Open'
try:
d.save(1)
# update feed
update_feed(d)
# send auto reply
self.send_auto_reply(d)
except:
d.description = 'Unable to extract message'
d.save(1)
示例3: process_message
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import content_type [as 别名]
def process_message(self, mail):
"""
Updates message from support email as either new or reply
"""
from home import update_feed
content, content_type = '[Blank Email]', 'text/plain'
if mail.text_content:
content, content_type = mail.text_content, 'text/plain'
else:
content, content_type = mail.html_content, 'text/html'
thread_list = mail.get_thread_id()
email_id = mail.mail['From']
if "<" in mail.mail['From']:
import re
re_result = re.findall('(?<=\<)(\S+)(?=\>)', mail.mail['From'])
if re_result and re_result[0]: email_id = re_result[0]
from webnotes.utils import decode_email_header
full_email_id = decode_email_header(mail.mail['From'])
for thread_id in thread_list:
exists = webnotes.conn.sql("""\
SELECT name
FROM `tabSupport Ticket`
WHERE name=%s AND raised_by REGEXP %s
""" , (thread_id, '(' + email_id + ')'))
if exists and exists[0] and exists[0][0]:
from webnotes.model.code import get_obj
st = get_obj('Support Ticket', thread_id)
st.make_response_record(content, full_email_id, content_type)
# to update modified date
#webnotes.conn.set(st.doc, 'status', 'Open')
st.doc.status = 'Open'
st.doc.save()
update_feed(st.doc, 'on_update')
webnotes.conn.commit()
# extract attachments
self.save_attachments(st.doc, mail.attachments)
webnotes.conn.begin()
return
from webnotes.model.doctype import get_property
opts = get_property('Support Ticket', 'options', 'naming_series')
# new ticket
from webnotes.model.doc import Document
d = Document('Support Ticket')
d.description = content
d.subject = decode_email_header(mail.mail['Subject'])
d.raised_by = full_email_id
d.content_type = content_type
d.status = 'Open'
d.naming_series = opts and opts.split("\n")[0] or 'SUP'
try:
d.save(1)
except:
d.description = 'Unable to extract message'
d.save(1)
else:
# update feed
update_feed(d, 'on_update')
# send auto reply
if cint(self.email_settings.send_autoreply):
self.send_auto_reply(d)
webnotes.conn.commit()
# extract attachments
self.save_attachments(d, mail.attachments)
webnotes.conn.begin()
示例4: process_message
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import content_type [as 别名]
def process_message(self, mail):
"""
Updates message from support email as either new or reply
"""
from home import update_feed
content, content_type = '[Blank Email]', 'text/plain'
if mail.text_content:
content, content_type = mail.text_content, 'text/plain'
else:
content, content_type = mail.html_content, 'text/html'
thread_list = mail.get_thread_id()
email_id = mail.mail['From']
if "<" in mail.mail['From']:
import re
re_result = re.findall('(?<=\<)(\S+)(?=\>)', mail.mail['From'])
if re_result and re_result[0]: email_id = re_result[0]
for thread_id in thread_list:
exists = webnotes.conn.sql("""\
SELECT name
FROM `tabSupport Ticket`
WHERE name=%s AND raised_by REGEXP %s
""" , (thread_id, '(' + email_id + ')'))
if exists and exists[0] and exists[0][0]:
from webnotes.model.code import get_obj
st = get_obj('Support Ticket', thread_id)
st.make_response_record(content, mail.mail['From'], content_type)
webnotes.conn.set(st.doc, 'status', 'Open')
update_feed(st.doc)
# extract attachments
self.save_attachments(st.doc, mail.attachments)
return
opts = webnotes.conn.sql("""\
SELECT options FROM tabDocField
WHERE parent='Support Ticket' AND fieldname='naming_series'""")
# new ticket
from webnotes.model.doc import Document
d = Document('Support Ticket')
d.description = content
d.subject = mail.mail['Subject']
d.raised_by = mail.mail['From']
d.content_type = content_type
d.status = 'Open'
d.naming_series = (opts and opts[0] and opts[0][0] and opts[0][0].split("\n")[0]) or 'SUP'
try:
d.save(1)
# update feed
update_feed(d)
# send auto reply
self.send_auto_reply(d)
except:
d.description = 'Unable to extract message'
d.save(1)
else:
# extract attachments
self.save_attachments(d, mail.attachments)
示例5: process_message
# 需要导入模块: from webnotes.model.doc import Document [as 别名]
# 或者: from webnotes.model.doc.Document import content_type [as 别名]
def process_message(self, mail):
"""
Updates message from support email as either new or reply
"""
from home import update_feed
content, content_type = "[Blank Email]", "text/plain"
if mail.text_content:
content, content_type = mail.text_content, "text/plain"
else:
content, content_type = mail.html_content, "text/html"
thread_list = mail.get_thread_id()
email_id = mail.mail["From"]
if "<" in mail.mail["From"]:
import re
re_result = re.findall("(?<=\<)(\S+)(?=\>)", mail.mail["From"])
if re_result and re_result[0]:
email_id = re_result[0]
from webnotes.utils import decode_email_header
full_email_id = decode_email_header(mail.mail["From"])
for thread_id in thread_list:
exists = webnotes.conn.sql(
"""\
SELECT name
FROM `tabSupport Ticket`
WHERE name=%s AND raised_by REGEXP %s
""",
(thread_id, "(" + email_id + ")"),
)
if exists and exists[0] and exists[0][0]:
st = webnotes.get_obj("Support Ticket", thread_id)
from core.doctype.communication.communication import make
make(
content=content,
sender=full_email_id,
doctype="Support Ticket",
name=thread_id,
lead=st.doc.lead,
contact=st.doc.contact,
)
st.doc.status = "Open"
st.doc.save()
update_feed(st, "on_update")
# extract attachments
self.save_attachments(st.doc, mail.attachments)
return
from webnotes.model.doctype import get_property
opts = get_property("Support Ticket", "options", "naming_series")
# new ticket
from webnotes.model.doc import Document
d = Document("Support Ticket")
d.description = content
d.subject = decode_email_header(mail.mail["Subject"])
d.raised_by = full_email_id
d.content_type = content_type
d.status = "Open"
d.naming_series = opts and opts.split("\n")[0] or "SUP"
try:
d.save(1)
try:
# extract attachments
self.save_attachments(d, mail.attachments)
except Exception, e:
self.description += "\n\n[Did not pull attachment]"
except:
d.description = "Unable to extract message"
d.save(1)
else:
# send auto reply
if cint(self.email_settings.send_autoreply):
if "mailer-daemon" not in d.raised_by.lower():
self.send_auto_reply(d)