diff --git a/gitlab/README.rst b/gitlab/README.rst new file mode 100644 index 000000000..77247d752 --- /dev/null +++ b/gitlab/README.rst @@ -0,0 +1,85 @@ +====== +Gitlab +====== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5fe540da3a23a490321ee98260fbc37dcc03fb8ceac994d75890e7b2af7753b3 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |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-OCA%2Fserver--backend-lightgray.png?logo=github + :target: https://github.com/OCA/server-backend/tree/16.0/gitlab + :alt: OCA/server-backend +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-backend-16-0/server-backend-16-0-gitlab + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-backend&target_branch=16.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module does not provide a functionality by itself but a base model +to implement gitlab related features + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +#. Go to *Settings > Technical > Gitlab Connections*. +#. Create new gitlab connections by filling in the details and then you can test the gitlab connection by clicking on "Test Connection" button. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Onestein + +Contributors +~~~~~~~~~~~~ + +* `Onestein `_ + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/server-backend `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/gitlab/__init__.py b/gitlab/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/gitlab/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/gitlab/__manifest__.py b/gitlab/__manifest__.py new file mode 100644 index 000000000..6278202c9 --- /dev/null +++ b/gitlab/__manifest__.py @@ -0,0 +1,12 @@ +{ + "name": "Gitlab", + "summary": "Base module for implementing gitlab related features", + "category": "Technical", + "version": "16.0.1.0.0", + "author": "Onestein, Odoo Community Association (OCA)", + "website": "https://github.com/OCA/server-backend", + "license": "AGPL-3", + "depends": ["base"], + "external_dependencies": {"python": ["python-gitlab"]}, + "data": ["security/ir_model_access.xml", "views/gitlab_view.xml", "menuitems.xml"], +} diff --git a/gitlab/menuitems.xml b/gitlab/menuitems.xml new file mode 100644 index 000000000..db16a39d6 --- /dev/null +++ b/gitlab/menuitems.xml @@ -0,0 +1,9 @@ + + + + diff --git a/gitlab/models/__init__.py b/gitlab/models/__init__.py new file mode 100644 index 000000000..873b96e07 --- /dev/null +++ b/gitlab/models/__init__.py @@ -0,0 +1 @@ +from . import gitlab diff --git a/gitlab/models/gitlab.py b/gitlab/models/gitlab.py new file mode 100644 index 000000000..646f304df --- /dev/null +++ b/gitlab/models/gitlab.py @@ -0,0 +1,48 @@ +from odoo import _, fields, models + +import gitlab + + +class Gitlab(models.Model): + _name = "gitlab" + _description = "Gitlab Connection" + + url = fields.Char(string="URL", default="https://gitlab.com") + private_token = fields.Char(string="Private / Personal Token", required=True) + debug = fields.Boolean(string="Enable Debug Mode") + per_page = fields.Integer(string="Pagination", default=100) + + def name_get(self): + res = [] + for record in self: + res.append((record.id, record.url)) + return res + + def get_server_connection(self): + self.ensure_one() + gl = gitlab.Gitlab(url=self.url, private_token=self.private_token) + if self.debug: + gl.enable_debug() + return gl + + def validate(self): + gl = self.get_server_connection() + try: + gl.auth() + title = _("Connection Test Succeeded!") + message = _("Everything seems properly set up!") + msg_type = "success" + except Exception as e: + title = _("Connection Test Failed!") + message = str(e) + msg_type = "danger" + return { + "type": "ir.actions.client", + "tag": "display_notification", + "params": { + "title": title, + "message": message, + "type": msg_type, + "sticky": False, + }, + } diff --git a/gitlab/readme/CONTRIBUTORS.rst b/gitlab/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..85125abb2 --- /dev/null +++ b/gitlab/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* `Onestein `_ diff --git a/gitlab/readme/DESCRIPTION.rst b/gitlab/readme/DESCRIPTION.rst new file mode 100644 index 000000000..9352a12a7 --- /dev/null +++ b/gitlab/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module does not provide a functionality by itself but a base model +to implement gitlab related features diff --git a/gitlab/readme/USAGE.rst b/gitlab/readme/USAGE.rst new file mode 100644 index 000000000..6dd083c83 --- /dev/null +++ b/gitlab/readme/USAGE.rst @@ -0,0 +1,4 @@ +To use this module, you need to: + +#. Go to *Settings > Technical > Gitlab Connections*. +#. Create new gitlab connections by filling in the details and then you can test the gitlab connection by clicking on "Test Connection" button. diff --git a/gitlab/security/ir_model_access.xml b/gitlab/security/ir_model_access.xml new file mode 100644 index 000000000..c7a32b9b9 --- /dev/null +++ b/gitlab/security/ir_model_access.xml @@ -0,0 +1,12 @@ + + + + gitlab_access + + + + + + + + diff --git a/gitlab/static/description/index.html b/gitlab/static/description/index.html new file mode 100644 index 000000000..71b5e1c8e --- /dev/null +++ b/gitlab/static/description/index.html @@ -0,0 +1,433 @@ + + + + + +Gitlab + + + +
+

