Working on continuing education certs

This commit is contained in:
Scott Idem
2021-07-28 14:13:51 -04:00
parent e43cf35ec4
commit 5e73c588a4
7 changed files with 197 additions and 11 deletions

View File

@@ -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};
"""