Skip to content

Commit

Permalink
[MIG] endpoint_route_handler: migrate to V15
Browse files Browse the repository at this point in the history
  • Loading branch information
astirpe committed May 19, 2024
1 parent 6b5e9d9 commit 7aa46a0
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 31 deletions.
2 changes: 1 addition & 1 deletion endpoint_route_handler/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"name": "Endpoint route handler",
"summary": """Provide mixin and tool to generate custom endpoints on the fly.""",
"version": "14.0.2.0.1",
"version": "15.0.1.0.0",
"license": "LGPL-3",
"development_status": "Beta",
"author": "Camptocamp,Odoo Community Association (OCA)",
Expand Down
20 changes: 0 additions & 20 deletions endpoint_route_handler/migrations/14.0.2.0.0/pre-migrate.py

This file was deleted.

5 changes: 3 additions & 2 deletions endpoint_route_handler/models/endpoint_route_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ def _check_route(self):
for rec in self:
if rec.route in self._blacklist_routes:
raise exceptions.UserError(
_("`%s` uses a blacklisted routed = `%s`") % (rec.name, rec.route)
_("`%(name)s` uses a blacklisted routed = `%(route)s`")
% {"name": rec.name, "route": rec.route}
)

@api.constrains("request_method", "request_content_type")
Expand All @@ -191,7 +192,7 @@ def _prepare_endpoint_rules(self, options=None):
return [rec._make_controller_rule(options=options) for rec in self]

def _registered_endpoint_rule_keys(self):
return tuple([rec._endpoint_registry_unique_key() for rec in self])
return tuple(rec._endpoint_registry_unique_key() for rec in self)

def _endpoint_registry_unique_key(self):
return "{0._name}:{0.id}".format(self)
Expand Down
7 changes: 4 additions & 3 deletions endpoint_route_handler/models/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ def _get_routing_map_last_version(cls, env):

@classmethod
def _clear_routing_map(cls):
super()._clear_routing_map()
res = super()._clear_routing_map()
if hasattr(cls, "_endpoint_route_last_version"):
cls._endpoint_route_last_version = 0
return res

@classmethod
def _auth_method_user_endpoint(cls):
Expand All @@ -77,5 +78,5 @@ def _auth_method_user_endpoint(cls):
"""
try:
cls._auth_method_user()
except http.SessionExpiredException:
raise werkzeug.exceptions.Unauthorized()
except http.SessionExpiredException as err:
raise werkzeug.exceptions.Unauthorized() from err
2 changes: 2 additions & 0 deletions endpoint_route_handler/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
* Simone Orsi <simone.orsi@camptocamp.com>
* [360ERP](https://www.360erp.com):
- Andrea Stirpe
4 changes: 2 additions & 2 deletions endpoint_route_handler/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

import contextlib

from odoo.tests.common import SavepointCase, tagged
from odoo.tests.common import TransactionCase, tagged
from odoo.tools import DotDict

from odoo.addons.website.tools import MockRequest


@tagged("-at_install", "post_install")
class CommonEndpoint(SavepointCase):
class CommonEndpoint(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down
6 changes: 3 additions & 3 deletions endpoint_route_handler/tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from psycopg2 import DatabaseError

from odoo import http
from odoo.tests.common import SavepointCase, tagged
from odoo.tests.common import TransactionCase, tagged
from odoo.tools import mute_logger

from odoo.addons.endpoint_route_handler.exceptions import EndpointHandlerNotFound
Expand All @@ -15,7 +15,7 @@


@tagged("-at_install", "post_install")
class TestRegistry(SavepointCase):
class TestRegistry(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down Expand Up @@ -118,7 +118,7 @@ def test_get_rules(self):
self.assertEqual(self._count_rules(), 7)
self.reg.get_rules()
self.assertEqual(
sorted([x.key for x in self.reg.get_rules()]),
sorted(x.key for x in self.reg.get_rules()),
sorted(
[
"route1",
Expand Down
6 changes: 6 additions & 0 deletions setup/endpoint_route_handler/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 7aa46a0

Please sign in to comment.