Skip to content

Commit 4c38c19

Browse files
committed
[ADD] vcp
1 parent f45f8f5 commit 4c38c19

38 files changed

Lines changed: 2396 additions & 0 deletions

vcp/README.rst

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
===
2+
Vcp
3+
===
4+
5+
..
6+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
7+
!! This file is generated by oca-gen-addon-readme !!
8+
!! changes will be overwritten. !!
9+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10+
!! source digest: sha256:e5814614bba4bc7f628d116d3529a253bb2ae9bff8e8a16c3cfc7eefa5def3cf
11+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12+
13+
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
14+
:target: https://odoo-community.org/page/development-status
15+
:alt: Beta
16+
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
17+
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
18+
:alt: License: AGPL-3
19+
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fversion--control--platform-lightgray.png?logo=github
20+
:target: https://github.com/OCA/version-control-platform/tree/18.0/vcp
21+
:alt: OCA/version-control-platform
22+
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23+
:target: https://translation.odoo-community.org/projects/version-control-platform-18-0/version-control-platform-18-0-vcp
24+
:alt: Translate me on Weblate
25+
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26+
:target: https://runboat.odoo-community.org/builds?repo=OCA/version-control-platform&target_branch=18.0
27+
:alt: Try me on Runboat
28+
29+
|badge1| |badge2| |badge3| |badge4| |badge5|
30+
31+
Creates a set of modules used for handling a version control patform.
32+
33+
**Table of contents**
34+
35+
.. contents::
36+
:local:
37+
38+
Use Cases / Context
39+
===================
40+
41+
The aim of this module is to allow any community to import data from a
42+
version control system.
43+
44+
The system should be done in a way that is agnostic to the system and
45+
the connections are handled directly by specific modules.
46+
47+
Bug Tracker
48+
===========
49+
50+
Bugs are tracked on `GitHub Issues <https://github.com/OCA/version-control-platform/issues>`_.
51+
In case of trouble, please check there if your issue has already been reported.
52+
If you spotted it first, help us to smash it by providing a detailed and welcomed
53+
`feedback <https://github.com/OCA/version-control-platform/issues/new?body=module:%20vcp%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
54+
55+
Do not contact contributors directly about support or help with technical issues.
56+
57+
Credits
58+
=======
59+
60+
Authors
61+
-------
62+
63+
* Dixmit
64+
65+
Contributors
66+
------------
67+
68+
- `Dixmit <https://dixmit.com>`__
69+
70+
- Enric Tobella
71+
72+
- `Akretion <https://akretion.com>`__
73+
74+
- Sebastien Beau
75+
76+
Maintainers
77+
-----------
78+
79+
This module is maintained by the OCA.
80+
81+
.. image:: https://odoo-community.org/logo.png
82+
:alt: Odoo Community Association
83+
:target: https://odoo-community.org
84+
85+
OCA, or the Odoo Community Association, is a nonprofit organization whose
86+
mission is to support the collaborative development of Odoo features and
87+
promote its widespread use.
88+
89+
This module is part of the `OCA/version-control-platform <https://github.com/OCA/version-control-platform/tree/18.0/vcp>`_ project on GitHub.
90+
91+
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

vcp/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import controllers
2+
from . import models

vcp/__manifest__.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2025 Dixmit
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
{
5+
"name": "Vcp",
6+
"summary": """Virtual Control Platform core module""",
7+
"version": "18.0.1.0.0",
8+
"license": "AGPL-3",
9+
"author": "Dixmit,Odoo Community Association (OCA)",
10+
"website": "https://github.com/OCA/version-control-platform",
11+
"depends": ["website_partner"],
12+
"data": [
13+
"security/ir.model.access.csv",
14+
"data/ir_cron.xml",
15+
"templates/templates.xml",
16+
"views/menu.xml",
17+
"views/vcp_comment.xml",
18+
"views/vcp_review.xml",
19+
"views/vcp_request.xml",
20+
"views/vcp_repository.xml",
21+
"views/vcp_branch.xml",
22+
"views/vcp_platform.xml",
23+
],
24+
"demo": [],
25+
"assets": {
26+
"web.assets_frontend": [
27+
"vcp/static/src/components/**/*.esm.js",
28+
"vcp/static/src/components/**/*.xml",
29+
"vcp/static/src/components/**/*.scss",
30+
],
31+
"web.assets_tests": [
32+
"vcp/static/tests/**/*",
33+
],
34+
},
35+
}

vcp/controllers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import main

