Planning out a core object model

This commit is contained in:
Scott Idem
2021-11-18 21:20:41 -05:00
parent dee958aa2b
commit f71bd74aa0
3 changed files with 71 additions and 12 deletions

View File

@@ -11,23 +11,81 @@ from app.common_field_schema import base_fields, default_num_bytes
class Core_Object_Base(BaseModel):
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
obj_type: str
obj_id_random: str # alias this one based on obj_type?
obj_id_rand: str # alias this one based on obj_type?
obj_id: int # alias this one?
obj_name: Optional[str]
id_random: str # alias this one?
# The actual database record ID
id: int # alias this one?
# id_random: str # alias this one?
account_id_random: Optional[str]
account_id: Optional[str]
# This is what used to be id_random
oid: str # obj_id or object_id or id_random
# The object type name
# Examples: contact, person, user, event, event_file, membership, membership_person
otype: str # obj_type or object_type or type
code: str # Human friendly unique ID per account and object type
external_id: str # External service/system/client unique ID per account and object type
import_id: str # In theory this should not be needed. Use to supplement external_id
account_oid: Optional[str]
account_id: Optional[int]
user_id: Optional[int] # Owner/Creator user???
group_id: Optional[int] # Owner/Creator group???
# The current record the object is linked to for the data.
record_id: int
# for_type: Optional[str]
# for_id: Optional[int]
# obj_id_random: str # alias this one based on obj_type?
# obj_id_rand: str # alias this one based on obj_type?
# Common information fields
name: Optional[str]
summary: Optional[str]
description: Optional[str]
# Including JSON data
other_json: Optional[Json]
meta_json: Optional[Json]
# For moderation:
status: Optional[int]
review: Optional[bool] # ready for review or not ready for review
approve: Optional[bool] # approved or not approved
ready: Optional[bool]
enable: Optional[bool] # Manager override to fully enable/disable
enable_from: Optional[datetime.datetime] = None
enable_to: Optional[datetime.datetime] = None
# The user access levels
# 1 super, 2 manager
# 3 administrator, 4 support, 5 assistant, 6 trusted
# 7 verified, 8 provisional
# 9 authenticated, 10 public (shared)
# 11 anonymous (not logged in)
access_level: Optional[int]
hide: Optional[bool] # Administrator and others can show/hide. Still accessible, just not shown in lists.
hide_from: Optional[datetime.datetime] = None
hide_to: Optional[datetime.datetime] = None
public: Optional[bool]
public_hide: Optional[bool] # Still accessible, just not shown in lists.
priority: Optional[bool] # Sorted first
sort: Optional[int] # Sorted second
group: Optional[str] # Group
notes: Optional[str]
created_on: Optional[datetime.datetime] = None
updated_on: Optional[datetime.datetime] = None
created_on: Optional[datetime.datetime]
updated_on: Optional[datetime.datetime]
versioned_on: Optional[datetime.datetime]
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)