Work on lots of methods and models.
This commit is contained in:
@@ -8,11 +8,15 @@ from app.db_sql import redis_lookup_id_random, sql_select
|
||||
from app.lib_general import log, logging
|
||||
|
||||
from app.methods.account_cfg_methods import load_account_cfg_obj
|
||||
# from app.methods.address_methods import load_address_obj_list
|
||||
from app.methods.archive_methods import load_archive_obj_list
|
||||
from app.methods.address_methods import get_address_rec_list, load_address_obj
|
||||
from app.methods.archive_methods import get_archive_rec_list, load_archive_obj
|
||||
# from app.methods.contact_methods import load_contact_obj_list
|
||||
from app.methods.event_methods import load_event_obj_list
|
||||
from app.methods.organization_methods import get_organization_rec_list, load_organization_obj
|
||||
from app.methods.person_methods import get_person_rec_list, load_person_obj
|
||||
from app.methods.product_methods import get_product_rec_list, load_product_obj
|
||||
from app.methods.post_methods import load_post_obj_list
|
||||
from app.methods.user_methods import get_user_rec_list, load_user_obj
|
||||
|
||||
from app.models.account_models import Account_Base
|
||||
from app.models.account_cfg_models import Account_Cfg_Base
|
||||
@@ -90,6 +94,7 @@ def load_account_obj(
|
||||
inc_site_list: bool = False, # Priority l3
|
||||
inc_user: bool = False,
|
||||
inc_user_list: bool = False, # Priority l2
|
||||
inc_user_role_list: bool = False,
|
||||
) -> Account_Base|dict|bool:
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
@@ -120,24 +125,68 @@ def load_account_obj(
|
||||
account_obj.account_cfg = account_cfg_dict
|
||||
else: account_obj.account_cfg = None
|
||||
|
||||
# if inc_address_list:
|
||||
# if address_dict_list := load_address_obj_list(
|
||||
# account_id = account_id,
|
||||
# limit = limit,
|
||||
# model_as_dict = model_as_dict,
|
||||
# enabled = enabled,
|
||||
# ):
|
||||
# account_obj.address_list = address_dict_list
|
||||
# else: account_obj.address_list = []
|
||||
|
||||
# Updated 2021-06-17
|
||||
if inc_address_list:
|
||||
if address_dict_list := load_address_obj_list(
|
||||
account_id = account_id,
|
||||
limit = limit,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
):
|
||||
if address_rec_list_result := get_address_rec_list(
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = account_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
address_dict_list = []
|
||||
for address_rec in address_rec_list_result:
|
||||
address_dict_list.append(
|
||||
load_address_obj(
|
||||
address_id = address_rec.get('address_id', None),
|
||||
limit = limit,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
inc_address_content_list = inc_address_content_list,
|
||||
)
|
||||
)
|
||||
account_obj.address_list = address_dict_list
|
||||
else: account_obj.address_list = []
|
||||
|
||||
# if inc_archive_list:
|
||||
# if archive_dict_list := load_archive_obj_list(
|
||||
# account_id = account_id,
|
||||
# limit = limit,
|
||||
# model_as_dict = model_as_dict,
|
||||
# enabled = enabled,
|
||||
# inc_archive_content_list = inc_archive_content_list,
|
||||
# ):
|
||||
# account_obj.archive_list = archive_dict_list
|
||||
# else: account_obj.archive_list = []
|
||||
|
||||
# Updated 2021-06-17
|
||||
if inc_archive_list:
|
||||
if archive_dict_list := load_archive_obj_list(
|
||||
account_id = account_id,
|
||||
limit = limit,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
inc_archive_content_list = inc_archive_content_list,
|
||||
):
|
||||
if archive_rec_list_result := get_archive_rec_list(
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = account_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
archive_dict_list = []
|
||||
for archive_rec in archive_rec_list_result:
|
||||
archive_dict_list.append(
|
||||
load_archive_obj(
|
||||
archive_id = archive_rec.get('archive_id', None),
|
||||
limit = limit,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
inc_archive_content_list = inc_archive_content_list,
|
||||
)
|
||||
)
|
||||
account_obj.archive_list = archive_dict_list
|
||||
else: account_obj.archive_list = []
|
||||
|
||||
@@ -162,34 +211,100 @@ def load_account_obj(
|
||||
# account_obj.organization = organization_obj
|
||||
# else: account_obj.organization = None
|
||||
|
||||
|
||||
# Updated 2021-06-17
|
||||
if inc_event_list:
|
||||
if event_dict_list := load_event_obj_list(
|
||||
account_id = account_id,
|
||||
limit = limit,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
# inc_location_address = inc_address,
|
||||
# inc_contact_1 = inc_contact,
|
||||
# inc_contact_2 = inc_contact,
|
||||
# inc_contact_3 = inc_contact,
|
||||
# inc_event_abstract_list = inc_event_abstract_list,
|
||||
# inc_event_badge_list = inc_event_badge_list,
|
||||
# inc_event_device_list = inc_event_device_list,
|
||||
inc_event_exhibit_list = inc_event_exhibit_list,
|
||||
inc_event_file_list = inc_event_file_list,
|
||||
inc_event_location_list = inc_event_location_list,
|
||||
inc_event_person_list = inc_event_person_list,
|
||||
inc_event_presentation_list = inc_event_presentation_list,
|
||||
inc_event_presenter_list = inc_event_presenter_list,
|
||||
inc_event_registration_list = inc_event_registration_list,
|
||||
inc_event_session_list = inc_event_session_list,
|
||||
inc_event_track_list = inc_event_track_list,
|
||||
# inc_person = inc_person,
|
||||
# inc_user = inc_user,
|
||||
):
|
||||
if event_rec_list_result := get_event_rec_list(
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = account_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
event_dict_list = []
|
||||
for event_rec in event_rec_list_result:
|
||||
event_dict_list.append(
|
||||
load_event_obj(
|
||||
event_id = event_rec.get('event_id', None),
|
||||
limit = limit,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
# inc_location_address = inc_address,
|
||||
# inc_contact_1 = inc_contact,
|
||||
# inc_contact_2 = inc_contact,
|
||||
# inc_contact_3 = inc_contact,
|
||||
# inc_event_abstract_list = inc_event_abstract_list,
|
||||
# inc_event_badge_list = inc_event_badge_list,
|
||||
# inc_event_device_list = inc_event_device_list,
|
||||
inc_event_exhibit_list = inc_event_exhibit_list,
|
||||
inc_event_file_list = inc_event_file_list,
|
||||
inc_event_location_list = inc_event_location_list,
|
||||
inc_event_person_list = inc_event_person_list,
|
||||
inc_event_presentation_list = inc_event_presentation_list,
|
||||
inc_event_presenter_list = inc_event_presenter_list,
|
||||
inc_event_registration_list = inc_event_registration_list,
|
||||
inc_event_session_list = inc_event_session_list,
|
||||
inc_event_track_list = inc_event_track_list,
|
||||
# inc_person = inc_person,
|
||||
# inc_user = inc_user,
|
||||
)
|
||||
)
|
||||
account_obj.event_list = event_dict_list
|
||||
else: account_obj.event_list = []
|
||||
|
||||
# if inc_event_list:
|
||||
# if event_dict_list := load_event_obj_list(
|
||||
# account_id = account_id,
|
||||
# limit = limit,
|
||||
# model_as_dict = model_as_dict,
|
||||
# enabled = enabled,
|
||||
# # inc_location_address = inc_address,
|
||||
# # inc_contact_1 = inc_contact,
|
||||
# # inc_contact_2 = inc_contact,
|
||||
# # inc_contact_3 = inc_contact,
|
||||
# # inc_event_abstract_list = inc_event_abstract_list,
|
||||
# # inc_event_badge_list = inc_event_badge_list,
|
||||
# # inc_event_device_list = inc_event_device_list,
|
||||
# inc_event_exhibit_list = inc_event_exhibit_list,
|
||||
# inc_event_file_list = inc_event_file_list,
|
||||
# inc_event_location_list = inc_event_location_list,
|
||||
# inc_event_person_list = inc_event_person_list,
|
||||
# inc_event_presentation_list = inc_event_presentation_list,
|
||||
# inc_event_presenter_list = inc_event_presenter_list,
|
||||
# inc_event_registration_list = inc_event_registration_list,
|
||||
# inc_event_session_list = inc_event_session_list,
|
||||
# inc_event_track_list = inc_event_track_list,
|
||||
# # inc_person = inc_person,
|
||||
# # inc_user = inc_user,
|
||||
# ):
|
||||
# account_obj.event_list = event_dict_list
|
||||
# else: account_obj.event_list = []
|
||||
|
||||
# Updated 2021-06-17
|
||||
if inc_organization_list:
|
||||
if organization_rec_list_result := get_organization_rec_list(
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = account_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
organization_dict_list = []
|
||||
for organization_rec in organization_rec_list_result:
|
||||
organization_dict_list.append(
|
||||
load_organization_obj(
|
||||
organization_id = organization_rec.get('organization_id', None),
|
||||
limit = limit,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
inc_address = inc_address,
|
||||
inc_contact = inc_contact,
|
||||
inc_person = inc_person,
|
||||
inc_user = inc_user,
|
||||
)
|
||||
)
|
||||
account_obj.organization_list = organization_dict_list
|
||||
else: account_obj.organization_list = []
|
||||
|
||||
|
||||
if inc_post_list:
|
||||
if post_dict_list := load_post_obj_list(
|
||||
account_id = account_id,
|
||||
@@ -203,6 +318,83 @@ def load_account_obj(
|
||||
account_obj.post_list = post_dict_list
|
||||
else: account_obj.post_list = []
|
||||
|
||||
# Updated 2021-06-17
|
||||
if inc_person_list:
|
||||
if person_rec_list_result := get_person_rec_list(
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = account_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
person_dict_list = []
|
||||
for person_rec in person_rec_list_result:
|
||||
person_dict_list.append(
|
||||
load_person_obj(
|
||||
person_id = person_rec.get('person_id', None),
|
||||
limit = limit,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
inc_address = inc_address,
|
||||
inc_contact = inc_contact,
|
||||
inc_organization = inc_organization,
|
||||
inc_user = inc_user,
|
||||
)
|
||||
)
|
||||
account_obj.person_list = person_dict_list
|
||||
else: account_obj.person_list = []
|
||||
|
||||
# Updated 2021-06-17
|
||||
if inc_product_list:
|
||||
if product_rec_list_result := get_product_rec_list(
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = account_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
product_dict_list = []
|
||||
for product_rec in product_rec_list_result:
|
||||
product_dict_list.append(
|
||||
load_product_obj(
|
||||
product_id = product_rec.get('product_id', None),
|
||||
model_as_dict = model_as_dict,
|
||||
)
|
||||
)
|
||||
account_obj.product_list = product_dict_list
|
||||
else: account_obj.product_list = []
|
||||
|
||||
# Updated 2021-06-17
|
||||
if inc_user_list:
|
||||
if user_rec_list_result := get_user_rec_list(
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = account_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
user_dict_list = []
|
||||
for user_rec in user_rec_list_result:
|
||||
user_dict_list.append(
|
||||
load_user_obj(
|
||||
user_id = user_rec.get('user_id', None),
|
||||
limit = limit,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
inc_address = inc_address,
|
||||
inc_contact = inc_contact,
|
||||
inc_event_list = inc_event_list,
|
||||
inc_journal_list = inc_journal_list,
|
||||
inc_membership_member = inc_membership_member,
|
||||
inc_order_list = inc_order_list,
|
||||
inc_order_cart_list = inc_order_cart_list,
|
||||
inc_organization = inc_organization,
|
||||
inc_person = inc_person,
|
||||
inc_post_list = inc_post_list,
|
||||
inc_post_comment_list = inc_post_comment_list,
|
||||
inc_user_role_list = inc_user_role_list,
|
||||
)
|
||||
)
|
||||
account_obj.user_list = user_dict_list
|
||||
else: account_obj.user_list = []
|
||||
|
||||
if model_as_dict:
|
||||
return account_obj.dict(by_alias=True, exclude_unset=True) # pylint: disable=no-member
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user