def remove_bulletin(self,bulletin_id,user_id): query = Bulletin.select().where(Bulletin.id == bulletin_id , Bulletin.fk_user == user_id) if query.count() > 0 : BulletinFilter.delete().where(BulletinFilter.fk_bulletin == bulletin_id).execute() query = (Bulletin.delete().where(Bulletin.id== bulletin_id).execute()) return True return False
def get_user_bulletin(self, user_id): query = (Bulletin.select( Bulletin.id, BulletinFilter.query_text, Source.title.alias('source'), BulletinFilter.scan_period, BulletinFilter.starred, Source.id.alias('source_id')).join(BulletinFilter).join( Source, JOIN_LEFT_OUTER).naive().where(Bulletin.fk_user == user_id)) ll = [] if query.count() > 0: query = query.execute() for index, ft in enumerate(query): ll.append({ 'index': index + 1, 'query_text': ft.query_text, 'source': ft.source, 'id': ft.id, 'source_id': ft.source_id, 'scan_period': ft.scan_period, 'starred': ft.starred }) return ll '''
def remove_bulletin_filter(self, filter_id, user_id): query = Bulletin.select().join(BulletinFilter).where( BulletinFilter.id == filter_id, Bulletin.fk_user == user_id) if query.count() > 0: query = (BulletinFilter.delete().where( BulletinFilter.id == filter_id).execute()) return True return False
def get_bulletin_filter(self,bulletin_id,user_id): query = (Bulletin.select(Bulletin.id,fn.isnull(BulletinFilter.query_text,"").alias('query_text'), fn.isnull(Source.title,SQL("'همه منابع'")).alias('source') ) .join(BulletinFilter).join(Source).naive().where(Bulletin.id==bulletin_id , Bulletin.fk_user== user_id ).execute()) ll = [] for index,ft in enumerate( query): ll.append({'index':index+1,'query_text':ft.query_text if ft.query_text != None else '' , 'source':ft.source ,'id':ft.id,'source_id':ft.source_id}) return ll
def remove_bulletin(self, bulletin_id, user_id): query = Bulletin.select().where(Bulletin.id == bulletin_id, Bulletin.fk_user == user_id) if query.count() > 0: BulletinFilter.delete().where( BulletinFilter.fk_bulletin == bulletin_id).execute() query = (Bulletin.delete().where( Bulletin.id == bulletin_id).execute()) return True return False
def get_user_bulletin(self, user_id): query = (Bulletin.select(Bulletin.id, BulletinFilter.query_text, Source.title.alias('source'), BulletinFilter.scan_period, BulletinFilter.starred, Source.id.alias('source_id')) .join(BulletinFilter).join(Source,JOIN_LEFT_OUTER).naive().where(Bulletin.fk_user == user_id)) ll = [] if query.count() > 0 : query = query.execute() for index, ft in enumerate(query): ll.append({'index':index + 1, 'query_text':ft.query_text, 'source':ft.source, 'id':ft.id, 'source_id':ft.source_id, 'scan_period':ft.scan_period, 'starred':ft.starred}) return ll '''
def get_bulletin_filter(self, bulletin_id, user_id): query = (Bulletin.select( Bulletin.id, fn.isnull(BulletinFilter.query_text, "").alias('query_text'), fn.isnull(Source.title, SQL("'همه منابع'")).alias('source')).join( BulletinFilter).join(Source).naive().where( Bulletin.id == bulletin_id, Bulletin.fk_user == user_id).execute()) ll = [] for index, ft in enumerate(query): ll.append({ 'index': index + 1, 'query_text': ft.query_text if ft.query_text != None else '', 'source': ft.source, 'id': ft.id, 'source_id': ft.source_id }) return ll
def remove_bulletin_filter(self,filter_id,user_id): query = Bulletin.select().join(BulletinFilter).where(BulletinFilter.id == filter_id , Bulletin.fk_user == user_id) if query.count() > 0 : query = (BulletinFilter.delete().where(BulletinFilter.id== filter_id).execute()) return True return False