Moving things to use the common_route_params. Rewriting most of things order and order_cart related! Updating address and contact related. General code clean up.
This commit is contained in:
@@ -4,7 +4,7 @@ import datetime
|
||||
from typing import Dict, List, Optional, Set, Union
|
||||
from pydantic import BaseModel, EmailStr, Field, PrivateAttr, ValidationError, validator
|
||||
|
||||
from app.db_sql import redis_lookup_id_random, sql_insert, sql_select, sql_update
|
||||
from app.db_sql import redis_lookup_id_random, sql_delete, sql_enable_part, sql_insert, sql_limit_offset_part, sql_select, sql_update
|
||||
from app.lib_general import log, logging
|
||||
|
||||
|
||||
@@ -35,9 +35,11 @@ def create_order_line_obj(order_line_obj_new:Order_Line_Base):
|
||||
|
||||
|
||||
# ### BEGIN ### API Order Line Methods ### load_order_line_obj() ###
|
||||
# Updated 2021-11-19
|
||||
def load_order_line_obj(
|
||||
order_line_id: int|str,
|
||||
limit: int = 1000,
|
||||
# limit: int = 500,
|
||||
# offset: int = 0,
|
||||
by_alias: bool = True,
|
||||
exclude_unset: bool = True, # NOTE: Normally this is True
|
||||
model_as_dict: bool = False, # NOTE: Normally this is False
|
||||
@@ -50,16 +52,14 @@ def load_order_line_obj(
|
||||
|
||||
if order_line_rec := sql_select(table_name='v_order_line', record_id=order_line_id): pass
|
||||
else: return False
|
||||
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(order_line_rec)
|
||||
|
||||
try:
|
||||
order_line_obj = Order_Line_Base(**order_line_rec)
|
||||
log.debug(order_line_obj)
|
||||
except ValidationError as e:
|
||||
log.error(e.json())
|
||||
return False
|
||||
log.debug(order_line_obj)
|
||||
|
||||
if model_as_dict:
|
||||
return order_line_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
|
||||
@@ -72,6 +72,8 @@ def load_order_line_obj(
|
||||
# Updated 2021-11-22
|
||||
def load_order_line_obj_full_detail(
|
||||
order_line_rec: dict,
|
||||
# limit: int = 500,
|
||||
# offset: int = 0,
|
||||
by_alias: bool = True,
|
||||
exclude_unset: bool = True, # NOTE: Normally this is True
|
||||
model_as_dict: bool = False, # NOTE: Normally this is False
|
||||
@@ -166,7 +168,8 @@ def get_order_line_rec_list(
|
||||
status: str = 'closed', # started, in progress, complete, all
|
||||
full_detail: bool = False,
|
||||
# enabled: str = 'enabled', # enabled, disabled, all
|
||||
limit: int = 1000,
|
||||
limit: int = 500,
|
||||
offset: int = 0,
|
||||
) -> list|bool:
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
@@ -228,11 +231,8 @@ def get_order_line_rec_list(
|
||||
else:
|
||||
sql_from_to_datetime = ''
|
||||
|
||||
if limit:
|
||||
data['limit'] = limit
|
||||
sql_limit = f'LIMIT :limit'
|
||||
else:
|
||||
sql_limit = ''
|
||||
# sql_enabled, data['enable'] = sql_enable_part(table_name='order', enabled=enabled) # Reasonably safe return str and bool
|
||||
sql_limit = sql_limit_offset_part(limit=limit, offset=offset) # Reasonably safe return str
|
||||
|
||||
log.debug(data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user