Rushabh Mehta | ad45e31 | 2013-11-20 12:59:58 +0530 | [diff] [blame] | 1 | # Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors |
Rushabh Mehta | e67d1fb | 2013-08-05 14:59:54 +0530 | [diff] [blame] | 2 | # License: GNU General Public License v3. See license.txt |
| 3 | |
Anand Doshi | 486f9df | 2012-07-19 13:40:31 +0530 | [diff] [blame] | 4 | from __future__ import unicode_literals |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 5 | import frappe |
Anand Doshi | bedc62f | 2014-04-04 16:26:45 +0530 | [diff] [blame] | 6 | from frappe.utils import cint |
Rushabh Mehta | 12852e7 | 2012-02-29 15:11:06 +0530 | [diff] [blame] | 7 | |
Rushabh Mehta | 793ba6b | 2014-02-14 15:47:51 +0530 | [diff] [blame] | 8 | @frappe.whitelist() |
Rushabh Mehta | 12852e7 | 2012-02-29 15:11:06 +0530 | [diff] [blame] | 9 | def get_feed(arg=None): |
Anand Doshi | bedc62f | 2014-04-04 16:26:45 +0530 | [diff] [blame] | 10 | """get feed""" |
Nabin Hait | 4d713ac | 2014-03-03 15:51:13 +0530 | [diff] [blame] | 11 | roles = frappe.get_roles() |
Anand Doshi | e9baaa6 | 2014-02-26 12:35:33 +0530 | [diff] [blame] | 12 | return frappe.db.sql("""select |
Rushabh Mehta | 12852e7 | 2012-02-29 15:11:06 +0530 | [diff] [blame] | 13 | distinct t1.name, t1.feed_type, t1.doc_type, t1.doc_name, t1.subject, t1.owner, |
| 14 | t1.modified |
| 15 | from tabFeed t1, tabDocPerm t2 |
| 16 | where t1.doc_type = t2.parent |
Nabin Hait | 4d713ac | 2014-03-03 15:51:13 +0530 | [diff] [blame] | 17 | and t2.role in (%s) |
Anand Doshi | e142d9c | 2013-01-02 16:46:35 +0530 | [diff] [blame] | 18 | and t2.permlevel = 0 |
Rushabh Mehta | 12852e7 | 2012-02-29 15:11:06 +0530 | [diff] [blame] | 19 | and ifnull(t2.`read`,0) = 1 |
| 20 | order by t1.modified desc |
Anand Doshi | bedc62f | 2014-04-04 16:26:45 +0530 | [diff] [blame] | 21 | limit %s, %s""" % (','.join(['%s']*len(roles)), '%s', '%s'), |
| 22 | tuple(roles + [cint(frappe.form_dict['limit_start']), cint(frappe.form_dict['limit_page_length'])]), |
| 23 | as_dict=1) |