188 lines
6.9 KiB
Python
188 lines
6.9 KiB
Python
import datetime, pytz
|
|
|
|
from typing import Dict, List, Optional, Set, Union
|
|
from pydantic import BaseModel, EmailStr, Field, Json, PrivateAttr, ValidationError, validator
|
|
|
|
from app.db_sql import redis_lookup_id_random
|
|
from app.lib_general import log, logging
|
|
|
|
from app.models.common_field_schema import base_fields, default_num_bytes
|
|
from app.models.contact_models import Contact_Base
|
|
from app.models.event_cfg_models import Event_Cfg_Base
|
|
from app.models.organization_models import Organization_Base
|
|
|
|
|
|
# ### BEGIN ### API Event Person Profile Models ### Event_Person_Profile_Base() ###
|
|
class Event_Person_Profile_Base(BaseModel):
|
|
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
|
log.debug(locals())
|
|
|
|
id_random: Optional[str] = Field(
|
|
**base_fields['event_person_profile_id_random'],
|
|
alias = 'event_person_profile_id_random',
|
|
)
|
|
id: Optional[int] = Field(
|
|
alias = 'event_person_profile_id'
|
|
)
|
|
|
|
account_id_random: Optional[str]
|
|
account_id: Optional[int]
|
|
|
|
contact_id_random: Optional[str]
|
|
contact_id: Optional[int]
|
|
|
|
event_id_random: Optional[str] # Only in view
|
|
event_id: Optional[int] # Only in view
|
|
|
|
event_person_id_random: Optional[str] # Only in view
|
|
event_person_id: Optional[int] # Only in view
|
|
|
|
organization_id_random: Optional[str]
|
|
organization_id: Optional[int]
|
|
|
|
pronouns: Optional[str] # Preferred pronouns
|
|
informal_name: Optional[str]
|
|
|
|
title_names: Optional[str] # Title for generation, official position, or professional or academic qualification, other honorific, or other name prefix
|
|
given_name: Optional[str]
|
|
middle_name: Optional[str]
|
|
family_name: Optional[str]
|
|
designations: Optional[str] # Temporary or long-term designations related to family, relationships, person differentiation (Junior/Senior), location, social status, professional qualifications, legal status, or other name suffix
|
|
|
|
professional_title: Optional[str] # Professional title
|
|
|
|
display_name: Optional[str] # View of display_override. Actual name shown in the directory and other "public" areas
|
|
full_name_override: Optional[str] # Actual name shown in the directory and other "public" areas
|
|
|
|
# BEGIN # Auto created name variations
|
|
full_name: Optional[str] # title_names given_name middle_name family_name designations
|
|
|
|
affiliations: Optional[str] # One or more affiliations with organizations, companies, and other groups
|
|
|
|
tagline: Optional[str]
|
|
biography: Optional[str]
|
|
|
|
email: Optional[str]
|
|
website_url: Optional[str]
|
|
|
|
thumbnail_hosted_file_id: Optional[int]
|
|
thumbnail_hosted_file_id_random: Optional[str]
|
|
thumbnail_path: Optional[str]
|
|
thumbnail_bg_color: Optional[str]
|
|
|
|
# photo_path: Optional[str]
|
|
# photo_bg_color: Optional[str]
|
|
|
|
picture_hosted_file_id: Optional[int]
|
|
picture_hosted_file_id_random: Optional[str]
|
|
picture_path: Optional[str]
|
|
picture_bg_color: Optional[str]
|
|
|
|
about_hosted_file_id: Optional[int]
|
|
about_hosted_file_id_random: Optional[str]
|
|
about_path: Optional[str]
|
|
|
|
email_allowed: Optional[bool]
|
|
email_marketing: Optional[bool]
|
|
email_updates: Optional[bool]
|
|
|
|
show_online: Optional[bool]
|
|
show_printed: Optional[bool]
|
|
|
|
enable: Optional[bool]
|
|
priority: Optional[bool]
|
|
sort: Optional[int]
|
|
group: Optional[str]
|
|
|
|
notes: Optional[str]
|
|
created_on: Optional[datetime.datetime] = None
|
|
updated_on: Optional[datetime.datetime] = None
|
|
|
|
# Including JSON data
|
|
extended_json: Optional[Json]
|
|
|
|
# Including other related objects
|
|
contact: Optional[Contact_Base]
|
|
event_cfg: Optional[Event_Cfg_Base] = Field(
|
|
alias = 'cfg',
|
|
)
|
|
organization: Optional[Organization_Base]
|
|
|
|
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
|
|
|
#@validator('event_person_profile_id_random', always=True)
|
|
def event_person_profile_id_random_copy(cls, v, values, **kwargs):
|
|
if values['id_random']:
|
|
return values['id_random']
|
|
return None
|
|
|
|
@validator('id', always=True)
|
|
def event_person_profile_id_lookup(cls, v, values, **kwargs):
|
|
if isinstance(v, int) and v > 0: return v
|
|
elif id_random := values.get('id_random'):
|
|
return redis_lookup_id_random(record_id_random=id_random, table_name='event_person_profile')
|
|
return None
|
|
|
|
@validator('account_id', always=True)
|
|
def account_id_lookup(cls, v, values, **kwargs):
|
|
if isinstance(v, int) and v > 0: return v
|
|
elif id_random := values.get('account_id_random'):
|
|
return redis_lookup_id_random(record_id_random=id_random, table_name='account')
|
|
return None
|
|
|
|
@validator('contact_id', always=True)
|
|
def contact_id_lookup(cls, v, values, **kwargs):
|
|
if isinstance(v, int) and v > 0: return v
|
|
elif id_random := values.get('contact_id_random'):
|
|
return redis_lookup_id_random(record_id_random=id_random, table_name='contact')
|
|
return None
|
|
|
|
@validator('organization_id', always=True)
|
|
def organization_id_lookup(cls, v, values, **kwargs):
|
|
if isinstance(v, int) and v > 0: return v
|
|
elif id_random := values.get('organization_id_random'):
|
|
return redis_lookup_id_random(record_id_random=id_random, table_name='organization')
|
|
return None
|
|
|
|
@validator('thumbnail_hosted_file_id', always=True)
|
|
def thumbnail_hosted_file_id_lookup(cls, v, values, **kwargs):
|
|
log.setLevel(logging.WARNING)
|
|
log.debug(locals())
|
|
|
|
if values.get('thumbnail_hosted_file_id_random', None):
|
|
return redis_lookup_id_random(record_id_random=values['thumbnail_hosted_file_id_random'], table_name='thumbnail_hosted_file')
|
|
return None
|
|
|
|
@validator('picture_hosted_file_id', always=True)
|
|
def picture_hosted_file_id_lookup(cls, v, values, **kwargs):
|
|
log.setLevel(logging.WARNING)
|
|
log.debug(locals())
|
|
|
|
if values.get('picture_hosted_file_id_random', None):
|
|
return redis_lookup_id_random(record_id_random=values['picture_hosted_file_id_random'], table_name='picture_hosted_file')
|
|
return None
|
|
|
|
@validator('about_hosted_file_id', always=True)
|
|
def about_hosted_file_id_lookup(cls, v, values, **kwargs):
|
|
log.setLevel(logging.WARNING)
|
|
log.debug(locals())
|
|
|
|
if values.get('about_hosted_file_id_random', None):
|
|
return redis_lookup_id_random(record_id_random=values['about_hosted_file_id_random'], table_name='about_hosted_file')
|
|
return None
|
|
|
|
class Config:
|
|
underscore_attrs_are_private = True
|
|
allow_population_by_field_name = True
|
|
fields = base_fields
|
|
|
|
|
|
class Event_Person_Profile_Base_Up(Event_Person_Profile_Base):
|
|
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
|
log.debug(locals())
|
|
|
|
|
|
# Including JSON data
|
|
extended_json: Optional[str]
|
|
# ### END ### API Event Person Profile Models ### Event_Person_Profile_Base() ###
|