Fix: Closing stock on update was not working as it was not able to encode/parse creation date and last edit date

This commit is contained in:
Amritanshu Agrawal 2021-11-02 11:57:06 +05:30
parent b69a38d8e9
commit b6ef6f79e5
2 changed files with 22 additions and 6 deletions

View File

@ -40,10 +40,26 @@ class ClosingStock(BaseModel):
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {date: lambda v: v.strftime("%d-%b-%Y")}
json_encoders = {date: lambda v: v.strftime("%d-%b-%Y"), datetime: lambda v: v.strftime("%d-%b-%Y %H:%M")}
@validator("date_", pre=True)
def parse_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@validator("creation_date", pre=True)
def parse_creation_date(cls, value):
if value is None:
return None
if isinstance(value, datetime):
return value
return datetime.strptime(value, "%d-%b-%Y %H:%M")
@validator("last_edit_date", pre=True)
def parse_last_edit_date(cls, value):
if value is None:
return None
if isinstance(value, datetime):
return value
return datetime.strptime(value, "%d-%b-%Y %H:%M")

View File

@ -7,15 +7,15 @@ cd "$parent_path" || exit
if [ 1 -eq "$#" ]
then
echo "Version bump to $1"
sed --in-place --regexp-extended 's/"([0-9].[0-9].[0-9])"/"'"$1"'"/g' brewman/brewman/__version__.py
sed --in-place --regexp-extended 's/"([0-9]*.[0-9].[0-9])"/"'"$1"'"/g' brewman/brewman/__version__.py
git add brewman/brewman/__version__.py
sed --in-place --regexp-extended 's/version = "([0-9].[0-9].[0-9])"/version = "'"$1"'"/g' brewman/pyproject.toml
sed --in-place --regexp-extended 's/version = "([0-9]*.[0-9].[0-9])"/version = "'"$1"'"/g' brewman/pyproject.toml
git add brewman/pyproject.toml
sed --in-place --regexp-extended 's/version: '\''([0-9].[0-9].[0-9])'\''/version: '\'"$1"\''/g' overlord/src/environments/environment.prod.ts
sed --in-place --regexp-extended 's/version: '\''([0-9]*.[0-9].[0-9])'\''/version: '\'"$1"\''/g' overlord/src/environments/environment.prod.ts
git add overlord/src/environments/environment.prod.ts
sed --in-place --regexp-extended 's/version: '\''([0-9].[0-9].[0-9])'\''/version: '\'"$1"\''/g' overlord/src/environments/environment.ts
sed --in-place --regexp-extended 's/version: '\''([0-9]*.[0-9].[0-9])'\''/version: '\'"$1"\''/g' overlord/src/environments/environment.ts
git add overlord/src/environments/environment.ts
sed --in-place --regexp-extended 's/"version": "([0-9].[0-9].[0-9])"/"version": "'"$1"'"/g' overlord/package.json
sed --in-place --regexp-extended 's/"version": "([0-9]*.[0-9].[0-9])"/"version": "'"$1"'"/g' overlord/package.json
git add overlord/package.json
git commit -m "Version Bump v$1"
git tag "v$1"