-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/permission NEW permission system #440
Open
DoyunShin
wants to merge
36
commits into
develop
Choose a base branch
from
feature/permission
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
8f189dd
feat(permission): Add new models
DoyunShin 9344b54
refactor(calendar): move meta to top
DoyunShin 9ed4cb9
feat(permission): Fix all permission function request to new one.
DoyunShin b5be2b0
feat(permission): remove related name from models
DoyunShin 0038fed
feat(permission): move org_type to groups
DoyunShin 62eca9f
feat(permission): add permission admin page
DoyunShin 6dc93d7
refactor(permission): clear all imports and type hints
DoyunShin e9e2cb9
fix(permission): Remove deleted column
DoyunShin 3ae56e4
fix(permission): Fix unique_together column name
DoyunShin d7f119a
refactor(permission): remove _id names and fix some of type hints
DoyunShin 4632984
refactor(permission): Fix type hinting
DoyunShin 706cf12
refactor(permission): add annotation
DoyunShin e4b7544
feat(permission): Remove all bitmasks
DoyunShin 7d0861c
fix(permission): Fix UserGroup PK
DoyunShin 49fb8f6
fix(permission): Resotre org_type on manual
DoyunShin 33546bb
fix(permission): Remove every OldUserGroup
DoyunShin 226d1d8
fix(permission): Fix BoardPermission legacy codes
DoyunShin cdc2eff
fix(permission): Add default groups on test
DoyunShin 5708cff
feat(permission): Migration file
DoyunShin 6c39c24
fix(permission): Fix UserProfile to User
DoyunShin 234f023
fix(permission): Add all board permissions
DoyunShin 2bea426
refactor(permission): remove unnecessery prints
DoyunShin e4ad24a
refactor(permission): Remove Old Structures
DoyunShin 0d53fe8
refactor(permission): move meta to down
DoyunShin 2e80713
refactor(permission): Remove Old Structures
DoyunShin 193a912
fix(permission): Restore manualuser org_type
DoyunShin 4df23e8
refactor(permission): Remove commit in migration
DoyunShin be94d66
fix(permission): Revert org_type null=False
DoyunShin 529c709
fix(permission): Check is_school_admin not has_group_by_id
DoyunShin c1a6d80
fix(permission): groups cached property, argument names, any() function
DoyunShin 1f43ed0
fix(permission): Fix default official groups
DoyunShin 283468e
fix(permission): Remove by_name functions
DoyunShin 32ef449
fix(permission): Use Group join
DoyunShin 3e12f68
refactor(permission): use annotations for self typing
injoonH c71e9f2
chore(permission): remove unused imports
injoonH 3a22da3
fix(permission): fix admin page for `UserGroup`
injoonH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
apps/core/migrations/0058_remove_board_comment_access_mask_and_more.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,99 @@ | ||
# Generated by Django 4.2.3 on 2024-01-10 17:16 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
from apps.core.models import BoardAccessPermissionType | ||
|
||
|
||
def move_board_permissions(apps, schema_editor): | ||
Board = apps.get_model("core", "Board") | ||
BoardPermission = apps.get_model("core", "BoardPermission") | ||
Group = apps.get_model("user", "Group") | ||
for board in Board.objects.all(): | ||
read_access_mask = board.read_access_mask | ||
write_access_mask = board.write_access_mask | ||
comment_access_mask = board.comment_access_mask | ||
|
||
for group in Group.objects.all(): | ||
read = bool((read_access_mask & (1 << (group.group_id - 1))) > 0) | ||
write = bool((write_access_mask & (1 << (group.group_id - 1))) > 0) | ||
comment = bool((comment_access_mask & (1 << (group.group_id - 1))) > 0) | ||
|
||
if read: | ||
BoardPermission.objects.create( | ||
board=board, | ||
group=group, | ||
permission=BoardAccessPermissionType.READ, | ||
) | ||
if write: | ||
BoardPermission.objects.create( | ||
board=board, | ||
group=group, | ||
permission=BoardAccessPermissionType.WRITE, | ||
) | ||
if comment: | ||
BoardPermission.objects.create( | ||
board=board, | ||
group=group, | ||
permission=BoardAccessPermissionType.COMMENT, | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("user", "0022_group_remove_userprofile_group_and_more"), | ||
("core", "0057_alter_article_name_type_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="BoardPermission", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("permission", models.SmallIntegerField(verbose_name="permission")), | ||
( | ||
"board", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="core.board", | ||
verbose_name="board slug", | ||
), | ||
), | ||
( | ||
"group", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="user.group", | ||
verbose_name="group", | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "BoardPermission", | ||
"verbose_name_plural": "BoardPermissions", | ||
"unique_together": {("group", "board", "permission")}, | ||
}, | ||
), | ||
migrations.RunPython(move_board_permissions), | ||
migrations.RemoveField( | ||
model_name="board", | ||
name="comment_access_mask", | ||
), | ||
migrations.RemoveField( | ||
model_name="board", | ||
name="read_access_mask", | ||
), | ||
migrations.RemoveField( | ||
model_name="board", | ||
name="write_access_mask", | ||
), | ||
] |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❗ 파일명
0059_remove_board_comment_access_mask_and_more.py
로 수정해야 합니다.