Anand Doshi | 620145c | 2013-12-16 19:28:11 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
| 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
| 4 | from __future__ import unicode_literals |
| 5 | import webnotes |
| 6 | |
| 7 | def execute(): |
Anand Doshi | 620145c | 2013-12-16 19:28:11 +0530 | [diff] [blame] | 8 | # reset Page perms |
Anand Doshi | 8e332ff | 2013-12-26 18:30:39 +0530 | [diff] [blame] | 9 | from webnotes.core.page.permission_manager.permission_manager import reset |
Anand Doshi | 2298d59 | 2013-12-17 19:04:08 +0530 | [diff] [blame] | 10 | reset("Page") |
Anand Doshi | 9b67f43 | 2013-12-20 19:33:11 +0530 | [diff] [blame] | 11 | reset("Report") |
Anand Doshi | 2298d59 | 2013-12-17 19:04:08 +0530 | [diff] [blame] | 12 | |
| 13 | # patch to move print, email into DocPerm |
Anand Doshi | 9b67f43 | 2013-12-20 19:33:11 +0530 | [diff] [blame] | 14 | for doctype, hide_print, hide_email in webnotes.conn.sql("""select name, ifnull(allow_print, 0), ifnull(allow_email, 0) |
| 15 | from `tabDocType` where ifnull(issingle, 0)=0 and ifnull(istable, 0)=0 and |
| 16 | (ifnull(allow_print, 0)=0 or ifnull(allow_email, 0)=0)"""): |
| 17 | |
| 18 | if not hide_print: |
| 19 | webnotes.conn.sql("""update `tabDocPerm` set `print`=1 |
| 20 | where permlevel=0 and `read`=1 and parent=%s""", doctype) |
| 21 | |
| 22 | if not hide_email: |
| 23 | webnotes.conn.sql("""update `tabDocPerm` set `email`=1 |
| 24 | where permlevel=0 and `read`=1 and parent=%s""", doctype) |