Updates to start using the new Journals module.
This commit is contained in:
@@ -333,6 +333,40 @@ obj_type_kv_li = {
|
|||||||
'hide', 'priority', 'sort', 'group', 'notes', 'created_on', 'updated_on',
|
'hide', 'priority', 'sort', 'group', 'notes', 'created_on', 'updated_on',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
# Updated 2025-03-16
|
||||||
|
'journal': {
|
||||||
|
'tbl': 'journal',
|
||||||
|
'tbl_default': 'v_journal',
|
||||||
|
'tbl_update': 'journal',
|
||||||
|
'mdl': Journal_Base,
|
||||||
|
'mdl_default': Journal_Base,
|
||||||
|
'mdl_in': Journal_Base,
|
||||||
|
'mdl_out': Journal_Base,
|
||||||
|
'exp_default': [
|
||||||
|
'journal_id_random',
|
||||||
|
# 'account_id_random',
|
||||||
|
'title', 'description',
|
||||||
|
# 'enable', 'hide', 'priority', 'sort', 'group', 'notes',
|
||||||
|
# 'created_on', 'updated_on',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
# Updated 2025-03-16
|
||||||
|
'journal_entry': {
|
||||||
|
'tbl': 'journal_entry',
|
||||||
|
'tbl_default': 'v_journal_entry',
|
||||||
|
'tbl_update': 'journal_entry',
|
||||||
|
'mdl': Journal_Entry_Base,
|
||||||
|
'mdl_default': Journal_Entry_Base,
|
||||||
|
'mdl_in': Journal_Entry_Base,
|
||||||
|
'mdl_out': Journal_Entry_Base,
|
||||||
|
'exp_default': [
|
||||||
|
'journal_entry_id_random',
|
||||||
|
# 'account_id_random', 'journal_id_random',
|
||||||
|
# 'title', 'content',
|
||||||
|
# 'enable', 'hide', 'priority', 'sort', 'group', 'notes',
|
||||||
|
# 'created_on', 'updated_on',
|
||||||
|
],
|
||||||
|
},
|
||||||
# Updated 2024-09-27
|
# Updated 2024-09-27
|
||||||
'post': {
|
'post': {
|
||||||
'tbl': 'post',
|
'tbl': 'post',
|
||||||
@@ -507,8 +541,8 @@ obj_type_kv_li['event_track'] = {'table_name': 'v_event_track', 'tbl_name_update
|
|||||||
|
|
||||||
obj_type_kv_li['grant'] = {'table_name': 'v_grant', 'tbl_name_update': 'grant', 'base_name': Grant_Base}
|
obj_type_kv_li['grant'] = {'table_name': 'v_grant', 'tbl_name_update': 'grant', 'base_name': Grant_Base}
|
||||||
|
|
||||||
obj_type_kv_li['journal'] = {'table_name': 'v_journal', 'tbl_name_update': 'journal', 'base_name': Journal_Base}
|
# obj_type_kv_li['journal'] = {'table_name': 'v_journal', 'tbl_name_update': 'journal', 'base_name': Journal_Base}
|
||||||
obj_type_kv_li['journal_entry'] = {'table_name': 'v_journal_entry', 'tbl_name_update': 'journal_entry', 'base_name': Journal_Entry_Base}
|
# obj_type_kv_li['journal_entry'] = {'table_name': 'v_journal_entry', 'tbl_name_update': 'journal_entry', 'base_name': Journal_Entry_Base}
|
||||||
#obj_type_kv_li['log'] = {'table_name': 'log', 'tbl_name_update': 'log', 'base_name': Log_Base} #'v_log'
|
#obj_type_kv_li['log'] = {'table_name': 'log', 'tbl_name_update': 'log', 'base_name': Log_Base} #'v_log'
|
||||||
|
|
||||||
obj_type_kv_li['membership_cfg'] = {'table_name': 'v_membership_cfg', 'tbl_name_update': 'membership_cfg', 'base_name': Membership_Cfg_Base}
|
obj_type_kv_li['membership_cfg'] = {'table_name': 'v_membership_cfg', 'tbl_name_update': 'membership_cfg', 'base_name': Membership_Cfg_Base}
|
||||||
|
|||||||
@@ -25,11 +25,28 @@ class Journal_Entry_Base(BaseModel):
|
|||||||
journal_id_random: Optional[str]
|
journal_id_random: Optional[str]
|
||||||
journal_id: Optional[int]
|
journal_id: Optional[int]
|
||||||
|
|
||||||
|
external_id: Optional[str] # ID generated by external system (should be stable and not change)
|
||||||
|
import_id: Optional[str] # Used for import purposes to track the source of the data
|
||||||
code: Optional[str]
|
code: Optional[str]
|
||||||
|
|
||||||
|
for_type: Optional[str] # 'person', 'user', 'account', etc
|
||||||
|
for_id: Optional[int]
|
||||||
|
for_id_random: Optional[str]
|
||||||
|
|
||||||
name: Optional[str]
|
name: Optional[str]
|
||||||
summary: Optional[str]
|
summary: Optional[str]
|
||||||
|
outline: Optional[str]
|
||||||
|
|
||||||
content: Optional[str]
|
content: Optional[str]
|
||||||
|
content_html: Optional[str]
|
||||||
|
content_json: Optional[Union[Json, None]]
|
||||||
|
|
||||||
|
start_datetime: Optional[datetime.datetime]
|
||||||
|
end_datetime: Optional[datetime.datetime]
|
||||||
|
timezone: Optional[str] # = 'UTC' # Default to UTC
|
||||||
|
|
||||||
|
alert: Optional[bool] = False
|
||||||
|
alert_msg: Optional[str] = None
|
||||||
|
|
||||||
private: Optional[bool] = True
|
private: Optional[bool] = True
|
||||||
public: Optional[bool] = False
|
public: Optional[bool] = False
|
||||||
@@ -41,7 +58,12 @@ class Journal_Entry_Base(BaseModel):
|
|||||||
archive_on: Optional[datetime.datetime]
|
archive_on: Optional[datetime.datetime]
|
||||||
archive: Optional[bool]
|
archive: Optional[bool]
|
||||||
|
|
||||||
data_json: Optional[Json]
|
data_json: Optional[Union[Json, None]] # Used to store additional data for the journal
|
||||||
|
|
||||||
|
passcode_read: Optional[str] # Used to read the journal entry
|
||||||
|
passcode_read_expire: Optional[int] # Number of seconds to expire the read passcode
|
||||||
|
passcode_write: Optional[str] # Used to write to the journal entry
|
||||||
|
passcode_write_expire: Optional[int] # Number of seconds to expire the write passcode
|
||||||
|
|
||||||
enable: Optional[bool]
|
enable: Optional[bool]
|
||||||
hide: Optional[bool]
|
hide: Optional[bool]
|
||||||
@@ -53,25 +75,24 @@ class Journal_Entry_Base(BaseModel):
|
|||||||
created_on: Optional[datetime.datetime] = None
|
created_on: Optional[datetime.datetime] = None
|
||||||
updated_on: Optional[datetime.datetime] = None
|
updated_on: Optional[datetime.datetime] = None
|
||||||
|
|
||||||
|
# Including other related objects
|
||||||
|
# This is only for convenience. Probably going to keep unless it causes a problem.
|
||||||
|
file_count: Optional[int]
|
||||||
|
|
||||||
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
||||||
|
|
||||||
@validator('id', always=True)
|
@validator('id', always=True)
|
||||||
def journal_entry_id_lookup(cls, v, values, **kwargs):
|
def journal_entry_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='journal_entry')
|
||||||
if values['id_random']:
|
|
||||||
log.debug(values['id_random'])
|
|
||||||
return redis_lookup_id_random(record_id_random=values['id_random'], table_name='journal_entry')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('journal_id', always=True)
|
@validator('journal_id', always=True)
|
||||||
def journal_id_lookup(cls, v, values, **kwargs):
|
def journal_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('journal_id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='journal')
|
||||||
if values['journal_id_random']:
|
|
||||||
return redis_lookup_id_random(record_id_random=values['journal_id_random'], table_name='journal')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from app.lib_general import log, logging
|
|||||||
|
|
||||||
from app.models.common_field_schema import base_fields, default_num_bytes
|
from app.models.common_field_schema import base_fields, default_num_bytes
|
||||||
from app.models.journal_entry_models import Journal_Entry_Base
|
from app.models.journal_entry_models import Journal_Entry_Base
|
||||||
|
# from app.models.person_models import Person_Base
|
||||||
|
|
||||||
|
|
||||||
# ### BEGIN ### API Journal Models ### Journal_Base() ###
|
# ### BEGIN ### API Journal Models ### Journal_Base() ###
|
||||||
@@ -31,8 +32,16 @@ class Journal_Base(BaseModel):
|
|||||||
user_id_random: Optional[str]
|
user_id_random: Optional[str]
|
||||||
user_id: Optional[int]
|
user_id: Optional[int]
|
||||||
|
|
||||||
|
external_id: Optional[str] # ID generated by external system (should be stable and not change)
|
||||||
|
import_id: Optional[str] # Used for import purposes to track the source of the data
|
||||||
code: Optional[str]
|
code: Optional[str]
|
||||||
|
|
||||||
|
for_type: Optional[str] # 'person', 'user', 'account', etc
|
||||||
|
for_id: Optional[int]
|
||||||
|
for_id_random: Optional[str]
|
||||||
|
|
||||||
|
type_code: Optional[str] # 'log', 'tracking', 'personal', 'professional', etc
|
||||||
|
|
||||||
default_private: Optional[bool]
|
default_private: Optional[bool]
|
||||||
default_public: Optional[bool]
|
default_public: Optional[bool]
|
||||||
default_personal: Optional[bool]
|
default_personal: Optional[bool]
|
||||||
@@ -41,8 +50,34 @@ class Journal_Base(BaseModel):
|
|||||||
private_passcode: Optional[str]
|
private_passcode: Optional[str]
|
||||||
public_passcode: Optional[str]
|
public_passcode: Optional[str]
|
||||||
|
|
||||||
|
passcode_read: Optional[str] # Used to read the journal
|
||||||
|
passcode_read_expire: Optional[int] # Number of seconds to expire the read passcode
|
||||||
|
passcode_write: Optional[str] # Used to write to the journal
|
||||||
|
passcode_write_expire: Optional[int] # Number of seconds to expire the write passcode
|
||||||
|
|
||||||
name: Optional[str]
|
name: Optional[str]
|
||||||
summary: Optional[str]
|
summary: Optional[str]
|
||||||
|
outline: Optional[str]
|
||||||
|
|
||||||
|
description: Optional[str]
|
||||||
|
description_html: Optional[str]
|
||||||
|
description_json: Optional[str]
|
||||||
|
|
||||||
|
start_datetime: Optional[datetime.datetime]
|
||||||
|
end_datetime: Optional[datetime.datetime]
|
||||||
|
timezone: Optional[str] # = 'UTC' # Default to UTC
|
||||||
|
|
||||||
|
alert: Optional[bool] = False
|
||||||
|
alert_msg: Optional[str] = None
|
||||||
|
|
||||||
|
meta_data: Optional[str]
|
||||||
|
access_key: Optional[str]
|
||||||
|
|
||||||
|
sort_by: Optional[str]
|
||||||
|
sort_by_desc: Optional[bool]
|
||||||
|
|
||||||
|
cfg_json: Optional[Union[Json, None]]
|
||||||
|
data_json: Optional[Union[Json, None]] # Used to store additional data for the journal
|
||||||
|
|
||||||
enable: Optional[bool]
|
enable: Optional[bool]
|
||||||
hide: Optional[bool]
|
hide: Optional[bool]
|
||||||
@@ -56,17 +91,28 @@ class Journal_Base(BaseModel):
|
|||||||
|
|
||||||
# Including other related objects
|
# Including other related objects
|
||||||
journal_entry_list: Optional[list[Journal_Entry_Base]] # Journal_Entry_Base()
|
journal_entry_list: Optional[list[Journal_Entry_Base]] # Journal_Entry_Base()
|
||||||
|
# This is only for convenience. Probably going to keep unless it causes a problem.
|
||||||
|
file_count: Optional[int] # Only files directly under the journal
|
||||||
|
file_count_all: Optional[int] # All files under a journal and entries
|
||||||
|
|
||||||
|
# person: Optional[Person_Base]
|
||||||
|
person_external_id: Optional[str]
|
||||||
|
person_given_name: Optional[str] = None
|
||||||
|
person_family_name: Optional[str] = None
|
||||||
|
person_full_name: Optional[str] = None
|
||||||
|
person_primary_email: Optional[str] = None
|
||||||
|
person_passcode: Optional[str] = None
|
||||||
|
|
||||||
|
# person: Optional[Person_Base]
|
||||||
|
# user: Optional[User_Base]
|
||||||
|
|
||||||
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
||||||
|
|
||||||
@validator('id', always=True)
|
@validator('id', always=True)
|
||||||
def journal_id_lookup(cls, v, values, **kwargs):
|
def journal_id_lookup(cls, v, values, **kwargs):
|
||||||
log.setLevel(logging.WARNING)
|
if isinstance(v, int) and v > 0: return v
|
||||||
log.debug(locals())
|
elif id_random := values.get('id_random'):
|
||||||
|
return redis_lookup_id_random(record_id_random=id_random, table_name='journal')
|
||||||
if values['id_random']:
|
|
||||||
log.debug(values['id_random'])
|
|
||||||
return redis_lookup_id_random(record_id_random=values['id_random'], table_name='journal')
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@validator('person_id', always=True)
|
@validator('person_id', always=True)
|
||||||
|
|||||||
@@ -168,8 +168,8 @@ obj_type_li['event_track'] = {'table_name': 'v_event_track', 'tbl_name_update':
|
|||||||
|
|
||||||
obj_type_li['grant'] = {'table_name': 'v_grant', 'tbl_name_update': 'grant', 'base_name': Grant_Base}
|
obj_type_li['grant'] = {'table_name': 'v_grant', 'tbl_name_update': 'grant', 'base_name': Grant_Base}
|
||||||
|
|
||||||
obj_type_li['journal'] = {'table_name': 'v_journal', 'tbl_name_update': 'journal', 'base_name': Journal_Base}
|
obj_type_li['journal'] = {'table_name': 'v_journal', 'table_name_alt': 'v_journal', 'tbl_name_update': 'journal', 'base_name': Journal_Base}
|
||||||
obj_type_li['journal_entry'] = {'table_name': 'v_journal_entry', 'tbl_name_update': 'journal_entry', 'base_name': Journal_Entry_Base}
|
obj_type_li['journal_entry'] = {'table_name': 'v_journal_entry', 'table_name_alt': 'v_journal_entry', 'tbl_name_update': 'journal_entry', 'base_name': Journal_Entry_Base}
|
||||||
#obj_type_li['log'] = {'table_name': 'log', 'tbl_name_update': 'log', 'base_name': Log_Base} #'v_log'
|
#obj_type_li['log'] = {'table_name': 'log', 'tbl_name_update': 'log', 'base_name': Log_Base} #'v_log'
|
||||||
|
|
||||||
obj_type_li['membership_cfg'] = {'table_name': 'v_membership_cfg', 'tbl_name_update': 'membership_cfg', 'base_name': Membership_Cfg_Base}
|
obj_type_li['membership_cfg'] = {'table_name': 'v_membership_cfg', 'tbl_name_update': 'membership_cfg', 'base_name': Membership_Cfg_Base}
|
||||||
|
|||||||
Reference in New Issue
Block a user