Skip to content

feat(user-teplates): Add pre-admin templates - #785

Open
ImMohammad20000 wants to merge 1 commit into
devfrom
pre-admin-UserTemplates
Open

feat(user-teplates): Add pre-admin templates#785
ImMohammad20000 wants to merge 1 commit into
devfrom
pre-admin-UserTemplates

Conversation

@ImMohammad20000

@ImMohammad20000 ImMohammad20000 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added ownership-aware user templates, allowing administrators to create and manage templates associated with their account.
    • Template listings, details, updates, and deletions now respect administrator ownership and permission scopes.
    • User-template responses now include the optional administrator owner ID.
    • Updated template permission settings to support scoped read, simplified-read, update, and delete actions.
  • Documentation

    • Clarified permission descriptions for administrator-owned resources.

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 45ff579d-8591-4c42-a97b-dec795b0603c

📥 Commits

Reviewing files that changed from the base of the PR and between 3331421 and 1754825.

📒 Files selected for processing (9)
  • app/db/crud/user_template.py
  • app/db/migrations/versions/4b348c37504f_add_admin_id_to_user_templates.py
  • app/db/models.py
  • app/models/admin_role.py
  • app/models/user_template.py
  • app/operation/__init__.py
  • app/operation/user_template.py
  • dashboard/src/features/admin-roles/forms/admin-role-form.ts
  • dashboard/src/service/api/index.ts

Walkthrough

User templates now store optional administrator ownership. Backend CRUD and operations apply administrator-scoped filters and access checks. The migration updates schema and role permissions. Backend and dashboard API contracts expose admin_id.

Changes

User-template ownership and scoped access

Layer / File(s) Summary
Ownership schema and permission migration
app/db/models.py, app/db/migrations/versions/..., app/models/admin_role.py
Adds nullable user_templates.admin_id with a foreign key and index. The migration updates seed-role template permissions and operator API-key permissions.
Scoped template CRUD operations
app/db/crud/user_template.py, app/operation/__init__.py, app/operation/user_template.py
Passes administrator IDs through creation, retrieval, listing, update, delete, and bulk operations. Queries filter templates by owner when an ID is provided.
Permission and API contracts
app/models/user_template.py, dashboard/src/features/admin-roles/forms/admin-role-form.ts, dashboard/src/service/api/index.ts
Marks template read, simple-read, update, and delete actions as scoped. Adds nullable admin_id to template response types. Regenerates and reorders related API declarations.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 17548

The pre-admin user-template changes have no identified actionable correctness, security, availability, or readiness issue, so the PR is merge-ready after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant TemplateOperation
  participant AccessValidation
  participant UserTemplateCRUD
  participant UserTemplatesDatabase
  TemplateOperation->>AccessValidation: resolve scoped admin_id
  AccessValidation->>UserTemplateCRUD: retrieve template with scope
  UserTemplateCRUD->>UserTemplatesDatabase: filter by admin_id
  UserTemplatesDatabase-->>UserTemplateCRUD: return scoped template records
  UserTemplateCRUD-->>TemplateOperation: return validated template data
Loading

Possibly related PRs

  • PasarGuard/panel#759: Both changes extend administrator-aware access and validation for user templates.

Suggested labels: enhancement, Backend, Frontend

Suggested reviewers: m03ed, x0sina

Poem

I’m a rabbit guarding templates tight,
With admin_id tucked out of sight.
Scoped reads and updates hop in line,
CRUD filters keep each burrow fine.
The dashboard knows the owner too—
Squeak, the migration made it true!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.91% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title describes the main change, adding administrator-owned user templates, despite a minor typo in “teplates.”
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pre-admin-UserTemplates

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ImMohammad20000

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot added Backend enhancement New feature or request Frontend labels Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant