您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

__init__.py 1.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
  2. # MIT License. See license.txt
  3. from __future__ import unicode_literals
  4. import webnotes
  5. from webnotes import conf
  6. from webnotes.utils.email_lib.email_body import get_email
  7. from webnotes.utils.email_lib.smtp import send
  8. def sendmail_md(recipients, sender=None, msg=None, subject=None):
  9. """send markdown email"""
  10. import markdown2
  11. sendmail(recipients, sender, markdown2.markdown(msg), subject)
  12. def sendmail(recipients, sender='', msg='', subject='[No Subject]'):
  13. """send an html email as multipart with attachments and all"""
  14. send(get_email(recipients, sender, msg, subject))
  15. def sendmail_to_system_managers(subject, content):
  16. send(get_email(get_system_managers(), None, content, subject))
  17. @webnotes.whitelist()
  18. def get_contact_list():
  19. """Returns contacts (from autosuggest)"""
  20. cond = ['`%s` like "%s%%"' % (f,
  21. webnotes.form_dict.get('txt')) for f in webnotes.form_dict.get('where').split(',')]
  22. cl = webnotes.conn.sql("select `%s` from `tab%s` where %s" % (
  23. webnotes.form_dict.get('select')
  24. ,webnotes.form_dict.get('from')
  25. ,' OR '.join(cond)
  26. )
  27. )
  28. webnotes.response['cl'] = filter(None, [c[0] for c in cl])
  29. def get_system_managers():
  30. return webnotes.conn.sql_list("""select parent FROM tabUserRole
  31. WHERE role='System Manager'
  32. AND parent!='Administrator'
  33. AND parent IN
  34. (SELECT email FROM tabProfile WHERE enabled=1)""")