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.
 
 
 
 
 
 

37 line
1.4 KiB

  1. # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
  2. # MIT License. See license.txt
  3. # Event
  4. # -------------
  5. from __future__ import unicode_literals
  6. import webnotes
  7. @webnotes.whitelist()
  8. def get_cal_events(m_st, m_end):
  9. import webnotes.model.doc
  10. sql = webnotes.conn.sql
  11. # load owned events
  12. res1 = sql("select name from `tabEvent` WHERE ifnull(event_date,'2000-01-01') between '%s' and '%s' and owner = '%s' and event_type != 'Public' and event_type != 'Cancel'" % (m_st, m_end, webnotes.user.name))
  13. # load individual events
  14. res2 = sql("select t1.name from `tabEvent` t1, `tabEvent User` t2 where ifnull(t1.event_date,'2000-01-01') between '%s' and '%s' and t2.person = '%s' and t1.name = t2.parent and t1.event_type != 'Cancel'" % (m_st, m_end, webnotes.user.name))
  15. # load role events
  16. roles = webnotes.user.get_roles()
  17. myroles = ['t2.role = "%s"' % r for r in roles]
  18. myroles = '(' + (' OR '.join(myroles)) + ')'
  19. res3 = sql("select t1.name from `tabEvent` t1, `tabEvent Role` t2 where ifnull(t1.event_date,'2000-01-01') between '%s' and '%s' and t1.name = t2.parent and t1.event_type != 'Cancel' and %s" % (m_st, m_end, myroles))
  20. # load public events
  21. res4 = sql("select name from `tabEvent` where ifnull(event_date,'2000-01-01') between '%s' and '%s' and event_type='Public'" % (m_st, m_end))
  22. doclist, rl = [], []
  23. for r in res1 + res2 + res3 + res4:
  24. if not r in rl:
  25. doclist += webnotes.model.doc.get('Event', r[0])
  26. rl.append(r)
  27. return doclist