This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-27 02:44:21 -04:00
1 parent 0576e8eeb5
commit f1409266fe
8 files changed
+33 -33

No files matched your search

+4 -4
View File
@@ -241,11 +241,11 @@ class CalendarTable:
access_grants: Optional[list[AccessGrantModel]] = None, access_grants: Optional[list[AccessGrantModel]] = None,
db: Optional[AsyncSession] = None, db: Optional[AsyncSession] = None,
) -> CalendarModel: ) -> CalendarModel:
cal_data = CalendarModel.model_validate(cal).model_dump(exclude={'access_grants'}) calendar_model = CalendarModel.model_validate(cal)
cal_data['access_grants'] = ( calendar_model.access_grants = (
access_grants if access_grants is not None else await self._get_access_grants(cal_data['id'], db=db) access_grants if access_grants is not None else await self._get_access_grants(calendar_model.id, db=db)
) )
return CalendarModel.model_validate(cal_data) return calendar_model
async def get_or_create_defaults(self, user_id: str, db: Optional[AsyncSession] = None) -> list[CalendarModel]: async def get_or_create_defaults(self, user_id: str, db: Optional[AsyncSession] = None) -> list[CalendarModel]:
"""Return user's calendars, creating 'Personal' default if none exist.""" """Return user's calendars, creating 'Personal' default if none exist."""
+4 -4
View File
@@ -266,11 +266,11 @@ class ChannelTable:
access_grants: Optional[list[AccessGrantModel]] = None, access_grants: Optional[list[AccessGrantModel]] = None,
db: Optional[AsyncSession] = None, db: Optional[AsyncSession] = None,
) -> ChannelModel: ) -> ChannelModel:
channel_data = ChannelModel.model_validate(channel).model_dump(exclude={'access_grants'}) channel_model = ChannelModel.model_validate(channel)
channel_data['access_grants'] = ( channel_model.access_grants = (
access_grants if access_grants is not None else await self._get_access_grants(channel_data['id'], db=db) access_grants if access_grants is not None else await self._get_access_grants(channel_model.id, db=db)
) )
return ChannelModel.model_validate(channel_data) return channel_model
async def _collect_unique_user_ids( async def _collect_unique_user_ids(
self, self,
+4 -4
View File
@@ -195,11 +195,11 @@ class KnowledgeTable:
access_grants: Optional[list[AccessGrantModel]] = None, access_grants: Optional[list[AccessGrantModel]] = None,
db: Optional[AsyncSession] = None, db: Optional[AsyncSession] = None,
) -> KnowledgeModel: ) -> KnowledgeModel:
knowledge_data = KnowledgeModel.model_validate(knowledge).model_dump(exclude={'access_grants'}) knowledge_model = KnowledgeModel.model_validate(knowledge)
knowledge_data['access_grants'] = ( knowledge_model.access_grants = (
access_grants if access_grants is not None else await self._get_access_grants(knowledge_data['id'], db=db) access_grants if access_grants is not None else await self._get_access_grants(knowledge_model.id, db=db)
) )
return KnowledgeModel.model_validate(knowledge_data) return knowledge_model
async def insert_new_knowledge( async def insert_new_knowledge(
self, user_id: str, form_data: KnowledgeForm, db: Optional[AsyncSession] = None self, user_id: str, form_data: KnowledgeForm, db: Optional[AsyncSession] = None
+4 -4
View File
@@ -199,11 +199,11 @@ class ModelsTable:
if db is not None: if db is not None:
await db.commit() await db.commit()
model_data = ModelModel.model_validate(model).model_dump(exclude={'access_grants'}) model_model = ModelModel.model_validate(model)
model_data['access_grants'] = ( model_model.access_grants = (
access_grants if access_grants is not None else await self._get_access_grants(model_data['id'], db=db) access_grants if access_grants is not None else await self._get_access_grants(model_model.id, db=db)
) )
return ModelModel.model_validate(model_data) return model_model
async def insert_new_model( async def insert_new_model(
self, form_data: ModelForm, user_id: str, db: AsyncSession | None = None self, form_data: ModelForm, user_id: str, db: AsyncSession | None = None
+5 -5
View File
@@ -106,12 +106,12 @@ class NoteTable:
db: Optional[AsyncSession] = None, db: Optional[AsyncSession] = None,
) -> NoteModel: ) -> NoteModel:
# We exclude access_grants to inject them # We exclude access_grants to inject them
note_data = NoteModel.model_validate(note).model_dump(exclude={'access_grants'}) note_model = NoteModel.model_validate(note)
note_data['data'] = note_data.get('data') or {} note_model.data = note_model.data or {}
note_data['access_grants'] = ( note_model.access_grants = (
access_grants if access_grants is not None else await self._get_access_grants(note_data['id'], db=db) access_grants if access_grants is not None else await self._get_access_grants(note_model.id, db=db)
) )
return NoteModel.model_validate(note_data) return note_model
def _has_permission(self, db, query, filter: dict, permission: str = 'read'): def _has_permission(self, db, query, filter: dict, permission: str = 'read'):
return AccessGrants.has_permission_filter( return AccessGrants.has_permission_filter(
+4 -4
View File
@@ -103,11 +103,11 @@ class PromptsTable:
access_grants: list[AccessGrantModel | None] = None, access_grants: list[AccessGrantModel | None] = None,
db: AsyncSession | None = None, db: AsyncSession | None = None,
) -> PromptModel: ) -> PromptModel:
prompt_data = PromptModel.model_validate(prompt).model_dump(exclude={'access_grants'}) prompt_model = PromptModel.model_validate(prompt)
prompt_data['access_grants'] = ( prompt_model.access_grants = (
access_grants if access_grants is not None else await self._get_access_grants(prompt_data['id'], db=db) access_grants if access_grants is not None else await self._get_access_grants(prompt_model.id, db=db)
) )
return PromptModel.model_validate(prompt_data) return prompt_model
async def insert_new_prompt( async def insert_new_prompt(
self, user_id: str, form_data: PromptForm, db: AsyncSession | None = None self, user_id: str, form_data: PromptForm, db: AsyncSession | None = None
+4 -4
View File
@@ -113,11 +113,11 @@ class SkillsTable:
access_grants: Optional[list[AccessGrantModel]] = None, access_grants: Optional[list[AccessGrantModel]] = None,
db: Optional[AsyncSession] = None, db: Optional[AsyncSession] = None,
) -> SkillModel: ) -> SkillModel:
skill_data = SkillModel.model_validate(skill).model_dump(exclude={'access_grants'}) skill_model = SkillModel.model_validate(skill)
skill_data['access_grants'] = ( skill_model.access_grants = (
access_grants if access_grants is not None else await self._get_access_grants(skill_data['id'], db=db) access_grants if access_grants is not None else await self._get_access_grants(skill_model.id, db=db)
) )
return SkillModel.model_validate(skill_data) return skill_model
async def insert_new_skill( async def insert_new_skill(
self, self,
+4 -4
View File
@@ -106,11 +106,11 @@ class ToolsTable:
access_grants: list[AccessGrantModel | None] = None, access_grants: list[AccessGrantModel | None] = None,
db: AsyncSession | None = None, db: AsyncSession | None = None,
) -> ToolModel: ) -> ToolModel:
tool_data = ToolModel.model_validate(tool).model_dump(exclude={'access_grants'}) tool_model = ToolModel.model_validate(tool)
tool_data['access_grants'] = ( tool_model.access_grants = (
access_grants if access_grants is not None else await self._get_access_grants(tool_data['id'], db=db) access_grants if access_grants is not None else await self._get_access_grants(tool_model.id, db=db)
) )
return ToolModel.model_validate(tool_data) return tool_model
async def insert_new_tool( async def insert_new_tool(
self, self,