site.py 4.2 KB

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