Added new fields for posts related. Also cleaned up some of the code and logging.
This commit is contained in:
@@ -11,7 +11,7 @@ from app.models.common_field_schema import base_fields, default_num_bytes
|
||||
|
||||
# ### BEGIN ### API Archive Content Models ### Archive_Content_Base() ###
|
||||
class Archive_Content_Base(BaseModel):
|
||||
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# def testing(test_var=None):
|
||||
|
||||
@@ -12,6 +12,7 @@ from app.models.user_models import User_Base
|
||||
|
||||
|
||||
# ### BEGIN ### API Post Comment Models ### Post_Comment_Base() ###
|
||||
# Updated 2024-11-13
|
||||
class Post_Comment_Base(BaseModel):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
@@ -41,7 +42,11 @@ class Post_Comment_Base(BaseModel):
|
||||
anonymous: Optional[bool]
|
||||
full_name: Optional[str]
|
||||
email: Optional[str]
|
||||
#timezone: Optional[str]
|
||||
notify: Optional[bool]
|
||||
# timezone: Optional[str]
|
||||
|
||||
linked_li_json: Optional[Union[Json, None]]
|
||||
# cfg_json: Optional[Union[Json, None]]
|
||||
|
||||
enable: Optional[bool]
|
||||
|
||||
@@ -61,49 +66,40 @@ class Post_Comment_Base(BaseModel):
|
||||
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
||||
|
||||
#@validator('post_comment_id_random', always=True)
|
||||
def post_comment_id_random_copy(cls, v, values, **kwargs):
|
||||
log.setLevel(logging.WARNING)
|
||||
log.debug(locals())
|
||||
# def post_comment_id_random_copy(cls, v, values, **kwargs):
|
||||
# log.setLevel(logging.WARNING)
|
||||
# log.debug(locals())
|
||||
|
||||
if values['id_random']:
|
||||
return values['id_random']
|
||||
return None
|
||||
# if values['id_random']:
|
||||
# return values['id_random']
|
||||
# return None
|
||||
|
||||
@validator('id', always=True)
|
||||
def post_comment_id_lookup(cls, v, values, **kwargs):
|
||||
log.setLevel(logging.WARNING)
|
||||
log.debug(locals())
|
||||
|
||||
if values['id_random']:
|
||||
log.debug(values['id_random'])
|
||||
return redis_lookup_id_random(record_id_random=values['id_random'], table_name='post_comment')
|
||||
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='post_comment')
|
||||
return None
|
||||
|
||||
@validator('post_id', always=True)
|
||||
def post_id_lookup(cls, v, values, **kwargs):
|
||||
log.setLevel(logging.WARNING)
|
||||
log.debug(locals())
|
||||
|
||||
if values['post_id_random']:
|
||||
return redis_lookup_id_random(record_id_random=values['post_id_random'], table_name='post')
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('post_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='post')
|
||||
return None
|
||||
|
||||
@validator('person_id', always=True)
|
||||
def person_id_lookup(cls, v, values, **kwargs):
|
||||
log.setLevel(logging.WARNING)
|
||||
log.debug(locals())
|
||||
|
||||
if values.get('person_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=values['person_id_random'], table_name='person')
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('person_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='person')
|
||||
return None
|
||||
|
||||
@validator('user_id', always=True)
|
||||
def user_id_lookup(cls, v, values, **kwargs):
|
||||
log.setLevel(logging.WARNING)
|
||||
log.debug(locals())
|
||||
|
||||
if values.get('user_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=values['user_id_random'], table_name='user')
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('user_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='user')
|
||||
return None
|
||||
|
||||
class Config:
|
||||
|
||||
@@ -50,7 +50,8 @@ class Post_Base(BaseModel):
|
||||
anonymous: Optional[bool]
|
||||
full_name: Optional[str]
|
||||
email: Optional[str]
|
||||
timezone: Optional[str]
|
||||
notify: Optional[bool]
|
||||
# timezone: Optional[str]
|
||||
|
||||
post_comment_count: Optional[int] # post comment count using view
|
||||
|
||||
@@ -68,6 +69,9 @@ class Post_Base(BaseModel):
|
||||
archive_on: Optional[datetime.datetime] = None
|
||||
archive: Optional[bool]
|
||||
|
||||
linked_li_json: Optional[Union[Json, None]]
|
||||
cfg_json: Optional[Union[Json, None]]
|
||||
|
||||
enable: Optional[bool]
|
||||
|
||||
hide: Optional[bool]
|
||||
|
||||
Reference in New Issue
Block a user