Work on event related and added new create_on and updated_on forced change to UTC.
This commit is contained in:
@@ -27,9 +27,9 @@ def load_event_obj(
|
|||||||
exclude_unset: bool = True,
|
exclude_unset: bool = True,
|
||||||
model_as_dict: bool = False,
|
model_as_dict: bool = False,
|
||||||
enabled: str = 'enabled', # enabled, disabled, all
|
enabled: str = 'enabled', # enabled, disabled, all
|
||||||
inc_address: bool = False, # Under contact
|
inc_address: bool = False, # Loads address_location and under contact(s)
|
||||||
# inc_address_location: bool = False,
|
# inc_address_location: bool = False,
|
||||||
inc_contact: bool = False,
|
inc_contact: bool = False, # Loads all 3 contacts
|
||||||
# inc_contact_1: bool = False,
|
# inc_contact_1: bool = False,
|
||||||
# inc_contact_2: bool = False,
|
# inc_contact_2: bool = False,
|
||||||
# inc_contact_3: bool = False,
|
# inc_contact_3: bool = False,
|
||||||
@@ -295,8 +295,9 @@ def get_event_rec_list(
|
|||||||
organization_id: str = None,
|
organization_id: str = None,
|
||||||
person_id: str = None,
|
person_id: str = None,
|
||||||
user_id: str = None,
|
user_id: str = None,
|
||||||
limit: int = 1000,
|
limit: int = 500,
|
||||||
enabled: str = 'enabled', # enabled, disabled, all
|
enabled: str = 'enabled', # enabled, disabled, all
|
||||||
|
archived: str = 'archived', # archived, not_archived, all
|
||||||
conference: bool = False, # If it is a conference then organization, person, and user are queried as participants (not the owner/organizer)
|
conference: bool = False, # If it is a conference then organization, person, and user are queried as participants (not the owner/organizer)
|
||||||
) -> list|bool:
|
) -> list|bool:
|
||||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
@@ -324,6 +325,18 @@ def get_event_rec_list(
|
|||||||
data['user_id'] = user_id
|
data['user_id'] = user_id
|
||||||
data['conference'] = conference
|
data['conference'] = conference
|
||||||
|
|
||||||
|
if archived in ['archived', 'not_archived', 'all']:
|
||||||
|
if archived == 'archived':
|
||||||
|
data['archive'] = True
|
||||||
|
sql_archived = f'AND `event`.archive = :archive'
|
||||||
|
elif archived == 'not_archived':
|
||||||
|
data['archive'] = False
|
||||||
|
sql_archived = f'AND (`event`.archive = :archive OR `event`.archive IS NULL)'
|
||||||
|
elif archived == 'all':
|
||||||
|
sql_archived = ''
|
||||||
|
else:
|
||||||
|
sql_archived = f'AND `event`.archive = :archive'
|
||||||
|
|
||||||
if conference:
|
if conference:
|
||||||
data['conference'] = True
|
data['conference'] = True
|
||||||
sql_conference = f'AND `event`.conference = :conference'
|
sql_conference = f'AND `event`.conference = :conference'
|
||||||
@@ -331,7 +344,17 @@ def get_event_rec_list(
|
|||||||
data['conference'] = False
|
data['conference'] = False
|
||||||
sql_conference = f'AND `event`.conference = :conference'
|
sql_conference = f'AND `event`.conference = :conference'
|
||||||
|
|
||||||
|
if enabled in ['enabled', 'disabled', 'all']:
|
||||||
|
if enabled == 'enabled':
|
||||||
|
data['enable'] = True
|
||||||
|
sql_enabled = f'AND `event`.enable = :enable'
|
||||||
|
elif enabled == 'disabled':
|
||||||
|
data['enable'] = False
|
||||||
|
sql_enabled = f'AND `event`.enable = :enable'
|
||||||
|
elif enabled == 'all':
|
||||||
|
sql_enabled = ''
|
||||||
|
else:
|
||||||
|
sql_enabled = f'AND `event`.enable = :enable'
|
||||||
|
|
||||||
if limit:
|
if limit:
|
||||||
data['limit'] = limit
|
data['limit'] = limit
|
||||||
@@ -349,24 +372,13 @@ def get_event_rec_list(
|
|||||||
elif user_id:
|
elif user_id:
|
||||||
sql_where_type_id = f'`event`.user_id = :user_id'
|
sql_where_type_id = f'`event`.user_id = :user_id'
|
||||||
|
|
||||||
if enabled in ['enabled', 'disabled', 'all']:
|
|
||||||
if enabled == 'enabled':
|
|
||||||
data['enable'] = True
|
|
||||||
sql_enabled = f'AND `event`.enable = :enable'
|
|
||||||
elif enabled == 'disabled':
|
|
||||||
data['enable'] = False
|
|
||||||
sql_enabled = f'AND `event`.enable = :enable'
|
|
||||||
elif enabled == 'all':
|
|
||||||
sql_enabled = ''
|
|
||||||
else:
|
|
||||||
sql_enabled = f'AND `event`.enable = :enable'
|
|
||||||
|
|
||||||
sql = f"""
|
sql = f"""
|
||||||
SELECT `event`.id AS 'event_id', `event`.id_random AS 'event_id_random'
|
SELECT `event`.id AS 'event_id', `event`.id_random AS 'event_id_random'
|
||||||
FROM `event` AS `event`
|
FROM `event` AS `event`
|
||||||
WHERE
|
WHERE
|
||||||
{sql_where_type_id}
|
{sql_where_type_id}
|
||||||
{sql_enabled}
|
{sql_enabled}
|
||||||
|
{sql_archived}
|
||||||
{sql_conference}
|
{sql_conference}
|
||||||
ORDER BY `event`.created_on DESC, `event`.updated_on DESC
|
ORDER BY `event`.created_on DESC, `event`.updated_on DESC
|
||||||
{sql_limit};
|
{sql_limit};
|
||||||
@@ -379,26 +391,15 @@ def get_event_rec_list(
|
|||||||
elif user_id:
|
elif user_id:
|
||||||
sql_inner_join = f'`user` ON event_person.user_id = user.id AND user.id AND user.id = :user_id'
|
sql_inner_join = f'`user` ON event_person.user_id = user.id AND user.id AND user.id = :user_id'
|
||||||
|
|
||||||
if enabled in ['enabled', 'disabled', 'all']:
|
|
||||||
if enabled == 'enabled':
|
|
||||||
data['enable'] = True
|
|
||||||
sql_enabled = f'`event`.enable = :enable'
|
|
||||||
elif enabled == 'disabled':
|
|
||||||
data['enable'] = False
|
|
||||||
sql_enabled = f'`event`.enable = :enable'
|
|
||||||
elif enabled == 'all':
|
|
||||||
sql_enabled = ''
|
|
||||||
else:
|
|
||||||
sql_enabled = f'`event`.enable = :enable'
|
|
||||||
|
|
||||||
sql = f"""
|
sql = f"""
|
||||||
SELECT `event`.id AS 'event_id', `event`.id_random AS 'event_id_random'
|
SELECT `event`.id AS 'event_id', `event`.id_random AS 'event_id_random'
|
||||||
FROM `event` AS `event`
|
FROM `event` AS `event`
|
||||||
INNER JOIN `event_person` ON event.id = event_person.event_id
|
INNER JOIN `event_person` ON event.id = event_person.event_id
|
||||||
/*INNER JOIN `person` ON event_person.person_id = person.id*/
|
/*INNER JOIN `person` ON event_person.person_id = person.id*/
|
||||||
INNER JOIN {sql_inner_join}
|
INNER JOIN {sql_inner_join}
|
||||||
WHERE
|
WHERE 1=1
|
||||||
{sql_enabled}
|
{sql_enabled}
|
||||||
|
{sql_archived}
|
||||||
{sql_conference}
|
{sql_conference}
|
||||||
ORDER BY `event`.created_on DESC, `event`.updated_on DESC
|
ORDER BY `event`.created_on DESC, `event`.updated_on DESC
|
||||||
{sql_limit};
|
{sql_limit};
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ class Event_Cfg_Base(BaseModel):
|
|||||||
enable_from: Optional[datetime.datetime]
|
enable_from: Optional[datetime.datetime]
|
||||||
enable_to: Optional[datetime.datetime]
|
enable_to: Optional[datetime.datetime]
|
||||||
|
|
||||||
|
conference: Optional[bool]
|
||||||
|
|
||||||
enable_comments: Optional[bool]
|
enable_comments: Optional[bool]
|
||||||
disable_navigation: Optional[bool]
|
disable_navigation: Optional[bool]
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class Event_Base(BaseModel):
|
|||||||
lu_event_type_id: Optional[int]
|
lu_event_type_id: Optional[int]
|
||||||
#lu_event_type: Optional[str] # Needs to be reviewed
|
#lu_event_type: Optional[str] # Needs to be reviewed
|
||||||
|
|
||||||
conference: Optional[bool]
|
conference: Optional[bool] # Also in Event_Cfg_Base model
|
||||||
|
|
||||||
# type_name: Optional[str] = Field(
|
# type_name: Optional[str] = Field(
|
||||||
# alias = 'type'
|
# alias = 'type'
|
||||||
@@ -118,6 +118,9 @@ class Event_Base(BaseModel):
|
|||||||
enable_from: Optional[datetime.datetime] = None
|
enable_from: Optional[datetime.datetime] = None
|
||||||
enable_to: Optional[datetime.datetime] = None
|
enable_to: Optional[datetime.datetime] = None
|
||||||
|
|
||||||
|
archive: Optional[bool] # Also in Event_Cfg_Base model
|
||||||
|
archive_on: Optional[datetime.datetime] # Also in Event_Cfg_Base model
|
||||||
|
|
||||||
hide: Optional[bool] # Also in Event_Cfg_Base model
|
hide: Optional[bool] # Also in Event_Cfg_Base model
|
||||||
priority: Optional[bool]
|
priority: Optional[bool]
|
||||||
sort: Optional[int]
|
sort: Optional[int]
|
||||||
@@ -242,6 +245,18 @@ class Event_Base(BaseModel):
|
|||||||
return redis_lookup_id_random(record_id_random=values['contact_3_id_random'], table_name='contact')
|
return redis_lookup_id_random(record_id_random=values['contact_3_id_random'], table_name='contact')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@validator('created_on', always=True)
|
||||||
|
def created_on_utc(cls, v, values, **kwargs):
|
||||||
|
if isinstance(v, datetime.datetime):
|
||||||
|
return v.astimezone(pytz.UTC).isoformat()
|
||||||
|
else: return v
|
||||||
|
|
||||||
|
@validator('updated_on', always=True)
|
||||||
|
def updated_on_utc(cls, v, values, **kwargs):
|
||||||
|
if isinstance(v, datetime.datetime):
|
||||||
|
return v.astimezone(pytz.UTC).isoformat()
|
||||||
|
else: return v
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
underscore_attrs_are_private = True
|
underscore_attrs_are_private = True
|
||||||
allow_population_by_field_name = True
|
allow_population_by_field_name = True
|
||||||
|
|||||||
@@ -349,8 +349,9 @@ async def get_event_obj(
|
|||||||
@router.get('/account/{account_id}/event/list', response_model=Resp_Body_Base)
|
@router.get('/account/{account_id}/event/list', response_model=Resp_Body_Base)
|
||||||
async def get_account_obj_event_list(
|
async def get_account_obj_event_list(
|
||||||
account_id: str = Query(..., min_length=1, max_length=22),
|
account_id: str = Query(..., min_length=1, max_length=22),
|
||||||
limit: int = 500, # For now this covers any included objects or object lists
|
limit: int = 500,
|
||||||
enabled: str = 'enabled', # For now this covers any included objects or object lists
|
enabled: str = 'enabled',
|
||||||
|
archived: str = 'not_archived', # archived, not_archived, all
|
||||||
conference: bool = False, # Events with badges, sessions, presentations, presenters, registration, etc
|
conference: bool = False, # Events with badges, sessions, presentations, presenters, registration, etc
|
||||||
# inc_account_cfg: bool = False,
|
# inc_account_cfg: bool = False,
|
||||||
inc_address: bool = False, # Under event and under contact
|
inc_address: bool = False, # Under event and under contact
|
||||||
@@ -400,6 +401,7 @@ async def get_account_obj_event_list(
|
|||||||
account_id = account_id,
|
account_id = account_id,
|
||||||
limit = limit,
|
limit = limit,
|
||||||
enabled = enabled,
|
enabled = enabled,
|
||||||
|
archived = archived,
|
||||||
conference = conference,
|
conference = conference,
|
||||||
):
|
):
|
||||||
event_result_list = []
|
event_result_list = []
|
||||||
|
|||||||
Reference in New Issue
Block a user