Working on membership management

This commit is contained in:
Scott Idem
2021-04-13 17:08:05 -04:00
parent 130b1953de
commit d412ddac0a
3 changed files with 57 additions and 13 deletions

View File

@@ -12,6 +12,7 @@ from app.db_sql import *
from .api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template
from ..models.account_model import Account_Base
from ..models.account_methods import load_account_cfg_obj
from ..models.response_model import *
@@ -126,23 +127,30 @@ async def delete_account_obj(
return result
@router.get('/{obj_id}/cfg', response_model=Resp_Body_Base)
@router.get('/{account_id}/cfg', response_model=Resp_Body_Base)
async def get_account_cfg_obj(
obj_id: str = Query(..., min_length=1, max_length=22),
account_id: str = Query(..., min_length=1, max_length=22),
sys_module: Optional[str] = None, # event, fundraising, membership
x_account_id: str = Header(...),
by_alias: Optional[bool] = True,
exclude_unset: Optional[bool] = True,
):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
obj_type = 'account_cfg'
result = get_obj_template(
obj_type=obj_type,
obj_id=obj_id,
by_alias=True,
exclude_unset=True,
)
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(result)
return result
if sys_module:
if sys_module == 'membership':
membership_cfg_obj = load_account_cfg_obj(account_id=account_id, inc_membership_cfg=True).dict(by_alias=by_alias, exclude_unset=exclude_unset)
data = membership_cfg_obj
return mk_resp(data=data)
else:
obj_type = 'account_cfg'
result = get_obj_template(
obj_type=obj_type,
obj_id=account_id,
by_alias=True,
exclude_unset=True,
)
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(result)
return result