Working on continuing education certs
This commit is contained in:
@@ -19,6 +19,7 @@ def load_cont_edu_cert_obj(
|
||||
exclude_unset: bool = True,
|
||||
model_as_dict: bool = False,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
inc_cont_edu_cert_person_list: bool = False,
|
||||
) -> Cont_Edu_Cert_Base|dict|bool:
|
||||
# log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
@@ -36,6 +37,30 @@ def load_cont_edu_cert_obj(
|
||||
log.error(e.json())
|
||||
return False
|
||||
|
||||
# Updated 2021-07-28
|
||||
if inc_cont_edu_cert_person_list:
|
||||
from app.methods.cont_edu_cert_person_methods import get_cont_edu_cert_person_rec_list, load_cont_edu_cert_person_obj
|
||||
if cont_edu_cert_person_rec_list_result := get_cont_edu_cert_person_rec_list(
|
||||
cont_edu_cert_id = cont_edu_cert_id,
|
||||
limit = limit,
|
||||
enabled = enabled,
|
||||
):
|
||||
cont_edu_cert_person_result_list = []
|
||||
for cont_edu_cert_person_rec in cont_edu_cert_person_rec_list_result:
|
||||
if load_cont_edu_cert_person_result := load_cont_edu_cert_person_obj(
|
||||
cont_edu_cert_person_id = cont_edu_cert_person_rec.get('cont_edu_cert_person_id', None),
|
||||
limit = limit,
|
||||
by_alias = by_alias,
|
||||
exclude_unset = exclude_unset,
|
||||
model_as_dict = model_as_dict,
|
||||
enabled = enabled,
|
||||
# inc_cont_edu_cert = inc_cont_edu_cert,
|
||||
):
|
||||
cont_edu_cert_person_result_list.append(load_cont_edu_cert_person_result)
|
||||
else: cont_edu_cert_person_result_list.append(None)
|
||||
cont_edu_cert_obj.cont_edu_cert_person_list = cont_edu_cert_person_result_list
|
||||
else: cont_edu_cert_obj.cont_edu_cert_person_list = []
|
||||
|
||||
if model_as_dict:
|
||||
return cont_edu_cert_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
|
||||
else:
|
||||
|
||||
@@ -62,7 +62,12 @@ def load_cont_edu_cert_person_obj(
|
||||
|
||||
# ### BEGIN ### API Cont Edu Cert Person Methods ### get_cont_edu_cert_person_rec_list() ###
|
||||
def get_cont_edu_cert_person_rec_list(
|
||||
cont_edu_cert_id: str,
|
||||
account_id: str = None,
|
||||
cont_edu_cert_id: str = None,
|
||||
given_name: str = None,
|
||||
family_name: str = None,
|
||||
from_datetime: Optional[datetime.datetime] = None, # based on created_on
|
||||
to_datetime: Optional[datetime.datetime] = None, # based on created_on
|
||||
limit: int = 1000,
|
||||
enabled: str = 'enabled', # enabled, disabled, all
|
||||
) -> list|bool:
|
||||
@@ -72,8 +77,13 @@ def get_cont_edu_cert_person_rec_list(
|
||||
if cont_edu_cert_id := redis_lookup_id_random(record_id_random=cont_edu_cert_id, table_name='cont_edu_cert'): pass
|
||||
else: return False
|
||||
data = {}
|
||||
data['cont_edu_cert_id'] = cont_edu_cert_id
|
||||
sql_cont_edu_cert_id = f'`tbl`.cont_edu_cert_id = :cont_edu_cert_id'
|
||||
if account_id:
|
||||
data['account_id'] = account_id
|
||||
sql_where_id = f'`tbl`.account_id = :account_id'
|
||||
elif cont_edu_cert_id:
|
||||
data['cont_edu_cert_id'] = cont_edu_cert_id
|
||||
sql_where_id = f'`tbl`.cont_edu_cert_id = :cont_edu_cert_id'
|
||||
else: return False
|
||||
|
||||
if enabled in ['enabled', 'disabled', 'all']:
|
||||
if enabled == 'enabled':
|
||||
@@ -86,6 +96,19 @@ def get_cont_edu_cert_person_rec_list(
|
||||
sql_enabled = ''
|
||||
# sql_enabled = ''
|
||||
|
||||
if from_datetime and to_datetime:
|
||||
data['from_datetime'] = from_datetime
|
||||
data['to_datetime'] = to_datetime
|
||||
sql_from_to_datetime = f'AND `tbl`.created_on >= :from_datetime AND `tbl`.created_on <= :to_datetime'
|
||||
elif from_datetime:
|
||||
data['from_datetime'] = from_datetime
|
||||
sql_from_to_datetime = f'AND `tbl`.created_on >= :from_datetime'
|
||||
elif to_datetime:
|
||||
data['to_datetime'] = to_datetime
|
||||
sql_from_to_datetime = f'AND `tbl`.created_on <= :to_datetime'
|
||||
else:
|
||||
sql_from_to_datetime = ''
|
||||
|
||||
if limit:
|
||||
data['limit'] = limit
|
||||
sql_limit = f'LIMIT :limit'
|
||||
@@ -96,8 +119,9 @@ def get_cont_edu_cert_person_rec_list(
|
||||
SELECT `tbl`.id AS 'cont_edu_cert_person_id', `tbl`.id_random AS 'cont_edu_cert_person_id_random'
|
||||
FROM `cont_edu_cert_person` AS `tbl`
|
||||
WHERE
|
||||
{sql_cont_edu_cert_id}
|
||||
{sql_where_id}
|
||||
{sql_enabled}
|
||||
{sql_from_to_datetime}
|
||||
ORDER BY `tbl`.created_on DESC, `tbl`.updated_on DESC
|
||||
{sql_limit};
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user