-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Authorization/Permissions Prompt studio (#112)
* intial commit for permission in prompt studio * Create prompts to be part of prompt studio core * added share to prompt project * Prettier fix * File upload changes * Profile manger creation from prompt studio * Removing relation from custom tool on user deletion * Refractored the code * Refractored thr code to avoid exposing unused endpoints * added permission around prompt * Support for sharing the exported tool * Support for sharing the exported tool and access validation * Conflict resolution models * Conflict resolution jsx files * Check prompt registry is associated with custom tool * implemented UI for tool sharing * code clean up * Updated migrations * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Removed commented code * Fixed code climate issues * Fix code duplication * Removed redudant checks * Update backend/prompt_studio/permission.py Signed-off-by: Chandrasekharan M <[email protected]> --------- Signed-off-by: Rahul Johny <[email protected]> Signed-off-by: Chandrasekharan M <[email protected]> Co-authored-by: jagadeeswaran-zipstack <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: siddhiq <[email protected]> Co-authored-by: Chandrasekharan M <[email protected]> Co-authored-by: Neha <[email protected]>
- Loading branch information
1 parent
cef6fca
commit 72cdd4a
Showing
41 changed files
with
852 additions
and
436 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from typing import Any | ||
|
||
from rest_framework import permissions | ||
from rest_framework.request import Request | ||
from rest_framework.views import APIView | ||
|
||
|
||
class PromptAcesssToUser(permissions.BasePermission): | ||
"""Is the crud to Prompt/Notes allowed to user.""" | ||
|
||
def has_object_permission( | ||
self, request: Request, view: APIView, obj: Any | ||
) -> bool: | ||
return ( | ||
True | ||
if ( | ||
obj.tool_id.created_by == request.user | ||
or obj.tool_id.shared_users.filter(pk=request.user.pk).exists() | ||
) | ||
else False | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
backend/prompt_studio/prompt_studio_core/migrations/0012_customtool_shared_users.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 4.2.1 on 2024-03-26 04:26 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
( | ||
"prompt_studio_core", | ||
"0011_alter_customtool_postamble_alter_customtool_preamble", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="customtool", | ||
name="shared_users", | ||
field=models.ManyToManyField( | ||
related_name="shared_custom_tool", to=settings.AUTH_USER_MODEL | ||
), | ||
), | ||
] |
Oops, something went wrong.