Skip to content

Add patch and delete endpoints#2904

Merged
jzbahrai merged 7 commits into
mainfrom
task/delete-update-template
Jun 15, 2026
Merged

Add patch and delete endpoints#2904
jzbahrai merged 7 commits into
mainfrom
task/delete-update-template

Conversation

@jzbahrai

@jzbahrai jzbahrai commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary | Résumé

Added patch and delete endpoints for Templates

Related Issues | Cartes liées

Test instructions | Instructions pour tester la modification

  1. Create a new template:
POST http://localhost:6011/v2/manage-template
{"name": "Welcome email1",
 "template_type": "email",
 "subject": "Welcome to  notify 3",
 "content": "Hi ((first_name)), welcome!", 
 "template_category_id": "7c16aa95-e2e1-4497-81d6-04c656520fe4"
}
  1. Patch the above Template
PATCH http://localhost:6011/v2/manage-template/<template_id_from_above>
{"name": "Welcome email1",
 "template_type": "email",
 "subject": "Welcome to  notify 3",
 "content": "Hi ((first_name)), welcome!", 
 "template_category_id": "7c16aa95-e2e1-4497-81d6-04c656520fe4"
}

^ Ifyou posted the above with template_type, you will get an error
Remove the template_type and when you send the PATCH, you should see the version gets updated

  1. Delete the above template
  2. Check admin to see that the template doesn't exist

Copilot AI review requested due to automatic review settings June 10, 2026 19:06
@jzbahrai jzbahrai requested a review from jimleroyer as a code owner June 10, 2026 19:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds missing PATCH and DELETE endpoints to the existing /v2/manage-template/<template_id> API so callers can update template fields and archive templates, aligning v2 manage-template functionality with expected template lifecycle operations.

Changes:

  • Added /v2/manage-template/<template_id> PATCH endpoint with request schema validation and support for updating name/content/subject/category/folder.
  • Added /v2/manage-template/<template_id> DELETE endpoint that archives templates and returns the serialized template.
  • Added unit tests covering success and common failure cases for both endpoints.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/app/v2/manage_template/test_patch_template.py New tests for PATCH manage-template endpoint (update and error paths).
tests/app/v2/manage_template/test_delete_template.py New tests for DELETE manage-template endpoint (archive and error paths).
app/v2/manage_template/template_schemas.py Adds PATCH request schema for manage-template updates.
app/v2/manage_template/patch_template.py Implements PATCH endpoint logic and validation.
app/v2/manage_template/delete_template.py Implements DELETE endpoint to archive templates.
app/init.py Registers the new manage-template modules so routes are loaded.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/app/v2/manage_template/test_patch_template.py
Comment thread tests/app/v2/manage_template/test_patch_template.py Outdated
Comment thread app/v2/manage_template/patch_template.py
Comment thread app/v2/manage_template/delete_template.py
Comment thread app/__init__.py
Comment thread app/v2/manage_template/template_schemas.py
@jzbahrai jzbahrai force-pushed the task/delete-update-template branch from e830a13 to ee8f4eb Compare June 11, 2026 13:34
Comment thread app/v2/errors.py Fixed
Comment thread app/v2/errors.py Fixed
@jzbahrai jzbahrai force-pushed the task/delete-update-template branch from 4c6f8ab to a501e8f Compare June 11, 2026 15:45
@jzbahrai jzbahrai force-pushed the task/delete-update-template branch from f84cd82 to a9407ab Compare June 11, 2026 19:43

@whabanks whabanks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested locally and it's working as expected. Just one comment around folders.


template.archived = True
template.updated_at = datetime.utcnow()
templates_dao.dao_update_template(template)

@whabanks whabanks Jun 11, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to mirror existing behaviour on the admin endpoints and detach the archived templates from folders?

@whabanks whabanks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jzbahrai jzbahrai merged commit 0f4ce68 into main Jun 15, 2026
9 checks passed
@jzbahrai jzbahrai deleted the task/delete-update-template branch June 15, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants