Skip to content

Commit

Permalink
Fixed history table, token and linting issues. (#3029)
Browse files Browse the repository at this point in the history
  • Loading branch information
pwei1018 authored Sep 20, 2024
2 parents b387965 + c070212 commit 458939f
Show file tree
Hide file tree
Showing 12 changed files with 548 additions and 117 deletions.
424 changes: 424 additions & 0 deletions auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py

Large diffs are not rendered by default.

202 changes: 104 additions & 98 deletions auth-api/poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion auth-api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "auth-api"
version = "3.0.1"
version = "3.0.2"
description = ""
authors = ["\"BC Registries and Online Services\""]
readme = "README.md"
Expand Down
12 changes: 7 additions & 5 deletions auth-api/src/auth_api/exceptions/exception_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,29 @@ def __init__(self, app=None):
if app:
self.init_app(app)

def auth_handler(self, error): # pylint: disable=no-self-use
def auth_handler(self, error): # pylint: disable=useless-option-value
"""Handle AuthError."""
http_logger.error(error.error)
return error.error, error.status_code, RESPONSE_HEADERS

def db_handler(self, error): # pylint: disable=no-self-use
def db_handler(self, error): # pylint: disable=useless-option-value
"""Handle Database error."""
logger.exception(error)
error_text = error.__dict__["code"] if hasattr(error.__dict__, "code") else ""
message_text = str(error.__dict__["orig"]) if hasattr(error.__dict__, "orig") else "Internal server error"
status_code = error.status_code if hasattr(error, "status_code") else 500
return {"error": "{}".format(error_text), "message": "{}".format(message_text)}, status_code, RESPONSE_HEADERS

def std_handler(self, error): # pylint: disable=no-self-use
def std_handler(self, error): # pylint: disable=useless-option-value
"""Handle standard exception."""
if isinstance(error, HTTPException):
http_logger.error(error)
message = dict(message=error.message if hasattr(error, "message") else error.description)
message = dict( # pylint: disable=use-dict-literal
message=error.message if hasattr(error, "message") else error.description
)
else:
logger.exception(error)
message = dict(message="Internal server error")
message = dict(message="Internal server error") # pylint: disable=use-dict-literal
return message, error.code if isinstance(error, HTTPException) else 500, RESPONSE_HEADERS

def init_app(self, app):
Expand Down
2 changes: 1 addition & 1 deletion auth-api/src/auth_api/models/activity_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ActivityLog(BaseModel): # pylint: disable=too-few-public-methods,too-many
org_id = Column(Integer, nullable=True, index=True)

@classmethod
def fetch_activity_logs_for_account( # pylint: disable=too-many-arguments
def fetch_activity_logs_for_account( # pylint: disable=too-many-positional-arguments,too-many-arguments
cls,
org_id: int,
item_name: str,
Expand Down
2 changes: 0 additions & 2 deletions auth-api/src/auth_api/models/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
The class and schema are both present in this module.
"""

from flask import current_app
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String
from sqlalchemy.orm import relationship

Expand Down
2 changes: 1 addition & 1 deletion auth-api/src/auth_api/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def create_from_jwt_token(cls, first_name: str, last_name: str, **kwargs):
@user_context
def update_from_jwt_token(
cls,
user, # pylint:disable=too-many-arguments
user, # pylint:disable=too-many-positional-arguments
first_name: str,
last_name: str,
is_login: bool = False,
Expand Down
2 changes: 1 addition & 1 deletion auth-api/src/auth_api/models/user_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class UserSettings: # pylint: disable=too-few-public-methods, too-many-instance
Can extended to product which user has access to.
"""

def __init__( # pylint: disable=too-many-arguments
def __init__( # pylint: disable=too-many-positional-arguments,too-many-arguments
self,
id_,
label,
Expand Down
2 changes: 1 addition & 1 deletion auth-api/src/auth_api/services/invitation.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def send_admin_notification(user, url, recipient_email_list, org_name, org_id):
raise BusinessException(Error.FAILED_NOTIFICATION, None) from e

@staticmethod
def send_invitation( # pylint: disable=too-many-arguments
def send_invitation( # pylint: disable=too-many-positional-arguments,too-many-arguments
invitation: InvitationModel,
org_name,
org_id,
Expand Down
2 changes: 1 addition & 1 deletion auth-api/src/auth_api/services/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def create_membership(access_type, org, user_id, **kwargs):
@user_context
def _create_payment_settings(
org_model: OrgModel,
payment_info: dict, # pylint: disable=too-many-arguments
payment_info: dict, # pylint: disable=too-many-positional-arguments
payment_method: str,
mailing_address=None,
is_new_org: bool = True,
Expand Down
12 changes: 6 additions & 6 deletions auth-api/src/auth_api/services/rest_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RestService:
"""Service to invoke Rest services which uses OAuth 2.0 implementation."""

@staticmethod
def _invoke( # pylint: disable=too-many-arguments
def _invoke( # pylint: disable=too-many-positional-arguments,too-many-arguments
rest_method,
endpoint,
token=None,
Expand Down Expand Up @@ -102,7 +102,7 @@ def __log_response(response):
current_app.logger.info(f"response : {response.text if response else ''}")

@staticmethod
def post( # pylint: disable=too-many-arguments
def post( # pylint: disable=too-many-positional-arguments,too-many-arguments
endpoint,
token=None,
auth_header_type: AuthHeaderType = AuthHeaderType.BEARER,
Expand All @@ -127,7 +127,7 @@ def post( # pylint: disable=too-many-arguments
)

@staticmethod
def put( # pylint: disable=too-many-arguments
def put( # pylint: disable=too-many-positional-arguments,too-many-arguments
endpoint,
token=None,
auth_header_type: AuthHeaderType = AuthHeaderType.BEARER,
Expand All @@ -140,7 +140,7 @@ def put( # pylint: disable=too-many-arguments
return RestService._invoke("put", endpoint, token, auth_header_type, content_type, data, raise_for_status)

@staticmethod
def patch( # pylint: disable=too-many-arguments
def patch( # pylint: disable=too-many-positional-arguments,too-many-arguments
endpoint,
token=None,
auth_header_type: AuthHeaderType = AuthHeaderType.BEARER,
Expand All @@ -165,7 +165,7 @@ def patch( # pylint: disable=too-many-arguments
)

@staticmethod
def delete( # pylint: disable=too-many-arguments
def delete( # pylint: disable=too-many-positional-arguments,too-many-arguments
endpoint,
token=None,
auth_header_type: AuthHeaderType = AuthHeaderType.BEARER,
Expand All @@ -190,7 +190,7 @@ def delete( # pylint: disable=too-many-arguments
)

@staticmethod
def get( # pylint: disable=too-many-arguments
def get( # pylint: disable=too-many-positional-arguments,too-many-arguments
endpoint,
token=None,
auth_header_type: AuthHeaderType = AuthHeaderType.BEARER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
"""

__version__ = '2.18.4' # pylint: disable=invalid-name
__version__ = '2.18.4' # pylint: disable=invalid-name

0 comments on commit 458939f

Please sign in to comment.