You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
1.4 KiB

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