Skip to content

Commit

Permalink
Merge pull request #132 from jadmsaadaot/SUBMIT-task#204
Browse files Browse the repository at this point in the history
Add removed resource
  • Loading branch information
jadmsaadaot authored Nov 1, 2024
2 parents d56c84c + 0270778 commit f6094f0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion submit-api/src/submit_api/models/queries/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_projects_by_account_id(cls, account_id: int, search_options: AccountProj
).join(AccountProject.project)

# Apply search filters if provided
if search_options:
if search_options and any(bool(search_option) for search_option in search_options.__dict__.values()):
query = cls.filter_by_search_criteria(query, search_options)

return query.all()
Expand Down
17 changes: 17 additions & 0 deletions submit-api/src/submit_api/resources/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ def get(account_id):
projects = ProjectService.get_projects_by_account_id(account_id, search_options)
return AccountProjectSchema(many=True).dump(projects), HTTPStatus.OK

@staticmethod
@ApiHelper.swagger_decorators(API, endpoint_description="Add projects in bulk")
@API.expect(project_add_list)
@API.response(
code=HTTPStatus.CREATED, model=project_list_model, description="Added projects"
)
@API.response(HTTPStatus.BAD_REQUEST, "Bad Request")
@auth.require
@cors.crossdomain(origin="*")
def post(account_id):
"""Add projects in bulk."""
projects_data = AddProjectSchema().load(API.payload)
added_projects = ProjectService.bulk_add_projects(
account_id, projects_data.get("project_ids")
)
return ProjectSchema(many=True).dump(added_projects), HTTPStatus.CREATED


@cors_preflight("GET, OPTIONS, POST")
@API.route("/proponents/<int:proponent_id>", methods=["POST", "GET", "OPTIONS"])
Expand Down

0 comments on commit f6094f0

Please sign in to comment.