-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-0.2.0' into fix/prashanth-bug-chgng-user-name
- Loading branch information
Showing
17 changed files
with
398 additions
and
138 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
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 |
---|---|---|
@@ -1,17 +1,34 @@ | ||
from fastapi import Depends, Request | ||
from fastapi import Depends | ||
from fastapi.exceptions import RequestValidationError | ||
|
||
from lcfs.web.api.fuel_code.repo import FuelCodeRepository | ||
from lcfs.web.api.fuel_supply.repo import FuelSupplyRepository | ||
from lcfs.web.api.fuel_supply.schema import FuelSupplyCreateUpdateSchema | ||
|
||
|
||
class FuelSupplyValidation: | ||
def __init__( | ||
self, | ||
request: Request = None, | ||
fs_repo: FuelSupplyRepository = Depends(FuelSupplyRepository), | ||
fc_repo: FuelCodeRepository = Depends(FuelCodeRepository), | ||
): | ||
self.fs_repo = fs_repo | ||
self.request = request | ||
self.fc_repo = fc_repo | ||
|
||
async def check_duplicate(self, fuel_supply: FuelSupplyCreateUpdateSchema): | ||
return await self.fs_repo.check_duplicate(fuel_supply) | ||
|
||
async def validate_other(self, fuel_supply: FuelSupplyCreateUpdateSchema): | ||
fuel_type = await self.fc_repo.get_fuel_type_by_id(fuel_supply.fuel_type_id) | ||
|
||
if fuel_type.unrecognized: | ||
if not fuel_supply.fuel_type_other: | ||
raise RequestValidationError( | ||
[ | ||
{ | ||
"loc": ("fuelTypeOther",), | ||
"msg": "required when using Other", | ||
"type": "value_error", | ||
} | ||
] | ||
) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.