Skip to content

Commit

Permalink
Merge branch '16.0' into TA#72894
Browse files Browse the repository at this point in the history
  • Loading branch information
majouda authored Dec 9, 2024
2 parents ff0cd42 + 46e2ddd commit 0ab6002
Show file tree
Hide file tree
Showing 45 changed files with 2,793 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
name: Setup Log Folder For Reports
command: sudo mkdir -p .log && sudo chmod 777 .log

# - run:
# name: Run Test
# command: docker-compose run --rm odoo run_pytest.sh
- run:
name: Run Test
command: docker-compose run --rm odoo run_pytest.sh

# - store_test_results:
# path: .log
Expand Down
2 changes: 2 additions & 0 deletions .docker_files/main/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"summary": "Install all addons required for testing.",
"depends": [
"base",
"github_event",
"github_pullrequest",
],
"installable": True,
}
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ RUN gitoo install-all --conf_file /gitoo.yml --destination "${THIRD_PARTY_ADDONS

USER odoo

COPY github_event /mnt/extra-addons/github_event
COPY github_pull_request /mnt/extra-addons/github_pull_request

COPY .docker_files/main /mnt/extra-addons/main
COPY .docker_files/odoo.conf /etc/odoo
34 changes: 34 additions & 0 deletions github_event/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Github Events
=============

This modules defines what is a GitHub event (as an Odoo object).

.. contents:: Table of Contents

Events
------
As system administrator, I go to ``Configuration > Technical > GitHub > Events``.

.. image:: static/description/menu_technical_events.png

I see the list of events:

.. image:: static/description/event_tree.png

I open the form view of an event.

.. image:: static/description/event_form.png

Process Button
--------------
The ``Process`` button in the form view of events triggers the parsing of the payload.

.. image:: static/description/event_form_process_button.png

When no extra module is installed, only the ``Action`` is filled.

Clicking multiple times on the button is idempotent.

Contributors
------------
* Numigi (tm) and all its contributors (https://bit.ly/numigiens)
4 changes: 4 additions & 0 deletions github_event/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import models
22 changes: 22 additions & 0 deletions github_event/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2023 - Today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

{
'name': 'Github Events',
'version': "16.0.1.0.0",
'author': 'Numigi',
'maintainer': 'Numigi',
'website': 'https://bit.ly/numigi-com',
'license': 'LGPL-3',
'category': 'Connector',
'summary': 'Define what is a github event as an odoo object',
'depends': [
'base_sparse_field',
],
'data': [
'security/ir.model.access.csv',
'views/github_event.xml',
'views/menu.xml',
],
'installable': True,
}
102 changes: 102 additions & 0 deletions github_event/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * github_pull_request
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-04 19:28+0000\n"
"PO-Revision-Date: 2019-12-04 14:30-0500\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"X-Generator: Poedit 2.0.6\n"

#. module: github_event
#: model:ir.model.fields,field_description:github_event.field_github_event__action
msgid "Action"
msgstr "Action"

#. module: github_event
#: model:ir.model.fields,field_description:github_event.field_github_event__create_uid
msgid "Created by"
msgstr "Créé par"

#. module: github_event
#: model:ir.model.fields,field_description:github_event.field_github_event__create_date
msgid "Created on"
msgstr "Créé le"

#. module: github_event
#: model:ir.model.fields,field_description:github_event.field_github_event__display_name
msgid "Display Name"
msgstr "Nom affiché"

#. module: github_event
#: model:ir.actions.act_window,name:github_event.events_action_window
#: model:ir.ui.menu,name:github_event.menu_github_event
msgid "Events"
msgstr "Événements"

#. module: github_event
#: model:ir.ui.menu,name:github_event.menu_github
msgid "Github"
msgstr "Github"

#. module: github_event
#: model:ir.model,name:github_event.model_github_event
#: model_terms:ir.ui.view,arch_db:github_event.github_event_form
msgid "Github Event"
msgstr "Événement Github"

#. module: github_event
#: model_terms:ir.ui.view,arch_db:github_event.github_event_list
msgid "Github Events"
msgstr "Événements Github"

#. module: github_event
#: model:ir.model.fields,field_description:github_event.field_github_event__id
msgid "ID"
msgstr ""

#. module: github_event
#: model:ir.model.fields,field_description:github_event.field_github_event____last_update
msgid "Last Modified on"
msgstr ""

#. module: github_event
#: model:ir.model.fields,field_description:github_event.field_github_event__write_uid
msgid "Last Updated by"
msgstr ""

#. module: github_event
#: model:ir.model.fields,field_description:github_event.field_github_event__write_date
msgid "Last Updated on"
msgstr ""

#. module: github_event
#: model:ir.model.fields,field_description:github_event.field_github_event__payload
#: model_terms:ir.ui.view,arch_db:github_event.github_event_form
msgid "Payload"
msgstr ""

#. module: github_event
#: model:ir.model.fields,field_description:github_event.field_github_event__payload_serialized
msgid "Payload Serialized"
msgstr ""

#. module: github_event
#: model_terms:ir.ui.view,arch_db:github_event.github_event_form
msgid "Process"
msgstr "Traîter"

#. module: github_event
#: code:addons/github_event/models/github_event.py:40
#, python-format
msgid "The payload does not contain a value at the path {}."
msgstr "Le payload ne contient pas de valeur sous le chemin {}."
6 changes: 6 additions & 0 deletions github_event/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

from . import (
github_event,
)
53 changes: 53 additions & 0 deletions github_event/models/github_event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import json
from odoo import api, fields, models, _
from odoo.addons.base_sparse_field.models.fields import Serialized
from odoo.exceptions import ValidationError


class GithubEvent(models.Model):

_name = "github.event"
_description = "Github Event"
_order = 'id desc'

action = fields.Char()
payload = fields.Text()
payload_serialized = Serialized(compute='_compute_payload_serialized')

@api.depends('payload')
def _compute_payload_serialized(self):
events_with_payloads = self.filtered(lambda e: e.payload)
for event in events_with_payloads:
event.payload_serialized = json.loads(event.payload)

def _get_value_from_payload(self, path):
"""Get a value from the payload.
:param path: a doted notation of the path to access the value.
:return: the value contained at the given path.
"""
section = self.payload_serialized
keys = path.split('.')

for key in keys[:-1]:
if not isinstance(section, dict) or key not in section:
raise ValidationError(
_("The payload does not contain a value at the path {}.").format(
path
)
)

section = section[key]

return section[keys[-1]]

def process(self):
"""Process a github event.
This method is intended to be inherited by other modules
to add extra behavior when processing a github event.
"""
self.action = self._get_value_from_payload('action')
3 changes: 3 additions & 0 deletions github_event/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_github_event,access_github_event,model_github_event,base.group_user,1,0,0,0
access_github_event_admin,access_github_event_admin,model_github_event,base.group_system,1,1,1,0
Binary file added github_event/static/description/event_form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added github_event/static/description/event_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added github_event/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions github_event/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Copyright 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
20 changes: 20 additions & 0 deletions github_event/tests/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 - today Numigi (tm) and all its contributors (https://bit.ly/numigiens)
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).

import os
from odoo.tests import common


class GithubEventCase(common.SavepointCase):

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.event_1 = cls.env['github.event'].create({})
cls.event_2 = cls.env['github.event'].create({})

def _read_payload(self, filename):
test_folder = os.path.dirname(os.path.realpath(__file__))
payload_file_path = os.path.join(test_folder, 'data', filename)
with open(payload_file_path, 'r') as file:
return file.read()
Loading

0 comments on commit 0ab6002

Please sign in to comment.