blob: 8fab54a4b90836a8197bf814d19a53ffb0a5ee78 [file] [log] [blame]
Rushabh Mehtaad45e312013-11-20 12:59:58 +05301# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
Rushabh Mehtae67d1fb2013-08-05 14:59:54 +05302# License: GNU General Public License v3. See license.txt
3
Anand Doshi486f9df2012-07-19 13:40:31 +05304from __future__ import unicode_literals
Rushabh Mehta793ba6b2014-02-14 15:47:51 +05305import frappe
Rushabh Mehta12852e72012-02-29 15:11:06 +05306
Rushabh Mehta793ba6b2014-02-14 15:47:51 +05307@frappe.whitelist()
Rushabh Mehta12852e72012-02-29 15:11:06 +05308def get_feed(arg=None):
9 """get feed"""
Nabin Hait4d713ac2014-03-03 15:51:13 +053010 roles = frappe.get_roles()
Anand Doshie9baaa62014-02-26 12:35:33 +053011 return frappe.db.sql("""select
Rushabh Mehta12852e72012-02-29 15:11:06 +053012 distinct t1.name, t1.feed_type, t1.doc_type, t1.doc_name, t1.subject, t1.owner,
13 t1.modified
14 from tabFeed t1, tabDocPerm t2
15 where t1.doc_type = t2.parent
Nabin Hait4d713ac2014-03-03 15:51:13 +053016 and t2.role in (%s)
Anand Doshie142d9c2013-01-02 16:46:35 +053017 and t2.permlevel = 0
Rushabh Mehta12852e72012-02-29 15:11:06 +053018 and ifnull(t2.`read`,0) = 1
19 order by t1.modified desc
Nabin Hait4d713ac2014-03-03 15:51:13 +053020 limit %s, %s""" % (','.join(['%s']*len(roles)), '%s', '%s'),
21 tuple(roles + [frappe.form_dict['limit_start'], frappe.form_dict['limit_page_length']]),
22 as_dict=1)