-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
2,793 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.