help.py 1.5 KB

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