def run_update_cat(*args): recs = MPost2Catalog.query_all().naive() for rec in recs: if rec.tag_kind != 'z': print('-' * 40) print(rec.uid) print(rec.tag_id) print(rec.par_id) MPost2Catalog.update_field(rec.uid, par_id=rec.tag_id[:2] + "00")
def run_update_cat(_): ''' Update the catagery. ''' recs = MPost2Catalog.query_all().objects() for rec in recs: if rec.tag_kind != 'z': print('-' * 40) print(rec.uid) print(rec.tag_id) print(rec.par_id) MPost2Catalog.update_field(rec.uid, par_id=rec.tag_id[:2] + "00")
def test_update_field(self): self.add_message() self.add_P2C() kwargs = {'post_id': self.post_id2} self.add_message(**kwargs) ss = MPost2Catalog.query_by_post(self.post_id) MPost2Catalog.update_field(ss[0].uid, post_id=kwargs['post_id']) aa = MPost2Catalog.query_by_post(kwargs['post_id']) assert ss[0].uid == aa[0].uid self.tearDown()
from torcms.handlers.post_handler import MPost from torcms.model.post2catalog_model import MPost2Catalog from torcms.model.evaluation_model import MEvaluation from torcms.model.usage_model import MUsage from torcms.model.json_model import MPost2Gson all_apps = MPost.query_all(kind='m', limit=100000) for app in all_apps: print('=' * 20) print(app.uid) if len(app.uid) == 4: MPost.update_field(app.uid, post_id='m' + app.uid) for post2tag in MPost2Catalog.query_by_post(app.uid): if len(post2tag.post_id) == 4: MPost2Catalog.update_field(post2tag.uid, post_id='m' + post2tag.post_id) for post2tag in MUsage.query_by_post(app.uid): if len(post2tag.post_id) == 4: MUsage.update_field(post2tag.uid, post_id='m' + post2tag.post_id) for post2tag in MPost2Gson.query_by_post(app.uid): if len(post2tag.post_id) == 4: MPost2Gson.update_field(post2tag.uid, post_id='m' + post2tag.post_id)
def test_update_field(self): MPost2Catalog.update_field(self.uid, post_id=self.post_id) assert True