Gitlab

+ + +

Beta License: AGPL-3 OCA/server-backend Translate me on Weblate Try me on Runboat

+

This module does not provide a functionality by itself but a base model +to implement gitlab related features

+

Table of contents

+ +
+

Usage

+

To use this module, you need to:

+
    +
  1. Go to Settings > Technical > Gitlab Connections.
  2. +
  3. Create new gitlab connections by filling in the details and then you can test the gitlab connection by clicking on “Test Connection” button.
  4. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Onestein
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/server-backend project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/gitlab/tests/__init__.py b/gitlab/tests/__init__.py new file mode 100644 index 000000000..15d045949 --- /dev/null +++ b/gitlab/tests/__init__.py @@ -0,0 +1 @@ +from . import test_gitlab diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py new file mode 100644 index 000000000..0c6a5e708 --- /dev/null +++ b/gitlab/tests/test_gitlab.py @@ -0,0 +1,32 @@ +# Copyright 2024 Onestein +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from unittest.mock import patch + +from odoo import _ +from odoo.tests.common import TransactionCase + +from gitlab.client import Gitlab + + +class TestGitlab(TransactionCase): + def setUp(self): + super().setUp() + self.gitlab = self.env["gitlab"].create({"private_token": "test"}) + + def test_name_get(self): + self.assertTrue(self.gitlab.name_get()) + + def test_gitlab_connection(self): + action = self.gitlab.validate() + self.assertEqual(action["params"]["title"], _("Connection Test Failed!")) + + def auth(self): + return True + + with patch.object( + Gitlab, + "auth", + auth, + ): + action = self.gitlab.validate() + self.assertEqual(action["params"]["title"], _("Connection Test Succeeded!")) diff --git a/gitlab/views/gitlab_view.xml b/gitlab/views/gitlab_view.xml new file mode 100644 index 000000000..45b1af647 --- /dev/null +++ b/gitlab/views/gitlab_view.xml @@ -0,0 +1,39 @@ + + + + gitlab + +
+
+
+ + + + + + + + +
+
+
+ + + gitlab + + + + + + + + + + + Gitlab Connections + gitlab + tree,form + + +
diff --git a/requirements.txt b/requirements.txt index 09c20b176..ad8b78d0a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ # generated from manifests external_dependencies mysqlclient pymssql<=2.2.5 +python-gitlab sqlalchemy diff --git a/setup/gitlab/odoo/addons/gitlab b/setup/gitlab/odoo/addons/gitlab new file mode 120000 index 000000000..bc856988e --- /dev/null +++ b/setup/gitlab/odoo/addons/gitlab @@ -0,0 +1 @@ +../../../../gitlab \ No newline at end of file diff --git a/setup/gitlab/setup.py b/setup/gitlab/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/gitlab/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)