Working on all module routes, methods, and models
This commit is contained in:
@@ -9,8 +9,9 @@ from app.lib_general import log, logging
|
||||
|
||||
from app.methods.address_methods import load_address_obj
|
||||
from app.methods.contact_methods import create_contact_obj, load_contact_obj, update_contact_obj
|
||||
from app.methods.order_methods import load_order_obj, get_order_rec_list
|
||||
from app.methods.organization_methods import load_organization_obj, update_organization_obj
|
||||
from app.methods.user_methods import create_user_obj, load_user_obj, update_user_obj
|
||||
# from app.methods.user_methods import create_user_obj, load_user_obj, update_user_obj
|
||||
|
||||
from app.models.person_models import Person_Base
|
||||
|
||||
@@ -69,7 +70,17 @@ def load_person_obj(
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
inc_address: bool = False, # Under contact
|
||||
inc_contact: bool = False,
|
||||
inc_event_list: bool = False,
|
||||
inc_journal_list: bool = False,
|
||||
inc_journal_entry_list: bool = False,
|
||||
inc_membership_member: bool = False,
|
||||
inc_order_cfg: bool = False,
|
||||
inc_order_line_list: bool = False,
|
||||
inc_order_list: bool = False,
|
||||
inc_order_cart_list: bool = False,
|
||||
inc_organization: bool = False,
|
||||
inc_post_list: bool = False,
|
||||
inc_post_comment_list: bool = False,
|
||||
inc_user: bool = False,
|
||||
) -> Person_Base|bool:
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
@@ -103,6 +114,32 @@ def load_person_obj(
|
||||
person_obj.contact = contact_result
|
||||
else: person_obj.contact = None
|
||||
|
||||
# Updated 2021-06-18
|
||||
if inc_order_list:
|
||||
if order_rec_list_result := get_order_rec_list(
|
||||
for_obj_type = 'person',
|
||||
for_obj_id = person_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
order_result_list = []
|
||||
for order_rec in order_rec_list_result:
|
||||
order_result_list.append(
|
||||
load_order_obj(
|
||||
order_id = order_rec.get('order_id', None),
|
||||
limit = limit,
|
||||
by_alias = by_alias,
|
||||
exclude_unset = exclude_unset,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
inc_order_cfg = inc_order_cfg,
|
||||
inc_order_line_list = inc_order_line_list,
|
||||
inc_user = inc_user,
|
||||
)
|
||||
)
|
||||
person_obj.order_list = order_result_list
|
||||
else: person_obj.order_list = []
|
||||
|
||||
# Updated 2021-06-18
|
||||
if inc_organization:
|
||||
organization_id = person_rec.get('organization_id', None)
|
||||
@@ -122,18 +159,19 @@ def load_person_obj(
|
||||
|
||||
# Updated 2021-06-18
|
||||
if inc_user:
|
||||
user_id = person_rec.get('user_id', None)
|
||||
log.debug(user_id)
|
||||
if user_result := load_user_obj(
|
||||
user_id = user_id,
|
||||
limit = limit,
|
||||
by_alias = by_alias,
|
||||
exclude_unset = exclude_unset,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
):
|
||||
person_obj.user = user_result
|
||||
else: person_obj.user = None
|
||||
# user_id = person_rec.get('user_id', None)
|
||||
# log.debug(user_id)
|
||||
# if user_result := load_user_obj(
|
||||
# user_id = user_id,
|
||||
# limit = limit,
|
||||
# by_alias = by_alias,
|
||||
# exclude_unset = exclude_unset,
|
||||
# model_as_dict = model_as_dict,
|
||||
# enabled = enabled,
|
||||
# ):
|
||||
# person_obj.user = user_result
|
||||
# else: person_obj.user = None
|
||||
pass
|
||||
|
||||
if model_as_dict:
|
||||
return person_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
|
||||
@@ -167,9 +205,9 @@ def update_person_obj(
|
||||
log.debug(contact_id)
|
||||
log.debug(contact_obj_up)
|
||||
if contact_obj_up_result := update_contact_obj(
|
||||
contact_id=contact_id,
|
||||
contact_obj_up=contact_obj_up,
|
||||
create_missing_obj=create_missing_obj,
|
||||
contact_id = contact_id,
|
||||
contact_obj_up = contact_obj_up,
|
||||
create_missing_obj = create_missing_obj,
|
||||
):
|
||||
log.debug(contact_obj_up_result)
|
||||
else:
|
||||
@@ -194,9 +232,9 @@ def update_person_obj(
|
||||
log.debug(organization_id)
|
||||
log.debug(organization_obj_up)
|
||||
if organization_obj_up_result := update_organization_obj(
|
||||
organization_id=organization_id,
|
||||
organization_obj_up=organization_obj_up,
|
||||
create_missing_obj=create_missing_obj,
|
||||
organization_id = organization_id,
|
||||
organization_obj_up = organization_obj_up,
|
||||
create_missing_obj = create_missing_obj,
|
||||
):
|
||||
log.debug(organization_obj_up_result)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user