msg.py 803 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter web page
  5. name:msg.py
  6. author:rabin
  7. """
  8. from __load__ import *
  9. class index_path(Load):
  10. @Web.auth
  11. @Web.setting
  12. def get(self):
  13. self.data['list'] = self.service('common').list('msg', search={'farm_id':self.data['setting']['farm']}, page=True, order='status asc, cdate desc')
  14. if self.data['list']:
  15. for key, value in enumerate(self.data['list']):
  16. type_info = self.service('common').one('msg_type', id=value['type_id'])
  17. self.data['list'][key]['type'] = type_info['name']
  18. self.data['list'][key]['cdates'] = Demeter.date(value['cdate'])
  19. id = value['id']
  20. update = {}
  21. update['status'] = True
  22. self.service('common').update('msg', id, update, cdate=False)
  23. self.view("msg/index.html")