refac
This commit is contained in:
@@ -502,9 +502,10 @@ class PromptsTable:
|
||||
name: str,
|
||||
command: str,
|
||||
tags: Optional[list[str]] = None,
|
||||
access_grants: Optional[list[dict]] = None,
|
||||
db: Optional[Session] = None,
|
||||
) -> Optional[PromptModel]:
|
||||
"""Update only name and command (no history created)."""
|
||||
"""Update only name, command, tags, and access grants (no history created)."""
|
||||
try:
|
||||
with get_db_context(db) as db:
|
||||
prompt = db.query(Prompt).filter_by(id=prompt_id).first()
|
||||
@@ -516,6 +517,11 @@ class PromptsTable:
|
||||
|
||||
if tags is not None:
|
||||
prompt.tags = tags
|
||||
|
||||
if access_grants is not None:
|
||||
AccessGrants.set_access_grants(
|
||||
"prompt", prompt_id, access_grants, db=db
|
||||
)
|
||||
|
||||
prompt.updated_at = int(time.time())
|
||||
db.commit()
|
||||
|
||||
@@ -33,6 +33,7 @@ class PromptMetadataForm(BaseModel):
|
||||
name: str
|
||||
command: str
|
||||
tags: Optional[list[str]] = None
|
||||
access_grants: Optional[list[dict]] = None
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
@@ -372,7 +373,7 @@ async def update_prompt_metadata(
|
||||
)
|
||||
|
||||
updated_prompt = Prompts.update_prompt_metadata(
|
||||
prompt.id, form_data.name, form_data.command, form_data.tags, db=db
|
||||
prompt.id, form_data.name, form_data.command, form_data.tags, form_data.access_grants, db=db
|
||||
)
|
||||
if updated_prompt:
|
||||
return updated_prompt
|
||||
|
||||
Reference in New Issue
Block a user