def feed(self, session, message='', page='1', who='', what='', action=''): feed = session.query(Tracking).filter( Tracking.action != c.AUTO_BADGE_SHIFT).order_by( Tracking.when.desc()) what = what.strip() if who: feed = feed.filter_by(who=who) if what: like = '%' + what + '%' # SQLAlchemy should have an icontains for this feed = feed.filter( or_(Tracking.data.ilike(like), Tracking.which.ilike(like))) if action: feed = feed.filter_by(action=action) return { 'message': message, 'who': who, 'what': what, 'page': page, 'action': action, 'count': feed.count(), 'feed': get_page(page, feed), 'action_opts': [opt for opt in c.TRACKING_OPTS if opt[0] != c.AUTO_BADGE_SHIFT], 'who_opts': [ who for [who] in session.query(Tracking).distinct().order_by( Tracking.who).values(Tracking.who) ] }
def index(self, session, page='1', search_text=''): emails = session.query(Email).order_by(Email.when.desc()) search_text = search_text.strip() if search_text: emails = emails.icontains(Email.dest, search_text) return { 'page': page, 'emails': get_page(page, emails), 'count': emails.count(), 'search_text': search_text }
def index(self, session, page='1', search_text=''): emails = session.query(Email).order_by(Email.when.desc()) search_text = search_text.strip() if search_text: emails = emails.icontains(Email.to, search_text) return { 'page': page, 'emails': get_page(page, emails), 'count': emails.count(), 'search_text': search_text }
def feed(self, session, message='', page='1', who='', what='', action=''): feed = session.query(Tracking).filter(Tracking.action != c.AUTO_BADGE_SHIFT).order_by(Tracking.when.desc()) what = what.strip() if who: feed = feed.filter_by(who=who) if what: like = '%' + what + '%' # SQLAlchemy should have an icontains for this feed = feed.filter(or_(Tracking.data.ilike(like), Tracking.which.ilike(like))) if action: feed = feed.filter_by(action=action) return { 'message': message, 'who': who, 'what': what, 'page': page, 'action': action, 'count': feed.count(), 'feed': get_page(page, feed), 'action_opts': [opt for opt in c.TRACKING_OPTS if opt[0] != c.AUTO_BADGE_SHIFT], 'who_opts': [ who for [who] in session.query(Tracking).distinct().order_by(Tracking.who).values(Tracking.who)] }