blob: 09b3297b992c0fc5941af4615bb5d2ea296cf5a5 [file] [log] [blame]
Anand Doshi486f9df2012-07-19 13:40:31 +05301from __future__ import unicode_literals
Rushabh Mehta5eb37642013-02-14 17:34:51 +05302
3import webnotes
4
5@webnotes.whitelist()
6def get_events(start, end):
7 roles = webnotes.get_roles()
8 events = webnotes.conn.sql("""select name as `id`, subject as title,
9 starts_on as `start`, ends_on as `end`, "Event" as doctype, owner
10 from tabEvent where event_date between %s and %s
11 and (event_type='Public' or owner=%s
12 or exists(select * from `tabEvent User` where
13 `tabEvent User`.parent=tabEvent.name and person=%s)
14 or exists(select * from `tabEvent Role` where
15 `tabEvent Role`.parent=tabEvent.name
16 and `tabEvent Role`.role in ('%s')))""" % ('%s', '%s', '%s', '%s',
17 "', '".join(roles)), (start, end,
18 webnotes.session.user, webnotes.session.user), as_dict=1, debug=1)
19
20 return events
21
22 block_days = webnotes.conn.sql("""select block_date as `start`,
23 name as `id`, reason as `title`, "Holiday List Block Date" as doctype,
24 where block_date between %s and %s
25 and """)
26
27@webnotes.whitelist()
28def update_event(name, start, end):
29 webnotes.conn.sql("""update tabEvent set starts_on=%s, ends_on=%s where
30 name=%s""", (start, end, name))
31