vcp/controllers/main.py

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# Copyright 2026 Dixmit
2+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
3+
4+
from math import sqrt
5+
6+
from odoo import _, http
7+
from odoo.http import request
8+
9+
from odoo.addons.portal.controllers.portal import CustomerPortal
10+
11+
12+
class ContributorsController(CustomerPortal):
13+
@http.route(
14+
[
15+
"/vcp",
16+
"/vcp/<string:vcp>",
17+
],
18+
type="http",
19+
auth="user",
20+
website=True,
21+
)
22+
def contributors_vcp(self, vcp=None):
23+
values = self._prepare_portal_layout_values()
24+
values.update(self._prepare_home_portal_values([]))
25+
if vcp is None:
26+
vcps = request.env["vcp.platform"].search([])
27+
return request.render(
28+
"vcp.vcp_platforms_template",
29+
{"vcps": vcps, **values},
30+
)
31+
vcp_id = (
32+
request.env["vcp.platform"]
33+
.sudo()
34+
.search([("name", "=ilike", vcp)], limit=1)
35+
.id
36+
)
37+
return request.render(
38+
"vcp.vcp_platform_template",
39+
{"vcp": vcp_id, **values},
40+
)
41+
42+
def _get_index(self, data):
43+
return round(
44+
sqrt(data["created_requests"])
45+
+ data["merged_requests"]
46+
+ sqrt(data["comments"])
47+
+ data["reviews"],
48+
2,
49+
)
50+
51+
def _get_field(self, kind):
52+
if kind == "contributors":
53+
return "partner_id"
54+
elif kind == "organizations":
55+
return "organization_id"
56+
elif kind == "repositories":
57+
return "repository_id"
58+
return False
59+
60+
@http.route(["/vcp-fetch"], type="json", auth="user", readonly=True)
61+
def fetch_vcp_data(self, vcp_id, year, month, kind, period, **values):
62+
vcp = request.env["vcp.platform"].browse(vcp_id).exists()
63+
if not vcp:
64+
return []
65+
start, end = vcp._get_dates(year, month, period, **values)
66+
data = vcp._generate_data(start, end, self._get_field(kind), kind, **values)
67+
return {
68+
"columns": self._get_vcp_columns(kind),
69+
"data": self._improve_vcp_data(data, kind, **values),
70+
}
71+
72+
def _get_vcp_columns(self, kind):
73+
if kind == "contributors":
74+
return [
75+
{"field": "name", "title": _("Name"), "kind": "name"},
76+
{
77+
"field": "created_requests",
78+
"title": _("Created Requests"),
79+
"kind": "float",
80+
"decimals": 0,
81+
},
82+
{
83+
"field": "merged_requests",
84+
"title": _("Merged Requests"),
85+
"kind": "float",
86+
"decimals": 0,
87+
},
88+
{
89+
"field": "comments",
90+
"title": _("Comments"),
91+
"kind": "float",
92+
"decimals": 0,
93+
},
94+
{
95+
"field": "reviews",
96+
"title": _("Reviews"),
97+
"kind": "float",
98+
"decimals": 0,
99+
},
100+
]
101+
elif kind == "organizations":
102+
return [
103+
{"field": "name", "title": _("Organization Name"), "kind": "name"},
104+
{
105+
"field": "created_requests",
106+
"title": _("Created Requests"),
107+
"kind": "float",
108+
"decimals": 0,
109+
},
110+
{
111+
"field": "merged_requests",
112+
"title": _("Merged Requests"),
113+
"kind": "float",
114+
"decimals": 0,
115+
},
116+
{
117+
"field": "comments",
118+
"title": _("Comments"),
119+
"kind": "float",
120+
"decimals": 0,
121+
},
122+
{
123+
"field": "reviews",
124+
"title": _("Reviews"),
125+
"kind": "float",
126+
"decimals": 0,
127+
},
128+
{
129+
"field": "developers",
130+
"title": _("Developers"),
131+
"kind": "float",
132+
"decimals": 0,
133+
},
134+
]
135+
elif kind == "repositories":
136+
return [
137+
{"field": "name", "title": _("Repository Name"), "kind": "name"},
138+
{
139+
"field": "created_requests",
140+
"title": _("Created Requests"),
141+
"kind": "float",
142+
"decimals": 0,
143+
},
144+
{
145+
"field": "merged_requests",
146+
"title": _("Merged Requests"),
147+
"kind": "float",
148+
"decimals": 0,
149+
},
150+
{
151+
"field": "comments",
152+
"title": _("Comments"),
153+
"kind": "float",
154+
"decimals": 0,
155+
},
156+
{
157+
"field": "reviews",
158+
"title": _("Reviews"),
159+
"kind": "float",
160+
"decimals": 0,
161+
},
162+
{
163+
"field": "developers",
164+
"title": _("Developers"),
165+
"kind": "float",
166+
"decimals": 0,
167+
},
168+
]
169+
return []
170+
171+
def _improve_vcp_data(self, data, kind, **kwargs):
172+
for key, values in data.items():
173+
if kind == "contributors":
174+
partner = request.env["res.partner"].browse(key)
175+
values["name"] = partner._get_contributors_name(kind, **kwargs)
176+
values["url"] = partner._get_contributor_url()
177+
elif kind == "organizations":
178+
organization = request.env["res.partner"].browse(key)
179+
values["name"] = organization._get_contributors_name(kind, **kwargs)
180+
values["url"] = organization._get_contributor_url()
181+
elif kind == "repositories":
182+
repository = request.env["vcp.repository"].browse(key)
183+
values["name"] = repository.name
184+
values["url"] = repository._get_repository_url()
185+
return data

vcp/data/ir_cron.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!-- Copyright 2026 Dixmit
3+
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
4+
<odoo noupdate="1">
5+
<record model="ir.cron" id="cron_repository_update">
6+
<field name="name">VCP: Repository Update</field>
7+
<field name="model_id" ref="model_vcp_repository" />
8+
<field name="state">code</field>
9+
<field name="code">model._cron_update_repositories()</field>
10+
<field name="interval_number">1</field>
11+
<field name="interval_type">minutes</field>
12+
<field name="active">False</field>
13+
</record>
14+
<record model="ir.cron" id="cron_platform_update">
15+
<field name="name">VCP: Platform Update</field>
16+
<field name="model_id" ref="model_vcp_platform" />
17+
<field name="state">code</field>
18+
<field name="code">model._cron_update_platforms()</field>
19+
<field name="interval_number">1</field>
20+
<field name="interval_type">days</field>
21+
<field name="active">False</field>
22+
</record>
23+
</odoo>

vcp/models/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from . import vcp_platform
2+
from . import vcp_branch
3+
from . import vcp_repository
4+
from . import vcp_request
5+
from . import vcp_review
6+
from . import vcp_comment
7+
from . import res_partner

0 commit comments

Comments
 (0)