site.py 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. # -*- coding: utf-8 -*-
  2. """
  3. demeter web page
  4. name:site.py 站点相关
  5. author:rabin
  6. """
  7. class site_path(Load):
  8. @Web.auth
  9. @Web.setting
  10. def get(self):
  11. self.common(
  12. name = u'站点管理'
  13. ,path = '/site/site'
  14. ,width = '600'
  15. ,height = '600'
  16. ,search = (('label-1','workdate-time-start','workdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'站点名称'))
  17. ,thead = (u'站点名称', u'快捷功能', u'更新时间')
  18. ,tbody = ('name','func', 'cdate')
  19. ,state = True
  20. )
  21. menu = (
  22. {'name':'抢购商品管理', 'url':'/site/product'}
  23. ,
  24. )
  25. self.commonList('site')
  26. if self.data['list']:
  27. for key, value in enumerate(self.data['list']):
  28. id = str(value['id'])
  29. param = '?search_site_id-select-=' + id
  30. self.data['list'][key]['func'] = ''
  31. for i in menu:
  32. self.data['list'][key]['func'] = self.data['list'][key]['func'] + '<a href="'+i['url']+''+param+'">'+i['name']+'</a>&nbsp;&nbsp;&nbsp;&nbsp;'
  33. self.commonView('list')
  34. class site_update_path(Load):
  35. @Web.auth
  36. @Web.setting
  37. def get(self):
  38. self.common(
  39. path = '/site/site'
  40. ,label = (u'站点名称',u'站点网址',u'登录页链接',u'登录账号',u'登录密码')
  41. ,update = ('name-input-required','link-input-required','login_link-input-required','username-input-required','password-password-required')
  42. )
  43. self.commonOne('site')
  44. self.commonView('update')
  45. @Web.auth
  46. @Web.setting
  47. def post(self):
  48. self.commonUpdate('site')
  49. @Web.auth
  50. @Web.setting
  51. def delete(self):
  52. self.commonDelete('site')
  53. class product_path(Load):
  54. @Web.auth
  55. @Web.setting
  56. def get(self):
  57. self.common(
  58. name = u'抢购商品'
  59. ,path = '/site/product'
  60. ,width = '600'
  61. ,height = '600'
  62. ,search = (('label-1','cdate-time-start','cdate-time-end','site_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择站点',u'商品名'))
  63. ,thead = (u'所属站点', u'商品名', u'状态', u'更新时间')
  64. ,tbody = ('site', 'name', 'status', 'cdate')
  65. ,state = True
  66. )
  67. self.data['common']['search_site_id-select-'] = self.service('common').list('site')
  68. self.commonList('product')
  69. status = {}
  70. status[1] = '待机'
  71. status[2] = '入队'
  72. status[3] = '抢购中'
  73. status[4] = '抢购完成'
  74. if self.data['list']:
  75. for key, value in enumerate(self.data['list']):
  76. site = self.service('common').one('site', id=value['site_id'])
  77. self.data['list'][key]['site'] = site['name']
  78. self.data['list'][key]['status'] = '<a href="/site/order?search_product_id-select-='+str(value['id'])+'">'+status[value['status']]+'[查看二维码]</a>'
  79. self.commonView('list')
  80. class product_update_path(Load):
  81. @Web.auth
  82. @Web.setting
  83. def get(self):
  84. status = [
  85. {'id':'1', 'name': '待机-如果之前抢购完成,选择此项可以重新开始抢购'},
  86. ]
  87. self.common(
  88. path = '/site/product'
  89. ,label = (u'所属站点', u'商品名称', u'商品链接', u'状态控制')
  90. ,update = ('site_id-select-required', 'name-input-required','link-input-required', 'status-select-required')
  91. ,update_site_id = self.service('common').list('site')
  92. ,update_status = status
  93. )
  94. self.commonOne('product')
  95. self.commonView('update')
  96. @Web.auth
  97. @Web.setting
  98. def post(self):
  99. self.commonUpdate('product')
  100. @Web.auth
  101. @Web.setting
  102. def delete(self):
  103. self.commonDelete('product')
  104. class order_path(Load):
  105. @Web.auth
  106. @Web.setting
  107. def get(self):
  108. self.common(
  109. name = u'商品订单列表'
  110. ,path = '/site/order'
  111. ,width = '600'
  112. ,height = '600'
  113. ,edit = False
  114. ,add = False
  115. ,search = (('label-1','cdate-time-start','cdate-time-end', 'orderID-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'订单ID'))
  116. ,thead = (u'商品名称', u'订单ID', u'二维码', u'更新时间')
  117. ,tbody = ('name', 'orderID', 'pic', 'cdate')
  118. ,state = False
  119. )
  120. #self.data['common']['search_product_id-select-'] = self.service('common').list('product')
  121. self.commonList('order')
  122. if self.data['list']:
  123. for key, value in enumerate(self.data['list']):
  124. product = self.service('common').one('product', id=value['product_id'])
  125. self.data['list'][key]['name'] = product['name']
  126. value['pic'] = value['pic'].replace(Demeter.path + 'runtime', '')
  127. self.data['list'][key]['pic'] = '<img src="'+value['pic']+'" width="200px" />'
  128. self.commonView('list')