farm.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. demeter web page
  5. name:main.py
  6. author:rabin
  7. """
  8. from __load__ import *
  9. class index_path(Load):
  10. @Web.setting
  11. def get(self):
  12. id = self.input('id')
  13. if not id:
  14. self.redirect('/')
  15. self.data['info'] = self.service('common').one('farm', id=id)
  16. self.data['product'] = self.service('common').list('farm_product', search={'farm_id':id, 'status':True}, limit='0,8')
  17. self.data['env'] = self.service('common').list('farm_env', search={'farm_id':id}, order='inorder asc,cdate desc', limit='0,5')
  18. if self.data['env']:
  19. for key, value in enumerate(self.data['env']):
  20. info = self.service('common').one('device_info', id=value['device_id'])
  21. #info['value'] = Demeter.exp(info['out_exp'], info['value'])
  22. self.data['env'][key]['device'] = info
  23. info = self.service('common').one('device_type', id=value['type_id'])
  24. self.data['env'][key]['type'] = info
  25. mobile = Demeter.checkMobile(self.request)
  26. if mobile:
  27. path = 'mobile/'
  28. else:
  29. path = ''
  30. self.view(path + "farm.html")