def ajax_list_catalog(self, catid): ''' Get posts of certain catid. In Json. ''' out_arr = {} for catinfo in MPost2Catalog.query_postinfo_by_cat(catid): out_arr[catinfo.uid] = catinfo.title json.dump(out_arr, self)
def delete_by_id(self, del_id): ''' Delete by id. ''' print("-" * 50) print(del_id) if self.check_post_role()['DELETE']: pass else: return False post_resc = MPost2Catalog.query_postinfo_by_cat(del_id) for post in post_resc: MPost2Catalog.remove_relation(post.uid, del_id) if MCategory.delete(del_id): output = {'del_link': 1} else: output = {'del_link': 0} return json.dump(output, self)
def test_query_postinfo_by_cat(self): self.add_message() self.add_P2C() ss = MPost2Catalog.query_postinfo_by_cat(self.tag_id) assert ss[0].logo == 'prprprprpr' self.tearDown()
def test_query_postinfo_by_cat(self): MPost2Catalog.query_postinfo_by_cat(self.tag_id) assert True