Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/routes/agencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from backend.mixpanel.mix import track_to_mp
from backend.database.models.user import UserRole
from backend.database.models.agency import Agency
from .tmp.pydantic.agencies import CreateAgency, UpdateAgency
from flask import Blueprint, abort, request
from flask_jwt_extended.view_decorators import jwt_required
from npdi_oas.agencies import CreateAgency, UpdateAgency
from pydantic import BaseModel


Expand Down Expand Up @@ -46,7 +46,7 @@ def create_agency():
body: CreateAgency = request.validated_body

try:
agency = Agency.from_dict(body.dict())
agency = Agency.from_dict(body.model_dump())
except NodeConflictException:
abort(409, description="Agency already exists")
except Exception as e:
Expand Down Expand Up @@ -95,7 +95,7 @@ def update_agency(agency_uid: str):
abort(404, description="Agency not found")

try:
agency = Agency.from_dict(body.dict(), agency_uid)
agency = Agency.from_dict(body.model_dump(), agency_uid)
agency.refresh()
track_to_mp(
request,
Expand Down
6 changes: 3 additions & 3 deletions backend/routes/officers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from backend.schemas import validate_request, ordered_jsonify, paginate_results
from backend.database.models.user import UserRole, User
from backend.database.models.officer import Officer
from .tmp.pydantic.officers import CreateOfficer, UpdateOfficer
from flask import Blueprint, abort, request
from flask_jwt_extended import get_jwt
from flask_jwt_extended.view_decorators import jwt_required
from npdi_oas.officers import CreateOfficer, UpdateOfficer
from pydantic import BaseModel


Expand Down Expand Up @@ -138,7 +138,7 @@ def create_officer():
current_user = User.get(jwt_decoded["sub"])

# try:
officer = Officer.from_dict(body.dict())
officer = Officer.from_dict(body.model_dump())
# except Exception as e:
# abort(400, description=str(e))

Expand Down Expand Up @@ -200,7 +200,7 @@ def update_officer(officer_uid: str):
abort(404, description="Officer not found")

try:
o = Officer.from_dict(body.dict(), officer_uid)
o = Officer.from_dict(body.model_dump(), officer_uid)
o.refresh()
except Exception as e:
abort(400, description=str(e))
Expand Down
18 changes: 9 additions & 9 deletions backend/routes/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from ..schemas import (
validate_request, paginate_results, ordered_jsonify,
NodeConflictException)
from .tmp.pydantic.partners import CreatePartner, UpdatePartner
from flask import Blueprint, abort, current_app, request
from flask_jwt_extended import get_jwt
from flask_jwt_extended.view_decorators import jwt_required
from npdi_oas.sources import CreateSource, UpdateSource

from ..database import (
Source,
Expand Down Expand Up @@ -39,11 +39,11 @@ def get_sources(source_uid: str):
@bp.route("/", methods=["POST"])
@jwt_required()
@min_role_required(UserRole.PUBLIC)
@validate_request(CreatePartner)
@validate_request(CreateSource)
def create_source():
"""Create a contributing source."""
logger = logging.getLogger("create_source")
body: CreatePartner = request.validated_body
body: CreateSource = request.validated_body
jwt_decoded = get_jwt()
current_user = User.get(jwt_decoded["sub"])

Expand All @@ -58,7 +58,7 @@ def create_source():

# Creates a new instance of the Source and saves it to the DB
try:
new_p = Source.from_dict(body.dict())
new_p = Source.from_dict(body.model_dump())
except NodeConflictException:
abort(409, description="Source already exists")
except Exception as e:
Expand Down Expand Up @@ -114,10 +114,10 @@ def get_all_sources():
@bp.route("/<source_uid>", methods=["PATCH"])
@jwt_required()
@min_role_required(UserRole.PUBLIC)
@validate_request(UpdatePartner)
@validate_request(UpdateSource)
def update_source(source_uid: str):
"""Update a source's information."""
body: UpdatePartner = request.validated_body
body: UpdateSource = request.validated_body
current_user = User.get(get_jwt()["sub"])
p = Source.nodes.get_or_none(uid=source_uid)
if p is None:
Expand All @@ -131,7 +131,7 @@ def update_source(source_uid: str):
abort(403, description="Not authorized to update source")

try:
p.from_dict(body.dict(), source_uid)
p.from_dict(body.model_dump(), source_uid)
p.refresh()
return p.to_json()
except Exception as e:
Expand Down Expand Up @@ -284,10 +284,10 @@ def add_member_to_source():
@bp.route("/join", methods=["POST"])
@jwt_required()
@min_role_required(UserRole.PUBLIC)
@validate_request(CreatePartner)
@validate_request(CreateSource)
def join_organization():
logger = logging.getLogger("join_organization")
body: CreatePartner = request.validated_body
body: CreateSource = request.validated_body
jwt_decoded = get_jwt()
current_user = User.get(jwt_decoded["sub"])
source = Source.nodes.get_or_none(uid=body["source_uid"])
Expand Down
133 changes: 0 additions & 133 deletions backend/routes/tmp/pydantic/agencies.py

This file was deleted.

8 changes: 0 additions & 8 deletions backend/routes/tmp/pydantic/common.py

This file was deleted.

Loading
Loading