models: add default_qry_str to event, session, presenter models
This commit is contained in:
@@ -59,7 +59,7 @@ class Event_Base(BaseModel):
|
|||||||
if rid and isinstance(rid, str):
|
if rid and isinstance(rid, str):
|
||||||
values['id'] = rid
|
values['id'] = rid
|
||||||
values['event_id'] = rid
|
values['event_id'] = rid
|
||||||
|
|
||||||
if a_rid := values.get('account_id_random'): values['account_id'] = a_rid
|
if a_rid := values.get('account_id_random'): values['account_id'] = a_rid
|
||||||
if pep_rid := values.get('poc_event_person_id_random'): values['poc_event_person_id'] = pep_rid
|
if pep_rid := values.get('poc_event_person_id_random'): values['poc_event_person_id'] = pep_rid
|
||||||
if pp_rid := values.get('poc_person_id_random'): values['poc_person_id'] = pp_rid
|
if pp_rid := values.get('poc_person_id_random'): values['poc_person_id'] = pp_rid
|
||||||
@@ -68,7 +68,7 @@ class Event_Base(BaseModel):
|
|||||||
if c1_rid := values.get('contact_1_id_random'): values['contact_1_id'] = c1_rid
|
if c1_rid := values.get('contact_1_id_random'): values['contact_1_id'] = c1_rid
|
||||||
if c2_rid := values.get('contact_2_id_random'): values['contact_2_id'] = c2_rid
|
if c2_rid := values.get('contact_2_id_random'): values['contact_2_id'] = c2_rid
|
||||||
if c3_rid := values.get('contact_3_id_random'): values['contact_3_id'] = c3_rid
|
if c3_rid := values.get('contact_3_id_random'): values['contact_3_id'] = c3_rid
|
||||||
|
|
||||||
# 2. Prevent "Collision Population" or leakage of integers during API responses
|
# 2. Prevent "Collision Population" or leakage of integers during API responses
|
||||||
# WE MUST NOT DELETE these if they are already integers during a POST operation
|
# WE MUST NOT DELETE these if they are already integers during a POST operation
|
||||||
# as they have been resolved by sanitize_payload.
|
# as they have been resolved by sanitize_payload.
|
||||||
@@ -77,7 +77,7 @@ class Event_Base(BaseModel):
|
|||||||
if val is not None and not isinstance(val, str):
|
if val is not None and not isinstance(val, str):
|
||||||
if values.get(f'{k}_random') or (k=='id' and values.get('id_random')):
|
if values.get(f'{k}_random') or (k=='id' and values.get('id_random')):
|
||||||
del values[k]
|
del values[k]
|
||||||
|
|
||||||
return values
|
return values
|
||||||
|
|
||||||
code: Optional[str] = Field(
|
code: Optional[str] = Field(
|
||||||
@@ -171,6 +171,7 @@ class Event_Base(BaseModel):
|
|||||||
|
|
||||||
cfg_json: Optional[Union[Json, None]] # Store per event config options; Not currently used 2024-06-11
|
cfg_json: Optional[Union[Json, None]] # Store per event config options; Not currently used 2024-06-11
|
||||||
data_json: Optional[Union[Json, None]] # For key value data. Careful with overwriting existing fields! Not currently used 2024-06-11
|
data_json: Optional[Union[Json, None]] # For key value data. Careful with overwriting existing fields! Not currently used 2024-06-11
|
||||||
|
default_qry_str: Optional[str] # Default query string used for searching and filtering events. Updated using SQL triggers and a SQL function
|
||||||
|
|
||||||
enable: Optional[bool] # Also in Event_Cfg_Base model
|
enable: Optional[bool] # Also in Event_Cfg_Base model
|
||||||
enable_from: Optional[datetime.datetime] = None
|
enable_from: Optional[datetime.datetime] = None
|
||||||
@@ -288,7 +289,7 @@ class Event_Meeting_Flat_Base(BaseModel):
|
|||||||
if rid and isinstance(rid, str):
|
if rid and isinstance(rid, str):
|
||||||
values['id'] = rid
|
values['id'] = rid
|
||||||
values['event_id'] = rid
|
values['event_id'] = rid
|
||||||
|
|
||||||
if a_rid := values.get('account_id_random'): values['account_id'] = a_rid
|
if a_rid := values.get('account_id_random'): values['account_id'] = a_rid
|
||||||
if pep_rid := values.get('poc_event_person_id_random'): values['poc_event_person_id'] = pep_rid
|
if pep_rid := values.get('poc_event_person_id_random'): values['poc_event_person_id'] = pep_rid
|
||||||
if pp_rid := values.get('poc_person_id_random'): values['poc_person_id'] = pp_rid
|
if pp_rid := values.get('poc_person_id_random'): values['poc_person_id'] = pp_rid
|
||||||
@@ -297,14 +298,14 @@ class Event_Meeting_Flat_Base(BaseModel):
|
|||||||
if c1_rid := values.get('contact_1_id_random'): values['contact_1_id'] = c1_rid
|
if c1_rid := values.get('contact_1_id_random'): values['contact_1_id'] = c1_rid
|
||||||
if c2_rid := values.get('contact_2_id_random'): values['contact_2_id'] = c2_rid
|
if c2_rid := values.get('contact_2_id_random'): values['contact_2_id'] = c2_rid
|
||||||
if c3_rid := values.get('contact_3_id_random'): values['contact_3_id'] = c3_rid
|
if c3_rid := values.get('contact_3_id_random'): values['contact_3_id'] = c3_rid
|
||||||
|
|
||||||
# 2. Prevent "Collision Population" or leakage of integers during API responses
|
# 2. Prevent "Collision Population" or leakage of integers during API responses
|
||||||
for k in ['id', 'event_id', 'account_id', 'poc_event_person_id', 'poc_person_id', 'user_id', 'address_location_id', 'contact_1_id', 'contact_2_id', 'contact_3_id']:
|
for k in ['id', 'event_id', 'account_id', 'poc_event_person_id', 'poc_person_id', 'user_id', 'address_location_id', 'contact_1_id', 'contact_2_id', 'contact_3_id']:
|
||||||
val = values.get(k)
|
val = values.get(k)
|
||||||
if val is not None and not isinstance(val, str):
|
if val is not None and not isinstance(val, str):
|
||||||
if values.get(f'{k}_random') or (k=='id' and values.get('id_random')):
|
if values.get(f'{k}_random') or (k=='id' and values.get('id_random')):
|
||||||
del values[k]
|
del values[k]
|
||||||
|
|
||||||
return values
|
return values
|
||||||
|
|
||||||
code: Optional[str] = Field(
|
code: Optional[str] = Field(
|
||||||
@@ -396,6 +397,7 @@ class Event_Meeting_Flat_Base(BaseModel):
|
|||||||
|
|
||||||
cfg_json: Optional[Union[Json, None]] # Store per event config options; Not currently used 2024-06-11
|
cfg_json: Optional[Union[Json, None]] # Store per event config options; Not currently used 2024-06-11
|
||||||
data_json: Optional[Union[Json, None]] # For key value data. Careful with overwriting existing fields! Not currently used 2024-06-11
|
data_json: Optional[Union[Json, None]] # For key value data. Careful with overwriting existing fields! Not currently used 2024-06-11
|
||||||
|
default_qry_str: Optional[str] # Default query string used for searching and filtering events. Updated using SQL triggers and a SQL function
|
||||||
|
|
||||||
enable: Optional[bool] # Also in Event_Cfg_Base model
|
enable: Optional[bool] # Also in Event_Cfg_Base model
|
||||||
enable_from: Optional[datetime.datetime] = None
|
enable_from: Optional[datetime.datetime] = None
|
||||||
@@ -413,7 +415,7 @@ class Event_Meeting_Flat_Base(BaseModel):
|
|||||||
# --- IDAA Recovery Meetings: Convenience Data (Flat) ---
|
# --- IDAA Recovery Meetings: Convenience Data (Flat) ---
|
||||||
# These fields are primarily for the flat "Meeting" view used by the IDAA mobile/web apps.
|
# These fields are primarily for the flat "Meeting" view used by the IDAA mobile/web apps.
|
||||||
# Note: We prioritize string IDs (id_random) for all external API consumers.
|
# Note: We prioritize string IDs (id_random) for all external API consumers.
|
||||||
|
|
||||||
address_id_random: Optional[str] = Field(None, **base_fields['address_id_random'])
|
address_id_random: Optional[str] = Field(None, **base_fields['address_id_random'])
|
||||||
address_name: Optional[str]
|
address_name: Optional[str]
|
||||||
address_line_1: Optional[str]
|
address_line_1: Optional[str]
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ class Event_Presenter_Base(BaseModel):
|
|||||||
notes: Optional[str]
|
notes: Optional[str]
|
||||||
created_on: Optional[datetime.datetime] = None
|
created_on: Optional[datetime.datetime] = None
|
||||||
updated_on: Optional[datetime.datetime] = None
|
updated_on: Optional[datetime.datetime] = None
|
||||||
|
default_qry_str: Optional[str] # Default query string used for searching and filtering presenters. Updated using SQL triggers and a SQL function
|
||||||
|
|
||||||
# Including convenience data
|
# Including convenience data
|
||||||
# This is only for convenience. Probably going to keep unless it causes a problem.
|
# This is only for convenience. Probably going to keep unless it causes a problem.
|
||||||
@@ -190,7 +191,7 @@ class Event_Presenter_Base(BaseModel):
|
|||||||
if rid := values.get('id_random') or values.get('event_presenter_id_random'):
|
if rid := values.get('id_random') or values.get('event_presenter_id_random'):
|
||||||
values['id'] = rid
|
values['id'] = rid
|
||||||
values['event_presenter_id'] = rid
|
values['event_presenter_id'] = rid
|
||||||
|
|
||||||
if a_rid := values.get('account_id_random'): values['account_id'] = a_rid
|
if a_rid := values.get('account_id_random'): values['account_id'] = a_rid
|
||||||
if e_rid := values.get('event_id_random'): values['event_id'] = e_rid
|
if e_rid := values.get('event_id_random'): values['event_id'] = e_rid
|
||||||
if ep_rid := values.get('event_person_id_random'): values['event_person_id'] = ep_rid
|
if ep_rid := values.get('event_person_id_random'): values['event_person_id'] = ep_rid
|
||||||
@@ -198,12 +199,12 @@ class Event_Presenter_Base(BaseModel):
|
|||||||
if es_rid := values.get('event_session_id_random'): values['event_session_id'] = es_rid
|
if es_rid := values.get('event_session_id_random'): values['event_session_id'] = es_rid
|
||||||
if et_rid := values.get('event_track_id_random'): values['event_track_id'] = et_rid
|
if et_rid := values.get('event_track_id_random'): values['event_track_id'] = et_rid
|
||||||
if p_rid := values.get('person_id_random'): values['person_id'] = p_rid
|
if p_rid := values.get('person_id_random'): values['person_id'] = p_rid
|
||||||
|
|
||||||
# 2. Prevent "Collision Population"
|
# 2. Prevent "Collision Population"
|
||||||
for k in ['id', 'event_presenter_id', 'account_id', 'event_id', 'event_person_id', 'event_presentation_id', 'event_session_id', 'event_track_id', 'person_id']:
|
for k in ['id', 'event_presenter_id', 'account_id', 'event_id', 'event_person_id', 'event_presentation_id', 'event_session_id', 'event_track_id', 'person_id']:
|
||||||
if k in values and not isinstance(values[k], str) and values[k] is not None:
|
if k in values and not isinstance(values[k], str) and values[k] is not None:
|
||||||
del values[k]
|
del values[k]
|
||||||
|
|
||||||
return values
|
return values
|
||||||
|
|
||||||
# Fields that are part of the model (for reading) but should not be saved to the DB table
|
# Fields that are part of the model (for reading) but should not be saved to the DB table
|
||||||
@@ -313,6 +314,7 @@ class Event_Presenter_Out_Base(BaseModel):
|
|||||||
notes: Optional[str]
|
notes: Optional[str]
|
||||||
created_on: Optional[datetime.datetime] = None
|
created_on: Optional[datetime.datetime] = None
|
||||||
updated_on: Optional[datetime.datetime] = None
|
updated_on: Optional[datetime.datetime] = None
|
||||||
|
default_qry_str: Optional[str] # Default query string used for searching and filtering presenters. Updated using SQL triggers and a SQL function
|
||||||
|
|
||||||
person_external_id: Optional[str]
|
person_external_id: Optional[str]
|
||||||
person_external_sys_id: Optional[str]
|
person_external_sys_id: Optional[str]
|
||||||
@@ -338,18 +340,18 @@ class Event_Presenter_Out_Base(BaseModel):
|
|||||||
if rid := values.get('id_random') or values.get('event_presenter_id_random'):
|
if rid := values.get('id_random') or values.get('event_presenter_id_random'):
|
||||||
values['id'] = rid
|
values['id'] = rid
|
||||||
values['event_presenter_id'] = rid
|
values['event_presenter_id'] = rid
|
||||||
|
|
||||||
if a_rid := values.get('account_id_random'): values['account_id'] = a_rid
|
if a_rid := values.get('account_id_random'): values['account_id'] = a_rid
|
||||||
if e_rid := values.get('event_id_random'): values['event_id'] = e_rid
|
if e_rid := values.get('event_id_random'): values['event_id'] = e_rid
|
||||||
if epr_rid := values.get('event_presentation_id_random'): values['event_presentation_id'] = epr_rid
|
if epr_rid := values.get('event_presentation_id_random'): values['event_presentation_id'] = epr_rid
|
||||||
if es_rid := values.get('event_session_id_random'): values['event_session_id'] = es_rid
|
if es_rid := values.get('event_session_id_random'): values['event_session_id'] = es_rid
|
||||||
if p_rid := values.get('person_id_random'): values['person_id'] = p_rid
|
if p_rid := values.get('person_id_random'): values['person_id'] = p_rid
|
||||||
|
|
||||||
# 2. Prevent "Collision Population"
|
# 2. Prevent "Collision Population"
|
||||||
for k in ['id', 'event_presenter_id', 'account_id', 'event_id', 'event_presentation_id', 'event_session_id', 'person_id']:
|
for k in ['id', 'event_presenter_id', 'account_id', 'event_id', 'event_presentation_id', 'event_session_id', 'person_id']:
|
||||||
if k in values and not isinstance(values[k], str) and values[k] is not None:
|
if k in values and not isinstance(values[k], str) and values[k] is not None:
|
||||||
del values[k]
|
del values[k]
|
||||||
|
|
||||||
return values
|
return values
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ class Event_Session_Base(BaseModel):
|
|||||||
notes: Optional[str]
|
notes: Optional[str]
|
||||||
created_on: Optional[datetime.datetime] = None
|
created_on: Optional[datetime.datetime] = None
|
||||||
updated_on: Optional[datetime.datetime] = None
|
updated_on: Optional[datetime.datetime] = None
|
||||||
|
default_qry_str: Optional[str] # Default query string used for searching and filtering sessions. Updated using SQL triggers and a SQL function
|
||||||
|
|
||||||
# Including convenience data
|
# Including convenience data
|
||||||
# This is only for convenience. Probably going to keep unless it causes a problem.
|
# This is only for convenience. Probably going to keep unless it causes a problem.
|
||||||
@@ -193,7 +194,7 @@ class Event_Session_Base(BaseModel):
|
|||||||
if rid := values.get('id_random') or values.get('event_session_id_random'):
|
if rid := values.get('id_random') or values.get('event_session_id_random'):
|
||||||
values['id'] = rid
|
values['id'] = rid
|
||||||
values['event_session_id'] = rid
|
values['event_session_id'] = rid
|
||||||
|
|
||||||
if a_rid := values.get('account_id_random'):
|
if a_rid := values.get('account_id_random'):
|
||||||
values['account_id'] = a_rid
|
values['account_id'] = a_rid
|
||||||
if e_rid := values.get('event_id_random'):
|
if e_rid := values.get('event_id_random'):
|
||||||
@@ -206,24 +207,24 @@ class Event_Session_Base(BaseModel):
|
|||||||
values['poc_event_person_id'] = pep_rid
|
values['poc_event_person_id'] = pep_rid
|
||||||
if pp_rid := values.get('poc_person_id_random'):
|
if pp_rid := values.get('poc_person_id_random'):
|
||||||
values['poc_person_id'] = pp_rid
|
values['poc_person_id'] = pp_rid
|
||||||
|
|
||||||
# 2. Prevent "Collision Population"
|
# 2. Prevent "Collision Population"
|
||||||
for k in ['id', 'event_session_id', 'account_id', 'event_id', 'event_location_id', 'event_track_id', 'poc_event_person_id', 'poc_person_id']:
|
for k in ['id', 'event_session_id', 'account_id', 'event_id', 'event_location_id', 'event_track_id', 'poc_event_person_id', 'poc_person_id']:
|
||||||
if k in values and not isinstance(values[k], str) and values[k] is not None:
|
if k in values and not isinstance(values[k], str) and values[k] is not None:
|
||||||
del values[k]
|
del values[k]
|
||||||
|
|
||||||
return values
|
return values
|
||||||
|
|
||||||
# Fields that are part of the model (for reading) but should not be saved to the DB table
|
# Fields that are part of the model (for reading) but should not be saved to the DB table
|
||||||
fields_to_exclude_from_db: ClassVar[list] = [
|
fields_to_exclude_from_db: ClassVar[list] = [
|
||||||
'account_id',
|
'account_id',
|
||||||
'file_count', 'internal_use_count', 'event_file_id_li_json', 'file_count_all',
|
'file_count', 'internal_use_count', 'event_file_id_li_json', 'file_count_all',
|
||||||
'event_name', 'event_start_datetime', 'event_end_datetime',
|
'event_name', 'event_start_datetime', 'event_end_datetime',
|
||||||
'event_location_name', 'event_track_name',
|
'event_location_name', 'event_track_name',
|
||||||
'event_abstract_list', 'event_badge_list', 'event_device_list',
|
'event_abstract_list', 'event_badge_list', 'event_device_list',
|
||||||
'event_file_list', 'event_file_internal_use_list', 'event_location',
|
'event_file_list', 'event_file_internal_use_list', 'event_location',
|
||||||
'event_location_list', 'event_person_list', 'event_presenter_cat',
|
'event_location_list', 'event_person_list', 'event_presenter_cat',
|
||||||
'event_presentation_list', 'event_presenter_list', 'event_track',
|
'event_presentation_list', 'event_presenter_list', 'event_track',
|
||||||
'poc_event_person', 'poc_person',
|
'poc_event_person', 'poc_person',
|
||||||
'poc_person_external_id', 'poc_person_given_name', 'poc_person_family_name',
|
'poc_person_external_id', 'poc_person_given_name', 'poc_person_family_name',
|
||||||
'poc_person_full_name', 'poc_person_primary_email', 'poc_person_passcode'
|
'poc_person_full_name', 'poc_person_primary_email', 'poc_person_passcode'
|
||||||
|
|||||||
Reference in New Issue
Block a user