Skip to content

Commit

Permalink
Merge pull request OpenG2P#190 from Abhishek-Wagh/17.0-develop
Browse files Browse the repository at this point in the history
well-known Api implementation in fastapi
  • Loading branch information
shibu-narayanan authored Feb 7, 2024
2 parents 4fac1f6 + 34fbcaf commit af35093
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 46 deletions.
3 changes: 1 addition & 2 deletions g2p_payment_files/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Part of OpenG2P. See LICENSE file for full copyright and licensing details.
from . import models
from . import controllers
from . import services
from . import models
4 changes: 3 additions & 1 deletion g2p_payment_files/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"depends": [
"g2p_programs",
"g2p_program_documents",
"g2p_programs_rest_api",
# "g2p_programs_rest_api",
"fastapi",
"mail",
],
"external_dependencies": {
Expand All @@ -32,6 +33,7 @@
"views/payment_batch_tag_view.xml",
"views/payment_manager_view.xml",
"views/payment_view.xml",
"data/fastapi_endpoint.xml",
],
"assets": {},
"demo": [],
Expand Down
2 changes: 1 addition & 1 deletion g2p_payment_files/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import payments
from . import well_known
7 changes: 0 additions & 7 deletions g2p_payment_files/controllers/payments.py

This file was deleted.

19 changes: 19 additions & 0 deletions g2p_payment_files/controllers/well_known.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import json
from typing import Annotated

from fastapi import APIRouter, Depends

from odoo.api import Environment

from odoo.addons.fastapi.dependencies import odoo_env

# create a router
api_router = APIRouter()


@api_router.get("/jwks.json")
def get_partners(env: Annotated[Environment, Depends(odoo_env)]):
CryptoKeySet = env["g2p.crypto.key.set"].sudo()
key_sets = CryptoKeySet.search([("status", "=", "active")])
jwks = [json.loads(key_set.jwk) for key_set in key_sets]
return {"keys": jwks}
9 changes: 9 additions & 0 deletions g2p_payment_files/data/fastapi_endpoint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<odoo>
<!-- -->
<record id="fastapi_endpoint_data" model="fastapi.endpoint">
<field name="name">payment</field>
<field name="app">payment</field>
<field name="root_path">/apiv1payment</field>
<!-- <field name="registry_sync" eval="obj()._add_after_commit_hook([obj().id]) and False"/> -->
</record>
</odoo>
1 change: 1 addition & 0 deletions g2p_payment_files/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
from . import payment_file_qrcode_config
from . import payment_manager
from . import payment
from . import fastapi_endpoint
15 changes: 15 additions & 0 deletions g2p_payment_files/models/fastapi_endpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from odoo import fields, models

from ..controllers.well_known import api_router


class WellknownComponent(models.Model):
_inherit = "fastapi.endpoint"
app: str = fields.Selection(
selection_add=[("payment", "Payment")], ondelete={"payment": "cascade"}
)

def _get_fastapi_routers(self):
if self.app == "payment":
return [api_router]
return super()._get_fastapi_routers()
1 change: 0 additions & 1 deletion g2p_payment_files/services/__init__.py

This file was deleted.

34 changes: 0 additions & 34 deletions g2p_payment_files/services/well_known.py

This file was deleted.

0 comments on commit af35093

Please sign in to comment.