Bug fix for special characters in GET params because of % symbol

This commit is contained in:
Scott Idem
2021-08-11 17:41:34 -04:00
parent cfd85435f2
commit 616011edfe
4 changed files with 54 additions and 18 deletions

View File

@@ -19,6 +19,8 @@ def create_order_cart_line_obj(order_cart_line_obj_new:Order_Cart_Line_Base):
if not order_cart_line_obj_new:
return False
# Something needs to be added to lookup the current product information and copy that into the order_cart_line. Also knowing this will eventually be order_line.
order_cart_line_obj_data = order_cart_line_obj_new.dict(by_alias=False, exclude_defaults=False, exclude_unset=True, exclude={'user', 'created_on', 'updated_on'})
if order_cart_line_obj_in_result := sql_insert(data=order_cart_line_obj_data, table_name='order_cart_line', rm_id_random=True, id_random_length=8): pass

View File

@@ -147,6 +147,16 @@ class Order_Cart_Line_Base(BaseModel):
return redis_lookup_id_random(record_id_random=values['curr_product_for_id_random'], table_name=values['curr_product_for_type'])
return None
# This is not working yet. It should return the product_type_code somehow
# @validator('product_type_code', always=True)
# def product_type_code_lookup(cls, v, values, **kwargs):
# log.setLevel(logging.WARNING)
# log.debug(locals())
# if values.get('product_type_code', None):
# return function_that_looks_stuff_up()
# return None
class Config:
underscore_attrs_are_private = True
allow_population_by_field_name = True

View File

@@ -216,12 +216,12 @@ async def search_cont_edu_cert_person_obj_li(
data = {}
data['account_id_random'] = account_id
data['cont_edu_cert_id_list'] = cont_edu_cert_id_list
data['external_id'] = external_id
data['given_name'] = given_name
data['family_name'] = family_name
data['email'] = email
data['from_datetime'] = from_datetime
data['to_datetime'] = to_datetime
# data['external_id'] = external_id
# data['given_name'] = given_name
# data['family_name'] = family_name
data['email'] = '%'+email+'%'
# data['from_datetime'] = from_datetime
# data['to_datetime'] = to_datetime
log.debug(data)
if enabled in ['enabled', 'disabled', 'all']:

View File

@@ -80,8 +80,6 @@ async def lookup_site_domain_obj(
referrer: Optional[str] = None,
x_account_id: str = Header(...),
by_alias: bool = True,
#include: Optional[list] = [],
#exclude: Optional[list] = [],
exclude_unset: bool = True,
exclude_none: bool = True,
response: Response = Response,
@@ -115,6 +113,7 @@ async def lookup_site_domain_obj(
"""
log.debug(sql)
# NOTE: This need to broken out into a methods function for site and or site_domain
if site_domain_obj_result := sql_select(data=data, sql=sql):
try:
site_obj = Site_Base(**site_domain_obj_result).dict(by_alias=by_alias, exclude_unset=exclude_unset, exclude_none=exclude_none)
@@ -159,9 +158,9 @@ async def get_site_domain_obj_li(
return result
@router.get('/{obj_id}', response_model=Resp_Body_Base)
@router.get('/{site_domain_id}', response_model=Resp_Body_Base)
async def get_site_domain_obj(
obj_id: str = Query(..., min_length=1, max_length=22),
site_domain_id: str = Query(..., min_length=11, max_length=22),
x_account_id: str = Header(...),
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
@@ -171,14 +170,39 @@ async def get_site_domain_obj(
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
obj_type = 'site_domain'
result = get_obj_template(
obj_type=obj_type,
obj_id=obj_id,
by_alias=True,
exclude_unset=True,
)
return result
if site_domain_id := redis_lookup_id_random(record_id_random=site_domain_id, table_name='site_domain'): pass
else: return mk_resp(data=None, status_code=404, response=response)
data = { 'site_domain_id': site_domain_id }
sql = f"""
SELECT *, site_enable_from AS 'enable_from', site_enable_to AS 'enable_to'
FROM `v_site_domain` AS site_domain
WHERE site_domain.id = :site_domain_id
;
"""
log.debug(sql)
# NOTE: This need to broken out into a methods function for site and or site_domain
if site_domain_obj_result := sql_select(data=data, sql=sql):
try:
site_obj = Site_Base(**site_domain_obj_result).dict(by_alias=by_alias, exclude_unset=exclude_unset, exclude_none=exclude_none)
log.debug(site_obj)
except ValidationError as e:
log.error(e.json())
try:
site_domain_obj = Site_Domain_Base(**site_domain_obj_result).dict(by_alias=by_alias, exclude_unset=exclude_unset, exclude_none=exclude_none)
log.debug(site_domain_obj)
except ValidationError as e:
log.error(e.json())
site_domain_obj['site'] = site_obj
log.debug(site_domain_obj)
return mk_resp(data=site_domain_obj)
else:
log.debug(site_domain_obj_result)
return mk_resp(data=False, status_code=404, response=response)
@router.delete('/{obj_id}', response_model=Resp_Body_Base)