Skip to content

Commit

Permalink
frontend: migrate API projects namespace to flask-restx
Browse files Browse the repository at this point in the history
  • Loading branch information
nikromen committed Aug 17, 2023
1 parent 030dd32 commit f8e6766
Show file tree
Hide file tree
Showing 4 changed files with 380 additions and 167 deletions.
22 changes: 18 additions & 4 deletions frontend/coprs_frontend/coprs/views/apiv3_ns/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import json

import flask
import wtforms
import sqlalchemy
import inspect
from functools import wraps
from werkzeug.datastructures import ImmutableMultiDict, MultiDict
from werkzeug.exceptions import HTTPException, NotFound, GatewayTimeout
from sqlalchemy.orm.attributes import InstrumentedAttribute
from flask_restx import Api, Namespace, Resource
from coprs import app
from flask_restx import Api
from coprs.exceptions import (
AccessRestricted,
ActionInProgressException,
Expand Down Expand Up @@ -244,10 +243,25 @@ def wrapper(ownername, projectname, **kwargs):
'/'.join([ownername, projectname])
)
)
return f(copr, **kwargs)
return f(copr)
return wrapper


# TODO: sync editable_copr decorator with flask-restx once everything's migrated
def get_editable_copr(func):
"""
Apply @editable_copr decorator on endpoints migrated to flask-restx.
"""
@wraps(func)
def editable_copr_getter(*args, ownername, projectname):
def get_copr_from_dec(return_copr_from_decorator):
return return_copr_from_decorator

copr = editable_copr(get_copr_from_dec)(ownername, projectname)
return func(*args, copr)
return editable_copr_getter


def set_defaults(formdata, form_class):
"""
Take a `formdata` which can be `flask.request.form` or an output from
Expand Down
2 changes: 0 additions & 2 deletions frontend/coprs_frontend/coprs/views/apiv3_ns/apiv3_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
from .json2form import get_form_compatible_data




apiv3_builds_ns = Namespace("build", description="Builds")
api.add_namespace(apiv3_builds_ns)

Expand Down
Loading

0 comments on commit f8e6766

Please sign in to comment.