Working on event registration and related.
This commit is contained in:
@@ -124,7 +124,7 @@ app.include_router(
|
|||||||
)
|
)
|
||||||
app.include_router(
|
app.include_router(
|
||||||
event_person.router,
|
event_person.router,
|
||||||
prefix='/event/person',
|
# prefix='/event/person',
|
||||||
tags=['Event Person'],
|
tags=['Event Person'],
|
||||||
)
|
)
|
||||||
app.include_router(
|
app.include_router(
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ def load_contact_obj(
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if inc_address:
|
if inc_address:
|
||||||
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.info('Need to include address data...')
|
||||||
address_id = contact_rec.get('address_id', None)
|
address_id = contact_rec.get('address_id', None)
|
||||||
log.debug(address_id)
|
log.debug(address_id)
|
||||||
from app.methods.address_methods import load_address_obj
|
from app.methods.address_methods import load_address_obj
|
||||||
|
|||||||
42
app/methods/event_badge_methods.py
Normal file
42
app/methods/event_badge_methods.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from typing import Dict, List, Optional, Set, Union
|
||||||
|
from pydantic import BaseModel, EmailStr, Field, PrivateAttr, ValidationError, validator
|
||||||
|
|
||||||
|
from app.db_sql import redis_lookup_id_random, sql_insert, sql_select, sql_update
|
||||||
|
from app.lib_general import log, logging
|
||||||
|
|
||||||
|
from app.models.event_badge_models import Event_Badge_Base
|
||||||
|
|
||||||
|
|
||||||
|
# ### BEGIN ### API Event Badge Methods ### load_event_badge_obj() ###
|
||||||
|
def load_event_badge_obj(
|
||||||
|
event_badge_id: int|str,
|
||||||
|
limit: int = 1000,
|
||||||
|
by_alias: bool = True,
|
||||||
|
exclude_unset: bool = True,
|
||||||
|
model_as_dict: bool = False,
|
||||||
|
enabled: str = 'enabled', # enabled, disabled, all
|
||||||
|
) -> Event_Badge_Base|dict|bool:
|
||||||
|
# log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
|
log.debug(locals())
|
||||||
|
|
||||||
|
if event_badge_id := redis_lookup_id_random(record_id_random=event_badge_id, table_name='event_badge'): pass
|
||||||
|
else: return False
|
||||||
|
|
||||||
|
if event_badge_rec := sql_select(table_name='v_event_badge', record_id=event_badge_id): pass
|
||||||
|
else: return False
|
||||||
|
|
||||||
|
try:
|
||||||
|
event_badge_obj = Event_Badge_Base(**event_badge_rec)
|
||||||
|
log.debug(event_badge_obj)
|
||||||
|
except ValidationError as e:
|
||||||
|
log.error(e.json())
|
||||||
|
return False
|
||||||
|
|
||||||
|
if model_as_dict:
|
||||||
|
return event_badge_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
|
||||||
|
else:
|
||||||
|
return event_badge_obj
|
||||||
|
# ### END ### API Event Badge Methods ### load_event_badge_obj() ###
|
||||||
@@ -83,7 +83,8 @@ def load_event_obj(
|
|||||||
|
|
||||||
# Updated 2021-06-30
|
# Updated 2021-06-30
|
||||||
if inc_address: # This address is directly linked from the event record.
|
if inc_address: # This address is directly linked from the event record.
|
||||||
address_location_id = event_rec.get('address_location_id', None)
|
log.info('Need to include event location address data...')
|
||||||
|
address_location_id = event_rec.get('address_location_id', None) # Should this be location_address_id? Reverse the field naming?
|
||||||
log.debug(address_location_id)
|
log.debug(address_location_id)
|
||||||
if address_location_result := load_address_obj(
|
if address_location_result := load_address_obj(
|
||||||
address_id = address_location_id,
|
address_id = address_location_id,
|
||||||
@@ -98,6 +99,7 @@ def load_event_obj(
|
|||||||
|
|
||||||
# Updated 2021-06-30
|
# Updated 2021-06-30
|
||||||
if inc_contact: # Just load all 3 of the contacts
|
if inc_contact: # Just load all 3 of the contacts
|
||||||
|
log.info('Need to include event contacts (3x) data...')
|
||||||
contact_1_id = event_rec.get('contact_1_id', None)
|
contact_1_id = event_rec.get('contact_1_id', None)
|
||||||
log.debug(contact_1_id)
|
log.debug(contact_1_id)
|
||||||
if contact_1_result := load_contact_obj(
|
if contact_1_result := load_contact_obj(
|
||||||
@@ -146,6 +148,7 @@ def load_event_obj(
|
|||||||
|
|
||||||
# Updated 2021-06-30
|
# Updated 2021-06-30
|
||||||
if inc_event_cfg:
|
if inc_event_cfg:
|
||||||
|
log.info('Need to include event configuration...')
|
||||||
# event_id = event_rec.get('event_id', None)
|
# event_id = event_rec.get('event_id', None)
|
||||||
# log.debug(event_id)
|
# log.debug(event_id)
|
||||||
if event_cfg_result := load_event_cfg_obj(
|
if event_cfg_result := load_event_cfg_obj(
|
||||||
@@ -169,6 +172,7 @@ def load_event_obj(
|
|||||||
if inc_event_registration_list: pass
|
if inc_event_registration_list: pass
|
||||||
|
|
||||||
if inc_event_session_list:
|
if inc_event_session_list:
|
||||||
|
log.info('Need to include event session list...')
|
||||||
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
#log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
@@ -238,6 +242,8 @@ def load_event_obj(
|
|||||||
if inc_event_track_list: pass
|
if inc_event_track_list: pass
|
||||||
|
|
||||||
if inc_poc_event_person:
|
if inc_poc_event_person:
|
||||||
|
log.info('Need to include event poc event person data...')
|
||||||
|
log.info('OR??? Need to include event poc person data...?')
|
||||||
poc_event_person_obj = load_person_obj(person_id=poc_event_person_id)
|
poc_event_person_obj = load_person_obj(person_id=poc_event_person_id)
|
||||||
log.debug(poc_event_person_obj)
|
log.debug(poc_event_person_obj)
|
||||||
#event_rec['poc_event_person'] = poc_event_person_obj
|
#event_rec['poc_event_person'] = poc_event_person_obj
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from app.db_sql import redis_lookup_id_random, sql_insert, sql_select, sql_updat
|
|||||||
from app.lib_general import log, logging
|
from app.lib_general import log, logging
|
||||||
|
|
||||||
# from app.methods.event_abstract_methods import load_event_abstract_obj
|
# from app.methods.event_abstract_methods import load_event_abstract_obj
|
||||||
# from app.methods.event_badge_methods import load_event_badge_obj
|
from app.methods.event_badge_methods import load_event_badge_obj
|
||||||
# from app.methods.event_exhibit_methods import load_event_exhibit_obj
|
# from app.methods.event_exhibit_methods import load_event_exhibit_obj
|
||||||
# from app.methods.event_file_methods import load_event_file_obj
|
# from app.methods.event_file_methods import load_event_file_obj
|
||||||
# from app.methods.event_presentation_methods import load_event_presentation_obj
|
# from app.methods.event_presentation_methods import load_event_presentation_obj
|
||||||
@@ -27,6 +27,9 @@ def load_event_person_obj(
|
|||||||
event_person_id: int|str,
|
event_person_id: int|str,
|
||||||
enabled: str = 'enabled', # enabled, disabled, all
|
enabled: str = 'enabled', # enabled, disabled, all
|
||||||
limit: int = 1000,
|
limit: int = 1000,
|
||||||
|
by_alias: bool = True,
|
||||||
|
exclude_unset: bool = True,
|
||||||
|
model_as_dict: bool = False,
|
||||||
inc_address: bool = False,
|
inc_address: bool = False,
|
||||||
inc_contact: bool = False,
|
inc_contact: bool = False,
|
||||||
inc_event_abstract_list: bool = False,
|
inc_event_abstract_list: bool = False,
|
||||||
@@ -70,7 +73,20 @@ def load_event_person_obj(
|
|||||||
# user_id = event_person_obj.user_id
|
# user_id = event_person_obj.user_id
|
||||||
|
|
||||||
if inc_event_abstract_list: pass
|
if inc_event_abstract_list: pass
|
||||||
if inc_event_badge: pass
|
|
||||||
|
# Updated 2021-08-17
|
||||||
|
if inc_event_badge:
|
||||||
|
log.info('Need to include event badge data...')
|
||||||
|
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
|
if event_badge_obj := load_event_badge_obj(
|
||||||
|
event_badge_id = event_badge_id
|
||||||
|
):
|
||||||
|
log.debug(event_badge_obj)
|
||||||
|
event_person_obj.event_badge = event_badge_obj.dict(by_alias=True, exclude_unset=True)
|
||||||
|
else:
|
||||||
|
log.warning('A event_badge object was not returned.')
|
||||||
|
event_person_obj.event_badge = None
|
||||||
|
|
||||||
if inc_event_exhibit_list: pass
|
if inc_event_exhibit_list: pass
|
||||||
if inc_event_file_list: pass
|
if inc_event_file_list: pass
|
||||||
#if inc_event_person_detail: pass
|
#if inc_event_person_detail: pass
|
||||||
@@ -80,32 +96,92 @@ def load_event_person_obj(
|
|||||||
if inc_event_session_list: pass
|
if inc_event_session_list: pass
|
||||||
if inc_event_track_list: pass
|
if inc_event_track_list: pass
|
||||||
|
|
||||||
|
# Updated 2021-08-17
|
||||||
if inc_person:
|
if inc_person:
|
||||||
|
log.info('Need to include person data...')
|
||||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
if person_obj := load_person_obj(
|
if person_obj := load_person_obj(
|
||||||
inc_address=inc_address,
|
inc_address = inc_address,
|
||||||
inc_contact=inc_contact,
|
inc_contact = inc_contact,
|
||||||
person_id=person_id
|
person_id = person_id
|
||||||
):
|
):
|
||||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
|
||||||
log.debug(person_obj)
|
log.debug(person_obj)
|
||||||
event_person_obj.person = person_obj.dict(by_alias=True, exclude_unset=True)
|
event_person_obj.person = person_obj.dict(by_alias=True, exclude_unset=True)
|
||||||
else:
|
else:
|
||||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.warning('A person object was not returned.')
|
||||||
log.debug('A person object was not returned.')
|
|
||||||
event_person_obj.person = None
|
event_person_obj.person = None
|
||||||
|
|
||||||
|
# Updated 2021-08-17
|
||||||
if inc_user:
|
if inc_user:
|
||||||
|
log.info('Need to include user data...')
|
||||||
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
# log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
if user_obj := load_user_obj(user_id=user_id):
|
if user_obj := load_user_obj(
|
||||||
|
user_id = user_id
|
||||||
|
):
|
||||||
log.debug(user_obj)
|
log.debug(user_obj)
|
||||||
event_person_obj.user = user_obj.dict(by_alias=True, exclude_unset=True)
|
event_person_obj.user = user_obj.dict(by_alias=True, exclude_unset=True)
|
||||||
else:
|
else:
|
||||||
|
log.warning('A user object was not returned.')
|
||||||
event_person_obj.user = None
|
event_person_obj.user = None
|
||||||
|
|
||||||
return event_person_obj
|
return event_person_obj
|
||||||
# ### END ### API Event Person Methods ### load_event_person_obj() ###
|
# ### END ### API Event Person Methods ### load_event_person_obj() ###
|
||||||
|
|
||||||
|
# ### BEGIN ### API Event Person Methods ### get_event_person_rec_list() ###
|
||||||
|
# for_obj_type: account, event, event_registration, event_badge, person, user
|
||||||
|
def get_event_person_rec_list(
|
||||||
|
for_obj_type: str,
|
||||||
|
for_obj_id: str,
|
||||||
|
limit: int = 1000,
|
||||||
|
enabled: str = 'enabled', # enabled, disabled, all
|
||||||
|
) -> list|bool:
|
||||||
|
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
|
log.debug(locals())
|
||||||
|
|
||||||
|
if for_obj_id := redis_lookup_id_random(record_id_random=for_obj_id, table_name=for_obj_type): pass
|
||||||
|
else: return False
|
||||||
|
data = {}
|
||||||
|
data[f'{for_obj_type}_id'] = for_obj_id
|
||||||
|
# data['for_obj_type'] = for_obj_type
|
||||||
|
sql_obj_type_id = f'`tbl`.{for_obj_type}_id = :{for_obj_type}_id'
|
||||||
|
|
||||||
|
# if enabled in ['enabled', 'disabled', 'all']:
|
||||||
|
# if enabled == 'enabled':
|
||||||
|
# data['enable'] = True
|
||||||
|
# sql_enabled = f'AND `tbl`.enable = :enable'
|
||||||
|
# elif enabled == 'disabled':
|
||||||
|
# data['enable'] = False
|
||||||
|
# sql_enabled = f'AND `tbl`.enable = :enable'
|
||||||
|
# elif enabled == 'all':
|
||||||
|
# sql_enabled = ''
|
||||||
|
sql_enabled = ''
|
||||||
|
|
||||||
|
if limit:
|
||||||
|
data['limit'] = limit
|
||||||
|
sql_limit = f'LIMIT :limit'
|
||||||
|
else:
|
||||||
|
sql_limit = ''
|
||||||
|
|
||||||
|
sql = f"""
|
||||||
|
SELECT `tbl`.id AS 'event_person_id', `tbl`.id_random AS 'event_person_id_random'
|
||||||
|
FROM `event_person` AS `tbl`
|
||||||
|
WHERE
|
||||||
|
{sql_obj_type_id}
|
||||||
|
{sql_enabled}
|
||||||
|
ORDER BY `tbl`.created_on DESC, `tbl`.updated_on DESC
|
||||||
|
{sql_limit};
|
||||||
|
"""
|
||||||
|
|
||||||
|
if event_person_rec_li_result := sql_select(data=data, sql=sql, as_list=True):
|
||||||
|
event_person_rec_li = event_person_rec_li_result
|
||||||
|
else:
|
||||||
|
event_person_rec_li = []
|
||||||
|
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
|
log.debug(event_person_rec_li_result)
|
||||||
|
|
||||||
|
return event_person_rec_li
|
||||||
|
# ### END ### API Event Person Methods ### get_event_person_rec_list() ###
|
||||||
|
|
||||||
|
|
||||||
# ### BEGIN ### API Event Person Methods ### create_event_person_obj() ###
|
# ### BEGIN ### API Event Person Methods ### create_event_person_obj() ###
|
||||||
# NOTE: This will create an event_person. This event_person should include at least a person_id.
|
# NOTE: This will create an event_person. This event_person should include at least a person_id.
|
||||||
|
|||||||
@@ -9,8 +9,9 @@ from app.lib_general import log, logging
|
|||||||
|
|
||||||
# from app.methods.address_methods import load_address_obj
|
# from app.methods.address_methods import load_address_obj
|
||||||
# from app.methods.contact_methods import load_contact_obj
|
# from app.methods.contact_methods import load_contact_obj
|
||||||
from app.methods.event_cfg_methods import load_event_cfg_obj
|
from app.methods.event_person_methods import get_event_person_rec_list, load_event_person_obj
|
||||||
from app.methods.person_methods import load_person_obj
|
from app.methods.event_registration_cfg_methods import load_event_registration_cfg_obj
|
||||||
|
# from app.methods.person_methods import load_person_obj
|
||||||
|
|
||||||
from app.models.event_registration_models import Event_Registration_Base
|
from app.models.event_registration_models import Event_Registration_Base
|
||||||
from app.models.event_cfg_models import Event_Cfg_Base
|
from app.models.event_cfg_models import Event_Cfg_Base
|
||||||
@@ -26,9 +27,10 @@ def load_event_registration_obj(
|
|||||||
enabled: str = 'enabled', # enabled, disabled, all
|
enabled: str = 'enabled', # enabled, disabled, all
|
||||||
inc_address: bool = False, # Under contact
|
inc_address: bool = False, # Under contact
|
||||||
inc_contact: bool = False,
|
inc_contact: bool = False,
|
||||||
inc_event_cfg: bool = False,
|
# inc_event_cfg: bool = False,
|
||||||
inc_event_person_list: bool = False,
|
inc_event_person_list: bool = False,
|
||||||
inc_event_registration_cfg: bool = False,
|
inc_event_registration_cfg: bool = False,
|
||||||
|
# inc_event_registration_list: bool = False,
|
||||||
inc_person: bool = False,
|
inc_person: bool = False,
|
||||||
) -> Event_Registration_Base|bool:
|
) -> Event_Registration_Base|bool:
|
||||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
@@ -46,9 +48,56 @@ def load_event_registration_obj(
|
|||||||
log.debug(event_registration_rec)
|
log.debug(event_registration_rec)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
log.info('Try to apply event registration record data to Event_Registration_Base...')
|
||||||
event_registration_obj = Event_Registration_Base(**event_registration_rec)
|
event_registration_obj = Event_Registration_Base(**event_registration_rec)
|
||||||
|
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
log.debug(event_registration_obj)
|
log.debug(event_registration_obj)
|
||||||
except ValidationError as e:
|
except ValidationError as e:
|
||||||
log.error(e.json())
|
log.error(e.json())
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
# Updated 2021-08-17
|
||||||
|
if inc_event_registration_cfg:
|
||||||
|
log.info('Need to include event registration configuration...')
|
||||||
|
event_id = event_registration_rec.get('event_id', None)
|
||||||
|
log.info(f'Need to include event registration config for event_id {event_id}...')
|
||||||
|
if event_registration_cfg_result := load_event_registration_cfg_obj(
|
||||||
|
event_id = event_id,
|
||||||
|
by_alias = by_alias,
|
||||||
|
exclude_unset = exclude_unset,
|
||||||
|
model_as_dict = model_as_dict,
|
||||||
|
):
|
||||||
|
event_registration_obj.cfg = event_registration_cfg_result
|
||||||
|
else: event_registration_obj.event_registration_cfg = None
|
||||||
|
|
||||||
|
# Updated 2021-08-17
|
||||||
|
if inc_event_person_list:
|
||||||
|
log.info('Need to include event person list...')
|
||||||
|
if event_person_rec_list_result := get_event_person_rec_list(
|
||||||
|
for_obj_type = 'event_registration',
|
||||||
|
for_obj_id = event_registration_id,
|
||||||
|
limit = limit,
|
||||||
|
enabled = enabled,
|
||||||
|
):
|
||||||
|
event_person_result_list = []
|
||||||
|
for event_person_rec in event_person_rec_list_result:
|
||||||
|
if load_event_person_result := load_event_person_obj(
|
||||||
|
event_person_id = event_person_rec.get('event_person_id', None),
|
||||||
|
limit = limit,
|
||||||
|
by_alias = by_alias,
|
||||||
|
exclude_unset = exclude_unset,
|
||||||
|
model_as_dict = model_as_dict,
|
||||||
|
enabled = enabled,
|
||||||
|
inc_person = inc_person,
|
||||||
|
# inc_user = inc_user,
|
||||||
|
):
|
||||||
|
event_person_result_list.append(load_event_person_result)
|
||||||
|
else: event_person_result_list.append(None)
|
||||||
|
event_registration_obj.event_person_list = event_person_result_list
|
||||||
|
else: event_registration_obj.event_person_list = []
|
||||||
|
|
||||||
|
if model_as_dict:
|
||||||
|
return event_registration_obj.dict(by_alias=by_alias, exclude_unset=exclude_unset) # pylint: disable=no-member
|
||||||
|
else:
|
||||||
|
return event_registration_obj
|
||||||
# ### END ### API Event Registration Methods ### load_event_registration_obj() ###
|
# ### END ### API Event Registration Methods ### load_event_registration_obj() ###
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Event_Badge_Base(BaseModel):
|
|||||||
default_factory = lambda:secrets.token_urlsafe(default_num_bytes),
|
default_factory = lambda:secrets.token_urlsafe(default_num_bytes),
|
||||||
)
|
)
|
||||||
id: Optional[int] = Field(
|
id: Optional[int] = Field(
|
||||||
#alias = 'event_badge_id'
|
alias = 'event_badge_id'
|
||||||
)
|
)
|
||||||
# account_id_random: Optional[str]
|
# account_id_random: Optional[str]
|
||||||
# account_id: Optional[int]
|
# account_id: Optional[int]
|
||||||
@@ -32,20 +32,28 @@ class Event_Badge_Base(BaseModel):
|
|||||||
person_id: Optional[int]
|
person_id: Optional[int]
|
||||||
|
|
||||||
pronoun: Optional[str]
|
pronoun: Optional[str]
|
||||||
|
informal_name: Optional[str]
|
||||||
given_name: Optional[str]
|
given_name: Optional[str]
|
||||||
family_name: Optional[str]
|
family_name: Optional[str]
|
||||||
full_name: Optional[str]
|
full_name: Optional[str]
|
||||||
|
display_name: Optional[str] # Actual name shown on badge and other "public" areas
|
||||||
|
|
||||||
email: Optional[str]
|
email: Optional[str]
|
||||||
|
|
||||||
degree: Optional[str]
|
degree: Optional[str]
|
||||||
degrees: Optional[str] # Do we want this?
|
degrees: Optional[str] # Do we want this?
|
||||||
credentials: Optional[str]
|
credentials: Optional[str]
|
||||||
title: Optional[str]
|
title: Optional[str]
|
||||||
|
|
||||||
affiliation: Optional[str]
|
affiliation: Optional[str]
|
||||||
affiliations: Optional[str] # Do we want this?
|
affiliations: Optional[str] # Do we want this?
|
||||||
|
affiliation_name: Optional[str] # Actual affiliation name(s) shown on badge and other "public" areas
|
||||||
|
|
||||||
city: Optional[str]
|
city: Optional[str]
|
||||||
county: Optional[str] # NOTE: This is for a county within a state or province
|
county: Optional[str] # NOTE: This is for a county within a state or province
|
||||||
state_province: Optional[str]
|
state_province: Optional[str]
|
||||||
country: Optional[str]
|
country: Optional[str]
|
||||||
|
location_name: Optional[str] # Actual location name shown on badge and other "public" areas
|
||||||
|
|
||||||
# NOTE: More badge fields need to be added here once things are cleaned up
|
# NOTE: More badge fields need to be added here once things are cleaned up
|
||||||
|
|
||||||
@@ -107,6 +115,7 @@ class Event_Badge_Base(BaseModel):
|
|||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
underscore_attrs_are_private = True
|
underscore_attrs_are_private = True
|
||||||
|
allow_population_by_field_name = True
|
||||||
fields = base_fields
|
fields = base_fields
|
||||||
|
|
||||||
Event_Badge_Base.update_forward_refs()
|
Event_Badge_Base.update_forward_refs()
|
||||||
|
|||||||
@@ -34,9 +34,15 @@ class Event_Person_Base(BaseModel):
|
|||||||
event_id_random: Optional[str]
|
event_id_random: Optional[str]
|
||||||
event_id: Optional[int]
|
event_id: Optional[int]
|
||||||
|
|
||||||
event_badge_id_random: Optional[str]
|
event_badge_id_random: Optional[str] # Default attendee badge
|
||||||
event_badge_id: Optional[int]
|
event_badge_id: Optional[int]
|
||||||
|
|
||||||
|
event_badge_vendor_id_random: Optional[str] # Additional vendor badge
|
||||||
|
event_badge_vendor_id: Optional[int]
|
||||||
|
|
||||||
|
event_badge_vip_id_random: Optional[str] # Additional VIP badge
|
||||||
|
event_badge_vip_id: Optional[int]
|
||||||
|
|
||||||
event_registration_id_random: Optional[str]
|
event_registration_id_random: Optional[str]
|
||||||
event_registration_id: Optional[int]
|
event_registration_id: Optional[int]
|
||||||
|
|
||||||
@@ -57,7 +63,9 @@ class Event_Person_Base(BaseModel):
|
|||||||
# Including other related objects
|
# Including other related objects
|
||||||
# event: Optional[Event_Base] # Causes an import loop
|
# event: Optional[Event_Base] # Causes an import loop
|
||||||
event_abstract_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more abstracts
|
event_abstract_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more abstracts
|
||||||
event_badge: Optional[Event_Badge_Base]
|
event_badge: Optional[Event_Badge_Base] # Default attendee badge
|
||||||
|
event_badge_vendor: Optional[Event_Badge_Base] # Additional vendor badge
|
||||||
|
event_badge_vip: Optional[Event_Badge_Base] # Additional VIP badge
|
||||||
event_exhibit_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more exhibits
|
event_exhibit_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more exhibits
|
||||||
event_file_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more files
|
event_file_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more files
|
||||||
event_location_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more locations (but unlikely?)
|
event_location_list: Optional[list] # Use event_person_detail table. An event_person record can be linked to one or more locations (but unlikely?)
|
||||||
@@ -118,6 +126,24 @@ class Event_Person_Base(BaseModel):
|
|||||||
return redis_lookup_id_random(record_id_random=values['event_badge_id_random'], table_name='event_badge')
|
return redis_lookup_id_random(record_id_random=values['event_badge_id_random'], table_name='event_badge')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@validator('event_badge_vendor_id', always=True)
|
||||||
|
def event_badge_vendor_id_lookup(cls, v, values, **kwargs):
|
||||||
|
log.setLevel(logging.WARNING)
|
||||||
|
log.debug(locals())
|
||||||
|
|
||||||
|
if values['event_badge_vendor_id_random']:
|
||||||
|
return redis_lookup_id_random(record_id_random=values['event_badge_vendor_id_random'], table_name='event_badge')
|
||||||
|
return None
|
||||||
|
|
||||||
|
@validator('event_badge_vip_id', always=True)
|
||||||
|
def event_badge_vip_id_lookup(cls, v, values, **kwargs):
|
||||||
|
log.setLevel(logging.WARNING)
|
||||||
|
log.debug(locals())
|
||||||
|
|
||||||
|
if values['event_badge_vip_id_random']:
|
||||||
|
return redis_lookup_id_random(record_id_random=values['event_badge_vip_id_random'], table_name='event_badge')
|
||||||
|
return None
|
||||||
|
|
||||||
@validator('event_registration_id', always=True)
|
@validator('event_registration_id', always=True)
|
||||||
def event_registration_id_lookup(cls, v, values, **kwargs):
|
def event_registration_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
log.setLevel(logging.WARNING)
|
||||||
@@ -147,6 +173,7 @@ class Event_Person_Base(BaseModel):
|
|||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
underscore_attrs_are_private = True
|
underscore_attrs_are_private = True
|
||||||
|
allow_population_by_field_name = True
|
||||||
fields = base_fields
|
fields = base_fields
|
||||||
|
|
||||||
|
|
||||||
@@ -160,7 +187,7 @@ class Event_Person_New_Base(BaseModel):
|
|||||||
default_factory = lambda:secrets.token_urlsafe(default_num_bytes),
|
default_factory = lambda:secrets.token_urlsafe(default_num_bytes),
|
||||||
)
|
)
|
||||||
id: Optional[int] = Field(
|
id: Optional[int] = Field(
|
||||||
#alias = 'event_person_id'
|
alias = 'event_person_id'
|
||||||
)
|
)
|
||||||
account_id_random: Optional[str]
|
account_id_random: Optional[str]
|
||||||
account_id: Optional[int]
|
account_id: Optional[int]
|
||||||
@@ -234,4 +261,5 @@ class Event_Person_New_Base(BaseModel):
|
|||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
underscore_attrs_are_private = True
|
underscore_attrs_are_private = True
|
||||||
|
allow_population_by_field_name = True
|
||||||
fields = base_fields
|
fields = base_fields
|
||||||
@@ -44,6 +44,7 @@ class Event_Registration_Base(BaseModel):
|
|||||||
|
|
||||||
# Including other related objects
|
# Including other related objects
|
||||||
cfg: Optional[Event_Registration_Cfg_Base]
|
cfg: Optional[Event_Registration_Cfg_Base]
|
||||||
|
event_person_list: Optional[list] # Optional[Event_Person_Base]
|
||||||
|
|
||||||
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from app.db_sql import sql_insert, sql_update, sql_insert_or_update, sql_select,
|
|||||||
|
|
||||||
from app.routers.api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template
|
from app.routers.api_crud import delete_obj_template, get_obj_template, get_obj_li_template, patch_obj_template, post_obj_template
|
||||||
|
|
||||||
from app.methods.event_person_methods import create_event_person_obj, load_event_person_obj, update_event_person_obj
|
from app.methods.event_person_methods import create_event_person_obj, get_event_person_rec_list, load_event_person_obj, update_event_person_obj
|
||||||
from app.methods.person_methods import create_person_obj, load_person_obj, update_person_obj
|
from app.methods.person_methods import create_person_obj, load_person_obj, update_person_obj
|
||||||
from app.methods.user_methods import create_user_obj, load_user_obj, update_user_obj
|
from app.methods.user_methods import create_user_obj, load_user_obj, update_user_obj
|
||||||
# from app.methods.user_load_methods import load_user_obj
|
# from app.methods.user_load_methods import load_user_obj
|
||||||
@@ -29,7 +29,7 @@ router = APIRouter()
|
|||||||
# Create a person record (with a contact record and an address for the contact record)
|
# Create a person record (with a contact record and an address for the contact record)
|
||||||
# Create a user record
|
# Create a user record
|
||||||
# Create an event_person record with the new person and user IDs
|
# Create an event_person record with the new person and user IDs
|
||||||
@router.post('/new', response_model=Resp_Body_Base)
|
@router.post('/event/person/new', response_model=Resp_Body_Base)
|
||||||
async def post_event_person_new(
|
async def post_event_person_new(
|
||||||
event_person_new_init: Event_Person_New_Base,
|
event_person_new_init: Event_Person_New_Base,
|
||||||
x_account_id: str = Header(...),
|
x_account_id: str = Header(...),
|
||||||
@@ -214,7 +214,7 @@ async def post_event_person_new(
|
|||||||
|
|
||||||
|
|
||||||
# ### BEGIN ### API Event Person ### patch_event_person_json() ###
|
# ### BEGIN ### API Event Person ### patch_event_person_json() ###
|
||||||
@router.patch('/{event_person_id}/json', response_model=Resp_Body_Base)
|
@router.patch('/event/person/{event_person_id}/json', response_model=Resp_Body_Base)
|
||||||
async def patch_event_person_json(
|
async def patch_event_person_json(
|
||||||
event_person_obj: Event_Person_Base,
|
event_person_obj: Event_Person_Base,
|
||||||
event_person_id: str = Query(..., min_length=1, max_length=22),
|
event_person_id: str = Query(..., min_length=1, max_length=22),
|
||||||
@@ -255,7 +255,7 @@ async def patch_event_person_json(
|
|||||||
|
|
||||||
# ### BEGIN ### API Event Person ### get_event_person_obj() ###
|
# ### BEGIN ### API Event Person ### get_event_person_obj() ###
|
||||||
# Working well as of 2021-06-04. Using as a template for other routes.
|
# Working well as of 2021-06-04. Using as a template for other routes.
|
||||||
@router.get('/{event_person_id}', response_model=Resp_Body_Base)
|
@router.get('/event/person/{event_person_id}', response_model=Resp_Body_Base)
|
||||||
async def get_event_person_obj(
|
async def get_event_person_obj(
|
||||||
event_person_id: str = Query(..., min_length=1, max_length=22),
|
event_person_id: str = Query(..., min_length=1, max_length=22),
|
||||||
enabled: str = 'enabled', # For now this covers any included objects or object lists
|
enabled: str = 'enabled', # For now this covers any included objects or object lists
|
||||||
@@ -316,8 +316,58 @@ async def get_event_person_obj(
|
|||||||
# ### END ### API Event ### get_event_person_obj() ###
|
# ### END ### API Event ### get_event_person_obj() ###
|
||||||
|
|
||||||
|
|
||||||
|
# ### BEGIN ### API Event Person Methods ### get_event_registration_event_person_obj_li() ###
|
||||||
|
# Similar to event_registration.py: /event/registration/<id> inc_event_person_list
|
||||||
|
# Updated 2021-08-17
|
||||||
|
@router.get('/event/registration/{event_registration_id}/event/person/list', response_model=Resp_Body_Base)
|
||||||
|
async def get_event_registration_event_person_obj_li(
|
||||||
|
event_registration_id: str = Query(..., min_length=1, max_length=22),
|
||||||
|
enabled: str = 'enabled',
|
||||||
|
limit: int = 1000,
|
||||||
|
inc_address: bool = False,
|
||||||
|
inc_contact: bool = False,
|
||||||
|
inc_event_badge: bool = False,
|
||||||
|
inc_person: bool = False,
|
||||||
|
# inc_user: bool = False,
|
||||||
|
x_account_id: str = Header(...),
|
||||||
|
by_alias: Optional[bool] = True,
|
||||||
|
exclude_unset: Optional[bool] = True,
|
||||||
|
response: Response = Response,
|
||||||
|
):
|
||||||
|
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||||
|
log.debug(locals())
|
||||||
|
|
||||||
|
if event_registration_id := redis_lookup_id_random(record_id_random=event_registration_id, table_name='event_registration'): pass
|
||||||
|
else: return mk_resp(data=None, status_code=404)
|
||||||
|
|
||||||
|
if event_person_rec_list_result := get_event_person_rec_list(
|
||||||
|
for_obj_type = 'event_registration',
|
||||||
|
for_obj_id = event_registration_id,
|
||||||
|
limit = limit,
|
||||||
|
enabled = enabled,
|
||||||
|
):
|
||||||
|
event_person_result_list = []
|
||||||
|
for event_person_rec in event_person_rec_list_result:
|
||||||
|
if load_event_person_result := load_event_person_obj(
|
||||||
|
event_person_id = event_person_rec.get('event_person_id', None),
|
||||||
|
limit = limit,
|
||||||
|
by_alias = by_alias,
|
||||||
|
exclude_unset = exclude_unset,
|
||||||
|
# model_as_dict = model_as_dict,
|
||||||
|
enabled = enabled,
|
||||||
|
inc_person = inc_person,
|
||||||
|
# inc_user = inc_user,
|
||||||
|
):
|
||||||
|
event_person_result_list.append(load_event_person_result)
|
||||||
|
else: event_person_result_list.append(None)
|
||||||
|
return mk_resp(data=event_person_result_list)
|
||||||
|
else: return mk_resp(data=None, status_code=404, response=response) # Not Found
|
||||||
|
# ### END ### API Event Person Methods ### get_event_registration_event_person_obj_li() ###
|
||||||
|
|
||||||
|
|
||||||
# ### BEGIN ### API Event Person Methods ### get_person_event_person_obj_li() ###
|
# ### BEGIN ### API Event Person Methods ### get_person_event_person_obj_li() ###
|
||||||
# Updated 2021-07-12
|
# Updated 2021-07-12
|
||||||
|
# NOT FINISHED YET
|
||||||
@router.get('/person/{person_id}/event/person/list', response_model=Resp_Body_Base)
|
@router.get('/person/{person_id}/event/person/list', response_model=Resp_Body_Base)
|
||||||
async def get_person_event_person_obj_li(
|
async def get_person_event_person_obj_li(
|
||||||
person_id: str = Query(..., min_length=1, max_length=22),
|
person_id: str = Query(..., min_length=1, max_length=22),
|
||||||
@@ -348,4 +398,4 @@ async def get_person_event_person_obj_li(
|
|||||||
else: return mk_resp(data=None, status_code=404)
|
else: return mk_resp(data=None, status_code=404)
|
||||||
|
|
||||||
return mk_resp(data=response_data)
|
return mk_resp(data=response_data)
|
||||||
# ### BEGIN ### API Event Person Methods ### get_person_event_person_obj_li() ###
|
# ### END ### API Event Person Methods ### get_person_event_person_obj_li() ###
|
||||||
|
|||||||
@@ -100,8 +100,11 @@ async def get_event_registration_obj(
|
|||||||
event_registration_id: str = Query(..., min_length=1, max_length=22),
|
event_registration_id: str = Query(..., min_length=1, max_length=22),
|
||||||
enabled: str = 'enabled', # For now this covers any included objects or object lists
|
enabled: str = 'enabled', # For now this covers any included objects or object lists
|
||||||
limit: int = 500, # For now this covers any included objects or object lists
|
limit: int = 500, # For now this covers any included objects or object lists
|
||||||
|
# inc_event_cfg: bool = False,
|
||||||
|
inc_event_person_list: bool = False,
|
||||||
inc_event_registration_cfg: bool = False,
|
inc_event_registration_cfg: bool = False,
|
||||||
inc_event_registration_list: bool = False,
|
# inc_event_registration_list: bool = False,
|
||||||
|
inc_person: bool = False,
|
||||||
x_account_id: str = Header(...),
|
x_account_id: str = Header(...),
|
||||||
by_alias: Optional[bool] = True,
|
by_alias: Optional[bool] = True,
|
||||||
exclude_unset: Optional[bool] = True,
|
exclude_unset: Optional[bool] = True,
|
||||||
@@ -115,6 +118,10 @@ async def get_event_registration_obj(
|
|||||||
|
|
||||||
if event_registration_obj := load_event_registration_obj(
|
if event_registration_obj := load_event_registration_obj(
|
||||||
event_registration_id = event_registration_id,
|
event_registration_id = event_registration_id,
|
||||||
|
inc_event_person_list = inc_event_person_list,
|
||||||
|
inc_event_registration_cfg = inc_event_registration_cfg,
|
||||||
|
# inc_event_registration_list = inc_event_registration_list,
|
||||||
|
inc_person = inc_person,
|
||||||
limit = limit,
|
limit = limit,
|
||||||
by_alias = by_alias,
|
by_alias = by_alias,
|
||||||
exclude_unset = exclude_unset,
|
exclude_unset = exclude_unset,
|
||||||
@@ -127,15 +134,6 @@ async def get_event_registration_obj(
|
|||||||
|
|
||||||
return mk_resp(data=event_registration_obj)
|
return mk_resp(data=event_registration_obj)
|
||||||
|
|
||||||
# obj_type = 'event_registration'
|
|
||||||
# result = get_obj_template(
|
|
||||||
# obj_type=obj_type,
|
|
||||||
# obj_id=event_registration_id,
|
|
||||||
# by_alias=True,
|
|
||||||
# exclude_unset=True,
|
|
||||||
# )
|
|
||||||
# return result
|
|
||||||
|
|
||||||
|
|
||||||
@router.delete('/{obj_id}', response_model=Resp_Body_Base)
|
@router.delete('/{obj_id}', response_model=Resp_Body_Base)
|
||||||
async def delete_event_registration_obj(
|
async def delete_event_registration_obj(
|
||||||
|
|||||||
Reference in New Issue
Block a user