Fix: Regime was stripping the whitespaces from header

This commit is contained in:
Amritanshu Agrawal 2023-03-06 22:02:21 +05:30
parent 7d0874093c
commit 0f1660ef5a
3 changed files with 4 additions and 7 deletions

View File

@ -24,7 +24,7 @@ def save(
try: try:
with SessionFuture() as db: with SessionFuture() as db:
regime_id = db.execute(select(func.coalesce(func.max(Regime.id), 0) + 1)).scalar_one() regime_id = db.execute(select(func.coalesce(func.max(Regime.id), 0) + 1)).scalar_one()
item = Regime(id=regime_id, name=data.name, header=data.header, prefix=data.prefix) item = Regime(id=regime_id, name=data.name.strip(), header=data.header, prefix=data.prefix.strip())
db.add(item) db.add(item)
db.commit() db.commit()
return regime_info(item) return regime_info(item)
@ -49,9 +49,9 @@ def update_route(
status_code=status.HTTP_423_LOCKED, status_code=status.HTTP_423_LOCKED,
detail=f"{item.name} is a fixture and cannot be edited or deleted.", detail=f"{item.name} is a fixture and cannot be edited or deleted.",
) )
item.name = data.name item.name = data.name.strip()
item.header = data.header item.header = data.header
item.prefix = data.prefix item.prefix = data.prefix.strip()
db.commit() db.commit()
return regime_info(item) return regime_info(item)
except SQLAlchemyError as e: except SQLAlchemyError as e:

View File

@ -10,7 +10,6 @@ class RegimeIn(BaseModel):
is_fixture: bool is_fixture: bool
class Config: class Config:
anystr_strip_whitespace = True
alias_generator = to_camel alias_generator = to_camel
@ -18,7 +17,6 @@ class Regime(RegimeIn):
id_: int id_: int
class Config: class Config:
anystr_strip_whitespace = True
alias_generator = to_camel alias_generator = to_camel
@ -28,7 +26,6 @@ class RegimeBlank(RegimeIn):
prefix: str prefix: str
class Config: class Config:
anystr_strip_whitespace = True
alias_generator = to_camel alias_generator = to_camel

View File

@ -13,7 +13,7 @@
<div class="flex flex-row justify-around content-start items-start"> <div class="flex flex-row justify-around content-start items-start">
<mat-form-field class="flex-auto"> <mat-form-field class="flex-auto">
<mat-label>Header</mat-label> <mat-label>Header</mat-label>
<input matInput formControlName="header" /> <textarea matInput formControlName="header"></textarea>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="flex flex-row justify-around content-start items-start"> <div class="flex flex-row justify-around content-start items-start">