Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ const config = [{
languageOptions: {
ecmaVersion: 2024,
sourceType: "module",
globals: {
"document": "readonly",
"setTimeout": "readonly",
"clearTimeout": "readonly",
"fetch": "readonly",
}
},
}];

Expand Down
10 changes: 7 additions & 3 deletions sbc_translation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@
"author": "Compassion CH",
"license": "AGPL-3",
"website": "https://github.com/CompassionCH/compassion-modules",
"depends": ["sbc_compassion", "partner_contact_birthdate", "website"],
"depends": ["sbc_compassion", "partner_contact_birthdate", "portal"],
"assets": {
"web.assets_backend": ["sbc_translation/js/translation_letter_counting_js.js"]
"web.assets_frontend": [
"sbc_translation/static/src/frontend/**/*.css",
"sbc_translation/static/src/frontend/**/*.xml",
"sbc_translation/static/src/frontend/**/*.esm.js",
],
},
"data": [
"security/ir_groups.xml",
Expand All @@ -48,8 +52,8 @@
"wizards/translation_letter_counting_view.xml",
"data/mail_template.xml",
"data/update_translation_priority_cron.xml",
"data/website.xml",
"data/queue_job.xml",
"templates/portal_templates.xml",
"views/translation_user_view.xml",
"views/correspondence_view.xml",
"views/translation_pool_view.xml",
Expand Down
76 changes: 62 additions & 14 deletions sbc_translation/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,75 @@
from werkzeug.utils import redirect

from odoo import http
from odoo.tools import file_open
from odoo.http import request

from odoo.addons.portal.controllers.portal import CustomerPortal

_logger = logging.getLogger(__name__)


class RestController(http.Controller):
class TranslationPlatformController(CustomerPortal):
@http.route(
"/my/translation-platform",
type="http",
auth="user",
website=True,
)
def translation_platform_portal(self, **kwargs):
"""
Portal page for the Translation Platform OWL app.
Only accessible to authenticated users who belong to the
sbc_translation.group_user group.
"""
if not request.env.user.has_group("sbc_translation.group_user"):
return redirect("/my")
return request.render("sbc_translation.portal_translation_platform", {})

@http.route(
["/translation-platform", "/translation-platform/<path:page>"],
type="http",
auth="public",
auth="user",
website=True,
)
def translation_platform(self, page=""):
def translation_platform_legacy(self, page="", **kwargs):
"""
Simple server for the translation platform which should be compiled into
/static/tp folder.
:param page: This the route requested
:return: index.html, or assets.
Legacy route: redirect old standalone-app URLs to the new portal page.
"""
if (
"assets" in page or page.endswith(".png") or page.endswith(".jpg")
): # Serving assets
return redirect(f"/sbc_translation/static/tp/{page}")
with file_open("sbc_translation/static/tp/index.html") as app:
return app.read()
return redirect("/my/translation-platform", 301)

def _prepare_home_portal_values(self, counters):
values = super()._prepare_home_portal_values(counters)
if not request.env.user.has_group("sbc_translation.group_user"):
return values
partner = request.env.user.partner_id
translator = request.env["translation.user"].search(
[("partner_id", "=", partner.id)]
)
if translator and "letters_to_translate" in counters:
if translator.translation_skills:
nb_letters = request.env["correspondence"].search_count(
[
("state", "=", "Global Partner translation queue"),
("translation_status", "=", "to do"),
("new_translator_id", "=", False),
(
"translation_competence_id.skill_ids",
"in",
translator.translation_skills.ids,
),
]
)
values["letters_to_translate"] = nb_letters
else:
values["letters_to_translate"] = 1
if translator and "letters_in_progress" in counters:
nb_letters = request.env["correspondence"].search_count(
[
("state", "=", "Global Partner translation queue"),
("translation_status", "!=", "done"),
("new_translator_id", "=", translator.id),
]
)
values["letters_in_progress"] = nb_letters
values["translator"] = translator
return values
6 changes: 0 additions & 6 deletions sbc_translation/data/website.xml

This file was deleted.

Loading
Loading