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.contact_methods import load_contact_obj, update_contact_obj
|
||||
# from app.methods.event_methods import get_event_rec_list
|
||||
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.person_methods import load_person_obj, update_person_obj
|
||||
from app.methods.person_methods import load_person_obj, update_person_obj
|
||||
from app.methods.post_methods import get_post_rec_list, load_post_obj
|
||||
|
||||
from app.models.user_models import User_Base, User_New_Base, User_Out_Base
|
||||
@@ -80,14 +81,20 @@ def load_user_obj(
|
||||
model_as_dict: bool = False,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
inc_address: bool = False,
|
||||
# inc_archive_list: bool = False,
|
||||
inc_contact: bool = False,
|
||||
inc_event_list: bool = False,
|
||||
# inc_hosted_file_list: bool = False,
|
||||
inc_journal_list: bool = False,
|
||||
inc_membership: 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_person: bool = False,
|
||||
# inc_person_list: bool = False,
|
||||
inc_post_list: bool = False,
|
||||
inc_post_comment_list: bool = False,
|
||||
inc_user_role_list: bool = False,
|
||||
@@ -112,20 +119,20 @@ def load_user_obj(
|
||||
return False
|
||||
|
||||
# Updated 2021-06-18
|
||||
if inc_contact:
|
||||
contact_id = user_rec.get('contact_id', None)
|
||||
log.debug(contact_id)
|
||||
if contact_result := load_contact_obj(
|
||||
contact_id = contact_id,
|
||||
limit = limit,
|
||||
by_alias = by_alias,
|
||||
exclude_unset = exclude_unset,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
inc_address = inc_address,
|
||||
):
|
||||
user_obj.contact = contact_result
|
||||
else: user_obj.contact = None
|
||||
# if inc_contact:
|
||||
# contact_id = user_rec.get('contact_id', None)
|
||||
# log.debug(contact_id)
|
||||
# if contact_result := load_contact_obj(
|
||||
# contact_id = contact_id,
|
||||
# limit = limit,
|
||||
# by_alias = by_alias,
|
||||
# exclude_unset = exclude_unset,
|
||||
# model_as_dict = model_as_dict,
|
||||
# enabled = enabled,
|
||||
# inc_address = inc_address,
|
||||
# ):
|
||||
# user_obj.contact = contact_result
|
||||
# else: user_obj.contact = None
|
||||
|
||||
if inc_event_list:
|
||||
from app.methods.event_methods import load_event_obj_list
|
||||
@@ -138,6 +145,33 @@ def load_user_obj(
|
||||
user_obj.event_list = event_dict_list
|
||||
else: user_obj.event_list = []
|
||||
|
||||
# Updated 2021-06-18
|
||||
if inc_order_list:
|
||||
if order_rec_list_result := get_order_rec_list(
|
||||
for_obj_type = 'user',
|
||||
for_obj_id = user_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_person = inc_person,
|
||||
# inc_user = inc_user,
|
||||
)
|
||||
)
|
||||
user_obj.order_list = order_result_list
|
||||
else: user_obj.order_list = []
|
||||
|
||||
# Updated 2021-06-18
|
||||
if inc_organization:
|
||||
organization_id = user_rec.get('organization_id', None)
|
||||
@@ -166,8 +200,7 @@ def load_user_obj(
|
||||
model_as_dict = model_as_dict,
|
||||
inc_address = inc_address,
|
||||
inc_contact = inc_contact,
|
||||
# inc_organization = inc_organization,
|
||||
# inc_user = inc_user,
|
||||
inc_organization = inc_organization,
|
||||
):
|
||||
user_obj.person = person_result
|
||||
else: user_obj.person = None
|
||||
|
||||
Reference in New Issue
Block a user