Working on all the routes, methods, and models.
This commit is contained in:
@@ -12,12 +12,15 @@ 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 get_contact_rec_list, load_contact_obj
|
||||
from app.methods.event_methods import get_event_rec_list, load_event_obj
|
||||
from app.methods.hosted_file_methods import get_hosted_file_rec_list, load_hosted_file_obj
|
||||
from app.methods.journal_methods import get_journal_rec_list, load_journal_obj
|
||||
from app.methods.order_methods import get_order_rec_list, load_order_obj
|
||||
# from app.methods.order_cart_methods import get_order_cart_rec_list, load_order_cart_obj
|
||||
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 get_post_rec_list, load_post_obj
|
||||
from app.methods.site_methods import get_site_rec_list, load_site_obj
|
||||
from app.methods.user_methods import get_user_rec_list, load_user_obj
|
||||
|
||||
from app.models.account_models import Account_Base
|
||||
@@ -30,6 +33,8 @@ from app.models.account_cfg_models import Account_Cfg_Base
|
||||
def load_account_obj(
|
||||
account_id: int|str,
|
||||
limit: int = 1000,
|
||||
by_alias: bool = True,
|
||||
exclude_unset: bool = True,
|
||||
model_as_dict: bool = False,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
inc_account_cfg: bool = False, # Priority l1
|
||||
@@ -72,7 +77,9 @@ def load_account_obj(
|
||||
inc_event_track_list: bool = False,
|
||||
inc_fundraising_cfg: bool = False,
|
||||
inc_hosted_file_list: bool = False,
|
||||
inc_hosted_file_link_list: bool = False,
|
||||
inc_journal_list: bool = False, # Priority l3
|
||||
inc_journal_entry_list: bool = False, # Priority l3
|
||||
# inc_membership: bool = False,
|
||||
inc_membership_cfg: bool = False,
|
||||
inc_membership_list: bool = False,
|
||||
@@ -99,6 +106,7 @@ def load_account_obj(
|
||||
inc_product_list: bool = False, # Priority l3
|
||||
# inc_site: bool = False,
|
||||
inc_site_list: bool = False, # Priority l3
|
||||
inc_site_domain_list: bool = False, # Priority l3
|
||||
inc_user: bool = False,
|
||||
inc_user_list: bool = False, # Priority l2
|
||||
inc_user_role_list: bool = False,
|
||||
@@ -109,7 +117,7 @@ def load_account_obj(
|
||||
if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
else: return False
|
||||
|
||||
if account_rec := sql_select(table_name='account', record_id=account_id): pass
|
||||
if account_rec := sql_select(table_name='v_account', record_id=account_id): pass
|
||||
else: return False
|
||||
|
||||
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
@@ -236,7 +244,7 @@ def load_account_obj(
|
||||
account_obj.event_list = event_dict_list
|
||||
else: account_obj.event_list = []
|
||||
|
||||
# Updated 2021-06-17
|
||||
# Updated 2021-06-18
|
||||
if inc_hosted_file_list:
|
||||
if hosted_file_rec_list_result := get_hosted_file_rec_list(
|
||||
for_obj_type = 'account',
|
||||
@@ -252,12 +260,38 @@ def load_account_obj(
|
||||
limit = limit,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
inc_hosted_file_link_list = inc_hosted_file_line_list,
|
||||
inc_hosted_file_link_list = inc_hosted_file_link_list,
|
||||
)
|
||||
)
|
||||
account_obj.hosted_file_list = hosted_file_dict_list
|
||||
else: account_obj.hosted_file_list = []
|
||||
|
||||
# Updated 2021-06-18
|
||||
if inc_journal_list:
|
||||
if journal_rec_list_result := get_journal_rec_list(
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = account_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
journal_dict_list = []
|
||||
for journal_rec in journal_rec_list_result:
|
||||
journal_dict_list.append(
|
||||
load_journal_obj(
|
||||
journal_id = journal_rec.get('journal_id', None),
|
||||
limit = limit,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
inc_journal_entry_list = inc_journal_entry_list,
|
||||
)
|
||||
)
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(journal_dict_list)
|
||||
|
||||
|
||||
account_obj.journal_list = journal_dict_list
|
||||
else: account_obj.journal_list = []
|
||||
|
||||
# Updated 2021-06-17
|
||||
if inc_order_list:
|
||||
if order_rec_list_result := get_order_rec_list(
|
||||
@@ -376,6 +410,28 @@ def load_account_obj(
|
||||
account_obj.product_list = product_dict_list
|
||||
else: account_obj.product_list = []
|
||||
|
||||
# Updated 2021-06-17
|
||||
if inc_site_list:
|
||||
if site_rec_list_result := get_site_rec_list(
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = account_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
site_result_list = []
|
||||
for site_rec in site_rec_list_result:
|
||||
site_result_list.append(
|
||||
load_site_obj(
|
||||
site_id = site_rec.get('site_id', None),
|
||||
by_alias = by_alias,
|
||||
exclude_unset = exclude_unset,
|
||||
model_as_dict = model_as_dict,
|
||||
inc_site_domain_list = inc_site_domain_list,
|
||||
)
|
||||
)
|
||||
account_obj.site_list = site_result_list
|
||||
else: account_obj.site_list = []
|
||||
|
||||
# Updated 2021-06-17
|
||||
if inc_user_list:
|
||||
if user_rec_list_result := get_user_rec_list(
|
||||
@@ -410,7 +466,7 @@ def load_account_obj(
|
||||
else: account_obj.user_list = []
|
||||
|
||||
if model_as_dict:
|
||||
return account_obj.dict(by_alias=True, exclude_unset=True) # pylint: disable=no-member
|
||||
return account_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
|
||||
else:
|
||||
return account_obj
|
||||
# ### END ### API Account Methods ### load_account_obj() ###
|
||||
|
||||
Reference in New Issue
Block a user