# -*- coding: utf-8 -*- #!/usr/bin/env python import os import sys import datetime PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..') sys.path.insert(0, PROJECT_ROOT) from script.base import * init_env(interactive=True) from apps.web.user.models import RechargeRecord, ConsumeRecord, MyUser from apps.web.device.models import Group # 将充值记录的总数从币数改为钱数 # 运行 upgrade_1220 # 添加消费记录的组名字段 def append_groupName_to_ConsumeRecord(): for record in ConsumeRecord.objects(): updated = record.update(groupName=Group.get_group(record.groupId).get('groupName')) assert updated, 'cannot update ConsumeRecord(%s)' % (record.id,) if __name__ == '__main__': print u'添加消费记录的组名字段' append_groupName_to_ConsumeRecord()