General clean up. Work on abstracts and websockets
This commit is contained in:
@@ -6,7 +6,67 @@ from pydantic import BaseModel, EmailStr, Field, Json, PrivateAttr, ValidationEr
|
||||
from app.db_sql import redis_lookup_id_random
|
||||
from app.lib_general import log, logging
|
||||
|
||||
from app.common_field_schema import base_fields, default_num_bytes
|
||||
# from app.common_field_schema import base_fields, default_num_bytes
|
||||
|
||||
class Core_Std_Obj_Base(BaseModel):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
id_random: Optional[str] = Field(
|
||||
alias = 'obj_id_random', # Not the DB field name
|
||||
)
|
||||
id: Optional[int] = Field(
|
||||
alias = 'obj_id' # Not the DB field name
|
||||
)
|
||||
|
||||
# id: int
|
||||
oid: Optional[str] = None
|
||||
otype: Optional[str] = None
|
||||
|
||||
code: Optional[str] = None
|
||||
|
||||
name: Optional[str] = None
|
||||
|
||||
# Including JSON data
|
||||
data_json: Optional[Json]
|
||||
other_json: Optional[Json]
|
||||
meta_json: Optional[Json]
|
||||
|
||||
# For moderation:
|
||||
enable: Optional[bool] # Manager override to fully enable/disable
|
||||
enable_from: Optional[datetime.datetime] = None
|
||||
enable_to: Optional[datetime.datetime] = None
|
||||
|
||||
status: Optional[int]
|
||||
review: Optional[bool] # ready for review or not ready for review
|
||||
approve: Optional[bool] # approved or not approved
|
||||
ready: Optional[bool]
|
||||
archive: Optional[bool]
|
||||
|
||||
hide: Optional[bool]
|
||||
priority: Optional[bool]
|
||||
sort: Optional[int]
|
||||
group: Optional[str]
|
||||
|
||||
notes: Optional[str]
|
||||
|
||||
xyz: Optional[str]
|
||||
|
||||
created_on: Optional[datetime.datetime] = None
|
||||
updated_on: Optional[datetime.datetime] = None
|
||||
|
||||
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
||||
|
||||
@validator('oid', always=True)
|
||||
def id_random_to_oid(cls, v, values, **kwargs):
|
||||
if isinstance(v, str):
|
||||
log.info('Got oid value!')
|
||||
return v
|
||||
elif id_random := values.get('id_random'):
|
||||
log.info('Got id_random value!')
|
||||
return id_random
|
||||
# return redis_lookup_id_random(record_id_random=id_random, table_name=otype)
|
||||
return None
|
||||
|
||||
|
||||
class Core_Object_Base(BaseModel):
|
||||
|
||||
@@ -8,7 +8,8 @@ from app.lib_general import log, logging
|
||||
|
||||
from app.models.common_field_schema import base_fields, default_num_bytes
|
||||
|
||||
#from app.models.event_models import Event_Base
|
||||
from app.models.core_object_models import Core_Std_Obj_Base
|
||||
# from app.models.event_models import Event_Base
|
||||
# from app.models.event_person_models import Event_Person_Base
|
||||
# from app.models.event_presentation_models import Event_Presentation_Base
|
||||
#from app.models.event_presenter_models import Event_Presenter_Base # This creates an import loop
|
||||
@@ -65,13 +66,15 @@ class Event_Abstract_Base(BaseModel):
|
||||
group: Optional[str]
|
||||
|
||||
notes: Optional[str]
|
||||
|
||||
created_on: Optional[datetime.datetime] = None
|
||||
updated_on: Optional[datetime.datetime] = None
|
||||
|
||||
# Including other related objects
|
||||
#event: Optional[Event_Base]
|
||||
# event: Optional[Event_Base]
|
||||
event_file_list: Optional[list] # Optional[Event_File_Base]
|
||||
# event_person: Optional[Event_Person_Base]
|
||||
event_person: Optional[dict]
|
||||
# event_presentation: Optional[Event_Presentation_Base]
|
||||
#event_presenter: Optional[Event_Presenter_Base] # This creates an import loop
|
||||
event_presenter_list: Optional[list] # Optional[Event_Presenter_Base]
|
||||
@@ -138,3 +141,137 @@ class Event_Abstract_Base(BaseModel):
|
||||
allow_population_by_field_name = True
|
||||
fields = base_fields
|
||||
# ### END ### API Event Abstract Models ### Event_Abstract_Base() ###
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Abstract Models ### Event_Abstract_Base() ###
|
||||
# Update 2023-03-22
|
||||
class Event_Abstract_Base_New(Core_Std_Obj_Base):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# id_random: Optional[str] = Field(
|
||||
# alias = 'event_abstract_id_random',
|
||||
# )
|
||||
|
||||
event_id_random: Optional[str]
|
||||
event_id: Optional[int]
|
||||
|
||||
event_person_id: Optional[int]
|
||||
|
||||
event_session_id: Optional[int]
|
||||
|
||||
event_person_id_random: Optional[str]
|
||||
|
||||
event_presentation_id_random: Optional[str]
|
||||
|
||||
event_presenter_id_random: Optional[str]
|
||||
|
||||
event_session_id_random: Optional[str]
|
||||
|
||||
# event_track_id_random: Optional[str]
|
||||
|
||||
poc_event_person_id_random: Optional[str] # Maybe change this to primary_event_person?
|
||||
|
||||
description: Optional[str]
|
||||
abstract: Optional[str]
|
||||
|
||||
class Config:
|
||||
underscore_attrs_are_private = True
|
||||
allow_population_by_field_name = True
|
||||
fields = base_fields
|
||||
# ### END ### API Event Abstract Models ### Event_Abstract_Base() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Abstract Models ### Event_Abstract_In() ###
|
||||
# Update 2023-03-22
|
||||
class Event_Abstract_In(Event_Abstract_Base_New):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
id: Optional[int] = Field(
|
||||
alias = 'event_abstract_id'
|
||||
)
|
||||
|
||||
event_id: Optional[int]
|
||||
|
||||
event_person_id: Optional[int]
|
||||
|
||||
event_session_id: Optional[int]
|
||||
|
||||
|
||||
@validator('id', always=True)
|
||||
def event_abstract_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_abstract')
|
||||
return None
|
||||
|
||||
@validator('event_id', always=True)
|
||||
def event_id_lookup(cls, v, values, **kwargs):
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('event_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='event')
|
||||
return None
|
||||
|
||||
@validator('event_person_id', always=True)
|
||||
def event_person_id_lookup(cls, v, values, **kwargs):
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('event_person_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='event_person')
|
||||
return None
|
||||
|
||||
# @validator('event_presentation_id', always=True)
|
||||
# def event_presentation_id_lookup(cls, v, values, **kwargs):
|
||||
# if isinstance(v, int) and v > 0: return v
|
||||
# elif id_random := values.get('event_presentation_id_random'):
|
||||
# return redis_lookup_id_random(record_id_random=id_random, table_name='event_presentation')
|
||||
# return None
|
||||
|
||||
# @validator('event_presenter_id', always=True)
|
||||
# def event_presenter_id_lookup(cls, v, values, **kwargs):
|
||||
# if isinstance(v, int) and v > 0: return v
|
||||
# elif id_random := values.get('event_presenter_id_random'):
|
||||
# return redis_lookup_id_random(record_id_random=id_random, table_name='event_presenter')
|
||||
# return None
|
||||
|
||||
@validator('event_session_id', always=True)
|
||||
def event_session_id_lookup(cls, v, values, **kwargs):
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('event_session_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='event_session')
|
||||
return None
|
||||
|
||||
# @validator('poc_event_person_id', always=True)
|
||||
# def poc_event_person_id_lookup(cls, v, values, **kwargs):
|
||||
# log.setLevel(logging.WARNING)
|
||||
# log.debug(locals())
|
||||
|
||||
# if values['poc_event_person_id_random']:
|
||||
# return redis_lookup_id_random(record_id_random=values['poc_event_person_id_random'], table_name='poc_event_person')
|
||||
# return None
|
||||
# ### END ### API Event Abstract Models ### Event_Abstract_In() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Event Abstract Models ### Event_Abstract_Ext() ###
|
||||
# Update 2023-03-22
|
||||
class Event_Abstract_Ext(Event_Abstract_Base_New):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# Including other related objects
|
||||
# event: Optional[Event_Base]
|
||||
event_file_list: Optional[list] # Optional[Event_File_Base]
|
||||
# from app.models.event_person_models import Event_Person_Base
|
||||
# event_person: Optional[Event_Person_Base]
|
||||
event_person: Optional[dict]
|
||||
# event_presentation: Optional[Event_Presentation_Base]
|
||||
#event_presenter: Optional[Event_Presenter_Base] # This creates an import loop
|
||||
# event_presenter_list: Optional[list] # Optional[Event_Presenter_Base]
|
||||
# event_session: Optional[Event_Session_Base]
|
||||
# event_track: Optional[Event_Track_Base]
|
||||
# poc_event_person: Optional[Event_Person_Base] # Maybe change this to primary_event_person?
|
||||
# poc_person: Optional[Person_Base] # Maybe change this to primary_person?
|
||||
# ### END ### API Event Abstract Models ### Event_Abstract_Ext() ###
|
||||
|
||||
@@ -8,7 +8,7 @@ from app.lib_general import log, logging
|
||||
|
||||
from app.models.common_field_schema import base_fields, default_num_bytes
|
||||
# from app.models.event_models import Event_Base # Causes an import loop
|
||||
from app.models.event_abstract_models import Event_Abstract_Base
|
||||
# from app.models.event_abstract_models import Event_Abstract_Base
|
||||
from app.models.event_badge_models import Event_Badge_Base
|
||||
# from app.models.event_exhibit_tracking_models import Event_Exhibit_Tracking_Base # Causes an import loop
|
||||
from app.models.event_person_profile_models import Event_Person_Profile_Base
|
||||
@@ -114,7 +114,7 @@ class Event_Person_Base(BaseModel):
|
||||
|
||||
# Including other related objects
|
||||
# event: Optional[Event_Base] # Causes an import loop
|
||||
event_abstract_list: Optional[list[Event_Abstract_Base]] # Use event_person_detail table. An event_person record can be linked to one or more abstracts
|
||||
# event_abstract_list: Optional[list[Event_Abstract_Base]] # Use event_person_detail table. An event_person record can be linked to one or more abstracts
|
||||
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
|
||||
|
||||
@@ -39,8 +39,10 @@ def mk_resp(
|
||||
status_name: str = '',
|
||||
success: bool = True,
|
||||
details: str = '',
|
||||
include: dict = None,
|
||||
exclude: dict = None,
|
||||
by_alias: bool = True,
|
||||
exclude_unset: bool = True,
|
||||
exclude_unset: bool = False,
|
||||
response: Response = None
|
||||
) -> dict:
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
@@ -63,7 +65,7 @@ def mk_resp(
|
||||
data_out = { 'result': data }
|
||||
else: # Assuming it is still and object. This should be improved. Example model type: "<class 'app.models.account_models.Account_Base'>"
|
||||
log.info('Data type is other')
|
||||
data_out = data.dict(by_alias=by_alias, exclude_unset=exclude_unset)
|
||||
data_out = data.dict(include=include, exclude=exclude, by_alias=by_alias, exclude_unset=exclude_unset)
|
||||
# log.debug(data_out)
|
||||
|
||||
resp_body = {}
|
||||
|
||||
Reference in New Issue
Block a user