Skip to content

Commit

Permalink
[IMP] Moved endpoint_removed out of util.py into blueprints namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
c8y3 committed Oct 8, 2024
1 parent 8b98929 commit ccbc9ea
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/case/case_notes_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from app.schema.marshables import CommentSchema
from app.blueprints.access_controls import ac_requires_case_identifier
from app.blueprints.access_controls import ac_api_requires
from app.util import endpoint_removed
from app.blueprints.rest.endpoints import endpoint_removed
from app.util import response_error
from app.util import response_success

Expand Down
12 changes: 11 additions & 1 deletion source/app/blueprints/rest/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

from functools import wraps

from app import app
from app.business.errors import BusinessProcessingError
from app.util import response
from app.util import response_error

logger = app.logger

Expand Down Expand Up @@ -60,3 +61,12 @@ def wrap(*args, **kwargs):
return result
return wrap
return inner_wrap


def endpoint_removed(message, version):
def inner_wrap(f):
@wraps(f)
def wrap(*args, **kwargs):
return response_error(f"Endpoint deprecated in {version}. {message}.", status=410)
return wrap
return inner_wrap
2 changes: 1 addition & 1 deletion source/app/blueprints/rest/profile_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from app.blueprints.access_controls import ac_api_requires
from app.util import response_error
from app.util import response_success
from app.util import endpoint_removed
from app.blueprints.rest.endpoints import endpoint_removed

profile_rest_blueprint = Blueprint('profile_rest', __name__)

Expand Down
10 changes: 0 additions & 10 deletions source/app/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from flask import session
from flask import url_for
from flask_login import current_user
from functools import wraps
from pathlib import Path
from pyunpack import Archive
from sqlalchemy.ext.declarative import DeclarativeMeta
Expand Down Expand Up @@ -234,15 +233,6 @@ def regenerate_session():
session.modified = True


def endpoint_removed(message, version):
def inner_wrap(f):
@wraps(f)
def wrap(*args, **kwargs):
return response_error(f"Endpoint deprecated in {version}. {message}.", status=410)
return wrap
return inner_wrap


def decompress_7z(filename: Path, output_dir):
"""
Decompress a 7z file in specified output directory
Expand Down

0 comments on commit ccbc9ea

Please sign in to comment.