Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

14.0 sbc translation #1838

Merged
merged 4 commits into from
Feb 27, 2024
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
104 changes: 104 additions & 0 deletions sbc_translation/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
========================
SBC Translation Platform
========================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-CompassionCH%2Fcompassion--modules-lightgray.png?logo=github
:target: https://github.com/CompassionCH/compassion-modules/tree/12.0/sbc_translation
:alt: CompassionCH/compassion-modules

|badge1| |badge2| |badge3|

Compassion SBC Translation Platform
===================================

This adds the backend management of SBC letters in the translation stage.
Once can manage all letters in translation and keep track of the progress.
It also serves as XMLRPC-API for the Translation Platform written in OWL (https://github.com/compassionch/translation-platform-web).

**Table of contents**

.. contents::
:local:

Installation
============

To install this module, you need to:

#. Clone the translation-platform project (https://github.com/compassionch/translation-platform-web).
#. Create a ``.env.production.local`` file and compile the web-app.
#. Copy the compiled app created in the ``dist`` folder into the ``/static/tp/`` folder of the module.
#. This will make the front-end interface available from your Odoo server with ``http://server_url/translation-platform`` route.

Configuration
=============

To configure this module, you need to:

#. Give access rights to users
- Front end translators need the User rights.
- Managers need the Manager rights for accessing the backend.

.. figure:: https://raw.githubusercontent.com/CompassionCH/compassion-modules/12.0/sbc_translation/static/description/user_rights.jpg
:alt: alternative description
:width: 600 px

Usage
=====

To use this module, you need to:

#. Go to /Sponsorship/Correspondence/Translation Platform/ menu
- Translation Pool is the list of all letters currently in translation
- Translators is the list of translators
- Competences is the available skills of translations. It is also
an entry point to the translation pool, filtered by language.

Changelog
=========

12.0.1.0.0 (2023-02-28)
~~~~~~~~~~~~~~~~~~~~~~~

* First version

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/CompassionCH/compassion-modules/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/CompassionCH/compassion-modules/issues/new?body=module:%20sbc_translation%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Compassion CH

Contributors
~~~~~~~~~~~~

* Emanuel Cino <[email protected]>

Maintainers
~~~~~~~~~~~

This module is part of the `CompassionCH/compassion-modules <https://github.com/CompassionCH/compassion-modules/tree/12.0/sbc_translation>`_ project on GitHub.

You are welcome to contribute.
4 changes: 3 additions & 1 deletion sbc_translation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from . import controllers, models, wizards
from . import models
from . import controllers
from . import wizards
from .hooks.post_init_hook import post_init_hook
9 changes: 5 additions & 4 deletions sbc_translation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,23 @@
# pylint: disable=C8101
{
"name": "SBC Translation Platform",
"version": "12.0.1.0.0",
"category": "Compassion",
"version": "14.0.1.0.0",
"category": "Other",
"summary": "SBC - Translation Platform",
"sequence": 150,
"author": "Compassion CH",
"license": "AGPL-3",
"website": "https://www.compassion.ch",
"depends": ["sbc_compassion", "partner_contact_birthdate"],
"depends": ["sbc_compassion", "partner_contact_birthdate", "website"],
"data": [
"security/ir_groups.xml",
"security/ir.model.access.csv",
"security/access_rules.xml",
"wizards/reply_to_comments_view.xml",
"data/mail_template.xml",
"data/increment_translation_priority_cron.xml",
"data/update_translation_priority_cron.xml",
"data/website.xml",
"data/queue_job.xml",
"views/translation_user_view.xml",
"views/correspondence_view.xml",
"views/translation_pool_view.xml",
Expand Down
4 changes: 2 additions & 2 deletions sbc_translation/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
##############################################################################
#
# Copyright (C) 2022 Compassion CH (http://www.compassion.ch)
# Copyright (C) 2023 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <[email protected]>
#
# The licence is in the file __manifest__.py
#
##############################################################################
from . import download_correspondence
from . import main
41 changes: 0 additions & 41 deletions sbc_translation/controllers/download_correspondence.py

This file was deleted.

36 changes: 36 additions & 0 deletions sbc_translation/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
##############################################################################
#
# Copyright (C) 2023 Compassion CH (http://www.compassion.ch)
# Releasing children from poverty in Jesus' name
#
# The licence is in the file __manifest__.py
#
##############################################################################
import logging

from werkzeug.utils import redirect

from odoo import http
from odoo.tools import file_open

_logger = logging.getLogger(__name__)


class RestController(http.Controller):
@http.route(
["/translation-platform", "/translation-platform/<path:page>"],
type="http",
auth="public",
)
def translation_platform(self, page=""):
"""
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.
"""
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()
2 changes: 1 addition & 1 deletion sbc_translation/data/mail_template.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<odoo>
<odoo noupdate="1">
<record id="translation_issue_notification" model="mail.template">
<field name="name">Translation issue notification</field>
<field name="subject">A translation issue was raised</field>
Expand Down
8 changes: 8 additions & 0 deletions sbc_translation/data/queue_job.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<odoo>
<!-- Job functions -->
<record id="move_pool_job" model="queue.job.function">
<field name="model_id" ref="model_correspondence"/>
<field name="method">move_pool</field>
<field name="channel_id" ref="sbc_compassion.channel_sbc_compassion"/>
</record>
</odoo>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data noupdate="1">
<record id="increment_priority_cron" model="ir.cron">
<field name="name">Increment translation priority</field>
<data>
<record id="update_translation_priority_cron" model="ir.cron">
<field name="name">Update translation priority</field>
<field name="model_id" ref="model_correspondence"/>
<field name="type">ir.action.server</field>
<field name="state">code</field>
<field name="code">model.increment_priority_cron()</field>
<field name="code">model.update_translation_priority_cron()</field>
<field name="interval_number">1</field>
<field name="interval_type">weeks</field>
<field name="numbercall">-1</field>
Expand Down
2 changes: 1 addition & 1 deletion sbc_translation/data/website.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<data noupdate="1">
<record id="translation_website" model="website">
<field name="name">Translation Platform</field>
<field name="domain">translate-test.compassion.ch</field>
<field name="domain">translate.compassion.ch</field>
</record>
</data>
</odoo>
14 changes: 12 additions & 2 deletions sbc_translation/hooks/post_init_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@
def post_init_hook(cr, registry):
logger.info("SBC Translation Init Hook: create missing competences")

# Update translation done
cr.execute(
"""
UPDATE correspondence SET translate_done = translate_date
WHERE translate_date IS NOT NULL;
UPDATE correspondence SET translate_date = write_date
WHERE state = 'Global Partner translation queue'
AND translate_date IS NULL;
"""
)

with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
# Update correspondence competence
Expand All @@ -28,7 +39,6 @@ def post_init_hook(cr, registry):
[{"source_language_id": src.id, "dest_language_id": dst.id}]
)
cr.execute(
"UPDATE correspondence SET translation_competence_id = %s "
"WHERE id = %s",
"UPDATE correspondence SET translation_competence_id = %s WHERE id = %s",
[competence.id, letter.id],
)
Loading