1234567891011121314151617181920212223242526272829303132 |
- # -*- coding: utf-8 -*-
- #!/usr/bin/env python
- """
- Goal:
- put agentId to every adRecords
- """
- import os
- import sys
- #: current_dir - 2
- 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, get_logger
- init_env(interactive=True)
- from apps.web.ad.models import AdRecord
- from apps.web.dealer.models import Dealer
- for record in AdRecord.objects():
- if record.dealerId:
- updated = record.update(agentId = Dealer.objects(id=str(record.dealerId)).get().agentId)
- assert updated, 'update failed, record id=%s' % (record.id,)
- print 'finished'
|