Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

54 linhas
2.3 KiB

  1. # Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
  2. #
  3. # MIT License (MIT)
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a
  6. # copy of this software and associated documentation files (the "Software"),
  7. # to deal in the Software without restriction, including without limitation
  8. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. # and/or sell copies of the Software, and to permit persons to whom the
  10. # Software is furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  17. # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  19. # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  20. # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. #
  22. from __future__ import unicode_literals
  23. import webnotes, conf
  24. def sendmail_md(recipients, sender=None, msg=None, subject=None):
  25. """send markdown email"""
  26. import markdown2
  27. sendmail(recipients, sender, markdown2.markdown(msg), subject)
  28. def sendmail(recipients, sender='', msg='', subject='[No Subject]'):
  29. """send an html email as multipart with attachments and all"""
  30. from webnotes.utils.email_lib.smtp import get_email
  31. get_email(recipients, sender, msg, subject).send()
  32. @webnotes.whitelist()
  33. def get_contact_list():
  34. """Returns contacts (from autosuggest)"""
  35. cond = ['`%s` like "%s%%"' % (f,
  36. webnotes.form_dict.get('txt')) for f in webnotes.form_dict.get('where').split(',')]
  37. cl = webnotes.conn.sql("select `%s` from `tab%s` where %s" % (
  38. webnotes.form_dict.get('select')
  39. ,webnotes.form_dict.get('from')
  40. ,' OR '.join(cond)
  41. )
  42. )
  43. webnotes.response['cl'] = filter(None, [c[0] for c in cl])
  44. def get_system_managers():
  45. return webnotes.conn.sql_list("""select parent FROM tabUserRole
  46. WHERE role='System Manager'
  47. AND parent!='Administrator'
  48. AND parent IN
  49. (SELECT email FROM tabProfile WHERE enabled=1)""")