You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
998 B

  1. # -*- coding: utf-8 -*-
  2. # © 2015 Therp BV <http://therp.nl>
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import werkzeug
  5. from openerp import http
  6. from openerp.http import request
  7. class Main(http.Controller):
  8. @http.route('/dead_mans_switch/alive', type='json', auth="none")
  9. def alive(self, **kwargs):
  10. if 'database_uuid' not in kwargs:
  11. raise werkzeug.exceptions.NotFound()
  12. instance = request.env['dead.mans.switch.instance'].sudo().search([
  13. ('database_uuid', '=', kwargs['database_uuid']),
  14. ])
  15. if not instance:
  16. instance = request.env['dead.mans.switch.instance'].sudo().create({
  17. 'database_uuid': kwargs['database_uuid'],
  18. })
  19. data = {
  20. field: value
  21. for field, value in kwargs.iteritems()
  22. if field in request.env['dead.mans.switch.log']._fields
  23. }
  24. instance.write({
  25. 'log_ids': [(0, 0, data)],
  26. })