help.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # -*- coding: utf-8 -*-
  2. """
  3. demeter web page
  4. name:help.py
  5. author:rabin
  6. """
  7. from .__load__ import *
  8. class index_path(Load):
  9. @Web.setting
  10. def get(self):
  11. self.data['url'] = '/help?'
  12. self.data['category'] = self.service('common').list('web_help_category')
  13. if self.data['category']:
  14. for key, value in enumerate(self.data['category']):
  15. self.data['category'][key]['link'] = '/help?category=' + str(value['id'])
  16. search = {}
  17. self.data['category_id'] = self.input('category')
  18. if self.data['category_id']:
  19. search['category_id'] = self.data['category_id']
  20. self.data['url'] = self.data['url'] + 'category=' + self.data['category_id']
  21. self.data['list'] = self.service('common').list('web_help', search=search, page={'num':10})
  22. if self.data['list']:
  23. for key, value in enumerate(self.data['list']):
  24. self.data['list'][key]['link'] = '/help/view?id=' + str(value['id'])
  25. self.data['list'][key]['index'] = key+1
  26. self.view("list.html")
  27. class view_path(Load):
  28. @Web.setting
  29. def get(self):
  30. id = self.input('id')
  31. if not id:
  32. self.out('error')
  33. return
  34. self.data['info'] = self.service('common').one('web_help', id=id)
  35. self.data['category'] = self.service('common').list('web_help_category')
  36. if self.data['category']:
  37. for key, value in enumerate(self.data['category']):
  38. self.data['category'][key]['link'] = '/help?category=' + str(value['id'])
  39. self.view("detail.html")