-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from jadmsaadaot/SUBMIT-task#16
Load and confirm project data - integrate front-end and backend
- Loading branch information
Showing
47 changed files
with
404 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Add name to account projects | ||
Revision ID: 5a6eda61c0c4 | ||
Revises: aeb2ae9d64b9 | ||
Create Date: 2024-08-15 11:55:47.490418 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '5a6eda61c0c4' | ||
down_revision = 'aeb2ae9d64b9' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('account_projects', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('name', sa.String(), nullable=False)) | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('account_projects', schema=None) as batch_op: | ||
batch_op.drop_column('name') | ||
|
||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
|
||
from .db import db | ||
|
||
|
||
TENANT_ID = 'tenant_id' | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright © 2024 Province of British Columbia | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the 'License'); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an 'AS IS' BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""API endpoints for managing a project resource.""" | ||
|
||
from http import HTTPStatus | ||
|
||
from flask_restx import Namespace, Resource, cors | ||
|
||
from submit_api.schemas.project import AddProjectSchema, ProjectSchema | ||
from submit_api.services.project_service import ProjectService | ||
from submit_api.utils.util import cors_preflight | ||
|
||
from .apihelper import Api as ApiHelper | ||
|
||
|
||
API = Namespace("projects", description="Endpoints for Project Management") | ||
"""Custom exception messages | ||
""" | ||
|
||
project_add_list = ApiHelper.convert_ma_schema_to_restx_model( | ||
API, AddProjectSchema(), "Project Add" | ||
) | ||
project_list_model = ApiHelper.convert_ma_schema_to_restx_model( | ||
API, ProjectSchema(), "Project" | ||
) | ||
|
||
|
||
@cors_preflight("GET, OPTIONS, POST") | ||
@API.route("", methods=["POST", "GET", "OPTIONS"]) | ||
class Projects(Resource): | ||
"""Resource for managing projects.""" | ||
|
||
@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") | ||
@cors.crossdomain(origin="*") | ||
def post(): | ||
"""Add projects in bulk.""" | ||
projects_data = AddProjectSchema(many=True).load(API.payload) | ||
added_projects = ProjectService.bulk_add_projects(projects_data) | ||
return ProjectSchema(many=True).dump(added_projects), HTTPStatus.CREATED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""Service for project management.""" | ||
from submit_api.models.account_project import AccountProject as ProjectModel | ||
|
||
|
||
class ProjectService: | ||
"""Project management service.""" | ||
|
||
@classmethod | ||
def get_project_by_id(cls, _project_id): | ||
"""Get project by id.""" | ||
db_project = ProjectModel.find_by_id(_project_id) | ||
return db_project | ||
|
||
@classmethod | ||
def bulk_add_projects(cls, projects): | ||
"""Add projects in bulk.""" | ||
ProjectModel.add_projects_bulk(projects) | ||
return projects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
to test api helper functions | ||
""" | ||
import pytest | ||
|
||
from submit_api.resources.apihelper import Api | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
|
||
from submit_api.config import get_named_config | ||
|
||
|
||
CONFIG = get_named_config('testing') | ||
fake = Faker() | ||
|
||
|
Oops, something went wrong.