[ADD] 增加会议表单

This commit is contained in:
soong
2024-08-19 08:28:35 +08:00
parent 12650f8a59
commit f447d3cc49
6 changed files with 133 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
from . import controllers
+11
View File
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': '会议表单',
'version': '17.0',
'depends': ['web'],
'data': [
'views/webclient_templates.xml',
],
}
@@ -0,0 +1 @@
from . import main
+42
View File
@@ -0,0 +1,42 @@
# -*- 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)
# record = request.env['room.booking'].sudo().browse(values['room_id'])
if request.httprequest.method == 'POST':
try:
# 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
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="website_form_room.frontend_layout" name="Frontend Layout" inherit_id="web.layout" primary="True">
<xpath expr="//head/meta[last()]" position="after">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
</xpath>
<xpath expr="//head/link[last()]" position="after">
<link rel="preload" href="/web/static/src/libs/fontawesome/fonts/fontawesome-webfont.woff2?v=4.7.0" as="font" crossorigin=""/>
<t t-call-assets="web.assets_frontend" t-js="false"/>
</xpath>
<xpath expr="//t[@t-out='0']" position="replace">
<div id="wrapwrap" t-attf-class="#{pageName or ''}">
<header t-if="not no_header" id="top" data-anchor="true">
<img class="img-responsive d-block mx-auto"
t-attf-src="/web/binary/company_logo"
alt="Logo"/>
</header>
<main>
<t t-out="0"/>
</main>
<footer t-cache="no_footer,no_copyright" t-if="not no_footer" id="bottom" data-anchor="true" t-attf-class="bg-light o_footer">
<div id="footer"/>
<div t-if="not no_copyright" class="o_footer_copyright">
<div class="container py-3">
<div class="row">
<div class="col-sm text-center text-sm-start text-muted">
<span class="o_footer_copyright_name me-2">Copyright &amp;copy; <span t-field="res_company.name" itemprop="name">Company name</span></span>
</div>
<div class="col-sm text-center text-sm-end">
<t t-call="web.brand_promotion"/>
</div>
</div>
</div>
</div>
</footer>
</div>
</xpath>
</template>
<template id="website_form_room.website_form_room" name="website form room">
<t t-call="website_form_room.frontend_layout">
<div class="container py-5">
<form class="oe_website_form_room" role="form" t-attf-action="/web/room" method="post" onsubmit="this.action = '/web/room' + location.hash">
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
<div class="mb-3 field-room_id">
<label for="room_id" class="form-label">会议号</label>
<input type="text" placeholder="会议号" name="room_id" t-att-value="room_id" id="room_id" t-attf-class="form-control" readonly="readonly"/>
</div>
<div class="mb-3 field-name">
<label for="name" class="form-label">名字</label>
<input type="text" placeholder="名字" name="name" t-att-value="name" id="name" t-attf-class="form-control" required="required" autofocus="autofocus" autocapitalize="off"/>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" placeholder="Password" name="password" id="password" t-attf-class="form-control" required="required" t-att-autofocus="'autofocus' if name else None" maxlength="4096"/>
</div>
<p class="alert alert-danger" t-if="error" role="alert">
<t t-esc="error"/>
</p>
<p class="alert alert-success" t-if="message" role="status">
<t t-esc="message"/>
</p>
<div t-attf-class="clearfix oe_login_buttons text-center gap-1 d-grid mb-1">
<button type="submit" class="btn btn-primary">签到</button>
</div>
</form>
</div>
</t>
</template>
</odoo>