upgrade_feature_20180930.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # -*- coding: utf-8 -*-
  2. # !/usr/bin/env python
  3. """
  4. 默认所有经销商支持线下投币的特性
  5. """
  6. import os
  7. import sys
  8. #: current_dir - 2
  9. PROJECT_ROOT = os.path.join(os.path.abspath(os.path.split(os.path.realpath(__file__))[0] + "/.."), '..')
  10. sys.path.insert(0, PROJECT_ROOT)
  11. from script.base import init_env, get_logger
  12. logger = get_logger(__name__)
  13. init_env(interactive=True)
  14. from apps.web.dealer.models import Dealer
  15. from apps.web.common.models import Feature
  16. if not Feature.objects(name = "show_offline_coins"):
  17. offline_coin_feature = Feature(**{
  18. "name": "show_offline_coins",
  19. "role": "dealer",
  20. "managerId": "59974b4b8732d6480fb699e5",
  21. "by": "5b5165d9c9a6bd1bec34fa6d",
  22. "description": u"是否显示线下投币模块",
  23. }).save()
  24. if not Feature.objects(name = "manual_withdraw"):
  25. manual_withdraw_feature = Feature(**{
  26. "name": "manual_withdraw",
  27. "role": "agent",
  28. "managerId": "59974b4b8732d6480fb699e5",
  29. "by": "5b5165d9c9a6bd1bec34fa6d",
  30. "description": u"是否手动提现",
  31. }).save()
  32. result = Dealer.get_collection().update({}, { '$addToSet': {'features': "show_offline_coins"}}, multi=True)
  33. logger.info('finished, result=%s' % (result,))