-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update permissions and query docs and bump version (#197)
Changes: - update docs - bump version
- Loading branch information
Showing
10 changed files
with
124 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import edgy | ||
from edgy.contrib.permissions import BasePermission | ||
|
||
models = edgy.Registry("sqlite:///foo.sqlite3") | ||
|
||
|
||
class User(edgy.Model): | ||
name = edgy.fields.CharField(max_length=100) | ||
|
||
class Meta: | ||
registry = models | ||
|
||
|
||
class Group(edgy.Model): | ||
name = edgy.fields.CharField(max_length=100) | ||
users = edgy.fields.ManyToMany("User", embed_through=False) | ||
|
||
class Meta: | ||
registry = models | ||
|
||
|
||
class Permission(BasePermission): | ||
# overwrite name of BasePermission with a CharField with primary_key=True | ||
name: str = edgy.fields.CharField(max_length=100, primary_key=True) | ||
users = edgy.fields.ManyToMany("User", embed_through=False) | ||
groups = edgy.fields.ManyToMany("Group", embed_through=False) | ||
name_model: str = edgy.fields.CharField(max_length=100, null=True, primary_key=True) | ||
obj = edgy.fields.ForeignKey("ContentType", null=True, primary_key=True) | ||
|
||
class Meta: | ||
registry = models | ||
|
||
|
||
user = User.query.create(name="edgy") | ||
group = Group.query.create(name="edgy", users=[user]) | ||
permission = await Permission.query.create(users=[user], groups=[group], name="view", obj=user) | ||
assert await Permission.query.users("view", objects=user).get() == user | ||
await Permission.query.permissions_of(user) |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = "0.17.4" | ||
__version__ = "0.18.0" | ||
|
||
from .cli.base import Migrate | ||
from .conf import settings | ||
|
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