Includes: - Odoo 19 framework (odoo/) - 27 custom EnCoach addons (new_project/custom_addons/) - encoach_core, encoach_api, encoach_lms_api, encoach_adaptive_api - encoach_exam, encoach_taxonomy, encoach_adaptive, encoach_assignment - encoach_ai, encoach_ai_grading, encoach_ai_generation, encoach_ai_media - encoach_courseware, encoach_communication, encoach_subscription - encoach_notification, encoach_approval, encoach_branding - encoach_classroom, encoach_registration, encoach_stats - encoach_faq, encoach_ticket, encoach_training, encoach_resources - encoach_adaptive_ai, encoach_sis - 21 OpenEduCat Enterprise modules (new_project/enterprise-19/) - 14 OpenEduCat Community modules (new_project/openeducat_erp-19.0/) - Configuration: odoo.conf, requirements.txt, scripts - 200+ REST API endpoints with JWT authentication - SRS and test documentation Made-with: Cursor
64 lines
2.4 KiB
Python
64 lines
2.4 KiB
Python
from odoo import http, _
|
|
from odoo.http import request
|
|
from odoo.exceptions import UserError
|
|
|
|
class DashboardShareRoute(http.Controller):
|
|
@http.route(['/dashboard/share/<int:share_id>/<token>'], type='http', auth='public')
|
|
def share_portal(self, share_id=None, token=None):
|
|
share = request.env["spreadsheet.dashboard.share"].sudo().browse(share_id).exists()
|
|
if not share:
|
|
raise request.not_found()
|
|
share._check_dashboard_access(token)
|
|
download_url = ""
|
|
if request.env.user.has_group('base.group_allow_export'):
|
|
download_url = f"/dashboard/download/{share.id}/{token}"
|
|
return request.render(
|
|
"spreadsheet.public_spreadsheet_layout",
|
|
{
|
|
"spreadsheet_name": share.dashboard_id.name,
|
|
"share": share,
|
|
"is_frozen": True,
|
|
"session_info": request.env["ir.http"].session_info(),
|
|
"props": {
|
|
"dataUrl": f"/dashboard/data/{share.id}/{token}",
|
|
"downloadExcelUrl": download_url,
|
|
"mode": "dashboard",
|
|
},
|
|
},
|
|
)
|
|
|
|
@http.route(["/dashboard/download/<int:share_id>/<token>"],
|
|
type='http', auth='user', readonly=True)
|
|
def download(self, token=None, share_id=None):
|
|
share = request.env["spreadsheet.dashboard.share"].sudo().browse(share_id)
|
|
share._check_dashboard_access(token)
|
|
if not request.env.user.has_group('base.group_allow_export'):
|
|
raise UserError(_("You don't have the rights to export data. Please contact an Administrator."))
|
|
stream = request.env["ir.binary"]._get_stream_from(
|
|
share, "excel_export", filename=share.name
|
|
)
|
|
return stream.get_response()
|
|
|
|
@http.route(
|
|
["/dashboard/data/<int:share_id>/<token>"],
|
|
type="http",
|
|
auth="public",
|
|
methods=["GET"],
|
|
readonly=True,
|
|
)
|
|
def get_shared_dashboard_data(self, share_id, token):
|
|
share = (
|
|
request.env["spreadsheet.dashboard.share"]
|
|
.sudo()
|
|
.browse(share_id)
|
|
.exists()
|
|
)
|
|
if not share:
|
|
raise request.not_found()
|
|
|
|
share._check_dashboard_access(token)
|
|
stream = request.env["ir.binary"]._get_stream_from(
|
|
share, "spreadsheet_binary_data"
|
|
)
|
|
return stream.get_response()
|