Planning out a core object model
This commit is contained in:
@@ -29,6 +29,7 @@ class Account_Cfg_Base(BaseModel):
|
|||||||
|
|
||||||
account_code: Optional[str]
|
account_code: Optional[str]
|
||||||
account_name: Optional[str]
|
account_name: Optional[str]
|
||||||
|
account_short_name: Optional[str]
|
||||||
account_description: Optional[str]
|
account_description: Optional[str]
|
||||||
|
|
||||||
account_enable: Optional[bool]
|
account_enable: Optional[bool]
|
||||||
|
|||||||
@@ -11,23 +11,81 @@ from app.common_field_schema import base_fields, default_num_bytes
|
|||||||
|
|
||||||
|
|
||||||
class Core_Object_Base(BaseModel):
|
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())
|
log.debug(locals())
|
||||||
|
|
||||||
obj_type: str
|
# The actual database record ID
|
||||||
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?
|
|
||||||
id: int # alias this one?
|
id: int # alias this one?
|
||||||
|
# id_random: str # alias this one?
|
||||||
|
|
||||||
account_id_random: Optional[str]
|
# This is what used to be id_random
|
||||||
account_id: Optional[str]
|
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]
|
notes: Optional[str]
|
||||||
created_on: Optional[datetime.datetime] = None
|
created_on: Optional[datetime.datetime]
|
||||||
updated_on: Optional[datetime.datetime] = None
|
updated_on: Optional[datetime.datetime]
|
||||||
|
versioned_on: Optional[datetime.datetime]
|
||||||
|
|
||||||
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ async def user_obj_change_password(
|
|||||||
@router.patch('/user/{obj_id}', response_model=Resp_Body_Base)
|
@router.patch('/user/{obj_id}', response_model=Resp_Body_Base)
|
||||||
async def patch_user_obj(
|
async def patch_user_obj(
|
||||||
obj: User_Base,
|
obj: User_Base,
|
||||||
obj_id: str = Query(..., min_length=1, max_length=22),
|
obj_id: str = Query(..., min_length=11, max_length=22),
|
||||||
x_account_id: Optional[str] = Header(..., ),
|
x_account_id: Optional[str] = Header(..., ),
|
||||||
return_obj: Optional[bool] = True,
|
return_obj: Optional[bool] = True,
|
||||||
by_alias: Optional[bool] = True,
|
by_alias: Optional[bool] = True,
|
||||||
|
|||||||
Reference in New Issue
Block a user