Moving stuff around to make it more easy to manage. Adding models, methods, and routes.
This commit is contained in:
@@ -9,7 +9,8 @@ from app.db_sql import *
|
||||
|
||||
from app.routers.api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template
|
||||
|
||||
from app.methods.account_methods import load_account_obj, load_account_cfg_obj
|
||||
from app.methods.account_methods import load_account_obj
|
||||
from app.methods.account_cfg_methods import load_account_cfg_obj
|
||||
|
||||
from app.models.account_models import Account_Base
|
||||
from app.models.response_models import *
|
||||
@@ -91,17 +92,19 @@ async def get_account_obj_li(
|
||||
|
||||
|
||||
# ### BEGIN ### API Account ### get_account_obj() ###
|
||||
# Working well as of 2021-06-04. Using as a template for other routes.
|
||||
# Working well as of 2021-06-11. Using as a template for other routes.
|
||||
@router.get('/{account_id}', response_model=Resp_Body_Base)
|
||||
async def get_account_obj_new(
|
||||
account_id: str = Query(..., min_length=1, max_length=22),
|
||||
enabled: str = 'enabled', # For now this covers any included objects or object lists
|
||||
limit: int = 500, # For now this covers any included objects or object lists
|
||||
enabled: str = 'enabled', # For now this covers any included objects or object lists
|
||||
inc_account_cfg: bool = False, # Priority l1
|
||||
inc_address: bool = False, # Under contact
|
||||
inc_address_list: bool = False,
|
||||
inc_archive: bool = False,
|
||||
# inc_archive: bool = False,
|
||||
inc_archive_list: bool = False, # Priority l1
|
||||
# inc_archive_content: bool = False,
|
||||
inc_archive_content_list: bool = False, # Priority l2
|
||||
inc_contact: bool = False,
|
||||
inc_contact_list: bool = False,
|
||||
inc_event: bool = False,
|
||||
@@ -166,64 +169,67 @@ async def get_account_obj_new(
|
||||
else:
|
||||
return mk_resp(data=None, status_code=404)
|
||||
|
||||
if account_obj := load_account_obj(
|
||||
account_id=account_id,
|
||||
enabled=enabled,
|
||||
limit=limit,
|
||||
inc_address=inc_address,
|
||||
inc_address_list=inc_address_list,
|
||||
inc_archive=inc_archive,
|
||||
inc_archive_list=inc_archive_list,
|
||||
inc_contact=inc_contact,
|
||||
inc_contact_list=inc_contact_list,
|
||||
inc_event=inc_event,
|
||||
inc_event_list=inc_event_list,
|
||||
# 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_file_list=inc_event_file_list,
|
||||
# inc_event_location=inc_event_location,
|
||||
# inc_event_person=inc_event_person,
|
||||
inc_event_person_list=inc_event_person_list,
|
||||
inc_event_presentation_list=inc_event_presentation_list,
|
||||
# inc_event_presenter_cat=inc_event_presenter_cat,
|
||||
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=inc_event_track,
|
||||
inc_event_track_list=inc_event_track_list,
|
||||
inc_fundraising_cfg=inc_fundraising_cfg,
|
||||
inc_hosted_file_list=inc_hosted_file_list,
|
||||
inc_journal_list=inc_journal_list,
|
||||
# inc_membership=inc_membership,
|
||||
inc_membership_cfg=inc_membership_cfg,
|
||||
inc_membership_list=inc_membership_list,
|
||||
# inc_order=inc_order,
|
||||
inc_order_list=inc_order_list,
|
||||
# inc_order_cart=inc_order_cart,
|
||||
inc_order_cart_list=inc_order_cart_list,
|
||||
inc_organization=inc_organization,
|
||||
inc_organization_list=inc_organization_list,
|
||||
inc_person=inc_person,
|
||||
inc_person_list=inc_person_list,
|
||||
# inc_post=inc_post,
|
||||
inc_post_list=inc_post_list,
|
||||
# inc_product=inc_product,
|
||||
inc_product_list=inc_product_list,
|
||||
# inc_site=inc_site,
|
||||
inc_site_list=inc_site_list,
|
||||
inc_user=inc_user,
|
||||
inc_user_list=inc_user_list,
|
||||
if account_dict := load_account_obj(
|
||||
account_id = account_id,
|
||||
enabled = enabled,
|
||||
limit = limit,
|
||||
model_as_dict = True, # NOTE: returning model as a dict
|
||||
inc_account_cfg = inc_account_cfg,
|
||||
inc_address = inc_address,
|
||||
inc_address_list = inc_address_list,
|
||||
# inc_archive = inc_archive,
|
||||
inc_archive_list = inc_archive_list,
|
||||
# inc_archive_content = inc_archive_content,
|
||||
inc_archive_content_list = inc_archive_content_list,
|
||||
inc_contact = inc_contact,
|
||||
inc_contact_list = inc_contact_list,
|
||||
inc_event = inc_event,
|
||||
inc_event_list = inc_event_list,
|
||||
# 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_file_list = inc_event_file_list,
|
||||
# inc_event_location = inc_event_location,
|
||||
# inc_event_person = inc_event_person,
|
||||
inc_event_person_list = inc_event_person_list,
|
||||
inc_event_presentation_list = inc_event_presentation_list,
|
||||
# inc_event_presenter_cat = inc_event_presenter_cat,
|
||||
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 = inc_event_track,
|
||||
inc_event_track_list = inc_event_track_list,
|
||||
inc_fundraising_cfg = inc_fundraising_cfg,
|
||||
inc_hosted_file_list = inc_hosted_file_list,
|
||||
inc_journal_list = inc_journal_list,
|
||||
# inc_membership = inc_membership,
|
||||
inc_membership_cfg = inc_membership_cfg,
|
||||
inc_membership_list = inc_membership_list,
|
||||
# inc_order = inc_order,
|
||||
inc_order_list = inc_order_list,
|
||||
# inc_order_cart = inc_order_cart,
|
||||
inc_order_cart_list = inc_order_cart_list,
|
||||
inc_organization = inc_organization,
|
||||
inc_organization_list = inc_organization_list,
|
||||
inc_person = inc_person,
|
||||
inc_person_list = inc_person_list,
|
||||
# inc_post = inc_post,
|
||||
inc_post_list = inc_post_list,
|
||||
# inc_product = inc_product,
|
||||
inc_product_list = inc_product_list,
|
||||
# inc_site = inc_site,
|
||||
inc_site_list = inc_site_list,
|
||||
inc_user = inc_user,
|
||||
inc_user_list = inc_user_list,
|
||||
):
|
||||
if isinstance(account_obj, Account_Base):
|
||||
response_data = account_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
|
||||
if isinstance(account_dict, dict):
|
||||
response_data = account_dict
|
||||
else:
|
||||
response_data = account_obj
|
||||
response_data = account_dict
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400) # Bad Request
|
||||
|
||||
return mk_resp(data=response_data)
|
||||
#return mk_resp(data=account_obj)
|
||||
# ### END ### API Account ### get_account_obj() ###
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user