Skip to content

Commit

Permalink
fastapi_auth_partner: better field naming
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienbeau committed Sep 11, 2023
1 parent 819aeee commit 574380e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion fastapi_auth_partner/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __call__(
if vals["did"] == directory.id and vals["pid"]:
partner = env["res.partner"].browse(vals["pid"]).exists()
if partner:
auth = partner.sudo().partner_auth_ids.filtered(
auth = partner.sudo().auth_partner_ids.filtered(
lambda s: s.directory_id == directory
)
if auth:
Expand Down
2 changes: 1 addition & 1 deletion fastapi_auth_partner/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ResPartner(models.Model):

# guest logic should be move in an dependency module
guest = fields.Boolean()
partner_auth_ids = fields.One2many(
auth_partner_ids = fields.One2many(
"fastapi.auth.partner", "partner_id", "Partner Auth"
)
count_partner_auth = fields.Integer(compute="_compute_count_partner_auth")
Expand Down
6 changes: 3 additions & 3 deletions fastapi_auth_partner/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def profile(
endpoint: Annotated[FastapiEndpoint, Depends(fastapi_endpoint)],
partner: Annotated[Partner, Depends(auth_partner_authenticated_partner)],
) -> AuthPartnerResponse:
partner_auth = partner.partner_auth_ids.filtered(
partner_auth = partner.auth_partner_ids.filtered(
lambda s: s.directory_id == endpoint.sudo().directory_id
)
return AuthPartnerResponse.from_orm(partner_auth)
Expand All @@ -114,7 +114,7 @@ def _prepare_partner_register(self, directory, data):
return {
"name": data.name,
"email": data.login,
"partner_auth_ids": [
"auth_partner_ids": [
(0, 0, self._prepare_partner_auth_register(directory, data))
],
}
Expand All @@ -129,7 +129,7 @@ def _prepare_partner_auth_register(self, directory, data):
def _register_auth(self, directory, data):
vals = self._prepare_partner_register(directory, data)
partner = self.env["res.partner"].create([vals])
return partner.partner_auth_ids
return partner.auth_partner_ids

def _login(self, directory, data):
partner_auth = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def whoami_public_or_partner(
],
) -> AuthPartnerResponse:
if partner:
return AuthPartnerResponse.from_orm(partner.partner_auth_ids)
return AuthPartnerResponse.from_orm(partner.auth_partner_ids)
return AuthPartnerResponse(login="no-one")


Expand Down

0 comments on commit 574380e

Please sign in to comment.