49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
|
|
|
import json
|
|
import logging
|
|
|
|
|
|
import odoo
|
|
import odoo.modules.registry
|
|
from odoo import http
|
|
from odoo.exceptions import AccessError
|
|
from odoo.http import request
|
|
from odoo.addons.web.controllers.utils import ensure_db
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class Home(http.Controller):
|
|
@http.route('/web/room', type='http', auth="none")
|
|
def web_login(self, room_id=None, **kw):
|
|
ensure_db()
|
|
values = {k: v for k, v in request.params.items()}
|
|
|
|
if not room_id:
|
|
values['error'] = "缺少会议号"
|
|
else:
|
|
values['room_id'] = int(room_id)
|
|
if request.httprequest.method == 'POST':
|
|
try:
|
|
record = request.env['room.booking'].sudo().browse(values['room_id'])
|
|
request.env["room.meeting.sign"].sudo().create({
|
|
"room_booking_id": record.id,
|
|
"sign_user_name": values.get("name", ""),
|
|
"user_type": "outsiders",
|
|
"sign_type": 'yes'
|
|
})
|
|
# pass
|
|
values["message"] = "签到成功"
|
|
except odoo.exceptions.AccessDenied as e:
|
|
if e.args == odoo.exceptions.AccessDenied().args:
|
|
values['error'] = "重复签到"
|
|
else:
|
|
values['error'] = "签到失败"
|
|
|
|
response = request.render('website_form_room.website_form_room', values)
|
|
response.headers['X-Frame-Options'] = 'SAMEORIGIN'
|
|
response.headers['Content-Security-Policy'] = "frame-ancestors 'self'"
|
|
return response
|