Feature: Added the customer module to list / edit customers. This is needed to add the customer discount functionality

This commit is contained in:
2021-04-02 06:34:31 +05:30
parent 214c40fbde
commit 0da16e9548
24 changed files with 560 additions and 7 deletions

View File

@ -93,11 +93,11 @@ def delete(
raise
@router.get("", response_model=schemas.CustomerIn)
@router.get("", response_model=schemas.CustomerBlank)
def show_blank(
db: Session = Depends(get_db),
user: UserToken = Security(get_user, scopes=["customers"]),
) -> schemas.CustomerIn:
) -> schemas.CustomerBlank:
return blank_customer_info()
@ -137,5 +137,5 @@ def customer_info(item: Customer) -> schemas.Customer:
)
def blank_customer_info() -> schemas.CustomerIn:
return schemas.CustomerIn(name="", address="", phone="")
def blank_customer_info() -> schemas.CustomerBlank:
return schemas.CustomerBlank(name="", address="", phone="")

View File

@ -9,11 +9,11 @@ from . import to_camel
class CustomerIn(BaseModel):
name: str = Field(..., min_length=1)
phone: str = Field(..., min_length=1)
# phone: str = Field(..., min_length=1)
phone: str
address: Optional[str]
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
@ -33,4 +33,11 @@ class CustomerLink(BaseModel):
class Config:
fields = {"id_": "id"}
class CustomerBlank(CustomerIn):
name: str
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel