-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Permissions language reworked #12449
Closed
Closed
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
03e96ed
Permissions language reworked
comradekingu c46356b
the source
comradekingu ac7301c
Read-only
comradekingu 8a9eed0
Read-only
comradekingu b65cea4
Read-only
comradekingu 9cb8fa2
Read-only
comradekingu 05d3db7
Read-only
comradekingu 74773a8
Merge branch 'main' into patch-307
orangesunny 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
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 | ||||
---|---|---|---|---|---|---|
|
@@ -58,7 +58,7 @@ def wrap_perm(function): | |||||
|
||||||
|
||||||
def check_global_permission(user: User, permission: str) -> bool: | ||||||
"""Check whether user has a global permission.""" | ||||||
"""Check whether the user has a global permission.""" | ||||||
if user.is_superuser: | ||||||
return True | ||||||
return permission in user.global_permissions | ||||||
|
@@ -189,15 +189,15 @@ def check_can_edit(user: User, permission: str, obj: Model, is_vote=False): # n | |||||
): | ||||||
return Denied( | ||||||
gettext( | ||||||
"Contributing to this translation requires agreeing to its contributor agreement." | ||||||
"Contributing to this translation requires accepting its contributor license agreement." | ||||||
) | ||||||
) | ||||||
|
||||||
# Perform usual permission check | ||||||
if not check_permission(user, permission, obj): | ||||||
if not user.is_authenticated: | ||||||
# Signing in might help, but user still might need additional privileges | ||||||
return Denied(gettext("Sign in to save the translation.")) | ||||||
return Denied(gettext("Sign in to save translations.")) | ||||||
if permission == "unit.review": | ||||||
return Denied( | ||||||
gettext("Insufficient privileges for approving translations.") | ||||||
|
@@ -224,7 +224,7 @@ def check_can_edit(user: User, permission: str, obj: Model, is_vote=False): # n | |||||
): | ||||||
return Denied( | ||||||
gettext( | ||||||
"This translation only accepts suggestions, and these are approved by voting." | ||||||
"This translation only accepts suggestions, in turn approved by voting." | ||||||
) | ||||||
) | ||||||
|
||||||
|
@@ -243,8 +243,8 @@ def check_unit_review(user: User, permission: str, obj: Model, skip_enabled=Fals | |||||
if isinstance(obj, Translation): | ||||||
if not obj.enable_review: | ||||||
if obj.is_source: | ||||||
return Denied(gettext("Source string reviews are not enabled.")) | ||||||
return Denied(gettext("Translation reviews are not enabled.")) | ||||||
return Denied(gettext("Source-string reviews are turned off.")) | ||||||
return Denied(gettext("Translation reviews are turned off.")) | ||||||
else: | ||||||
if isinstance(obj, CategoryLanguage): | ||||||
project = obj.category.project | ||||||
|
@@ -256,7 +256,7 @@ def check_unit_review(user: User, permission: str, obj: Model, skip_enabled=Fals | |||||
else: | ||||||
project = obj | ||||||
if not project.source_review and not project.translation_review: | ||||||
return Denied(gettext("Reviews are not enabled.")) | ||||||
return Denied(gettext("Reviewing is turned off.")) | ||||||
return check_can_edit(user, permission, obj) | ||||||
|
||||||
|
||||||
|
@@ -266,12 +266,12 @@ def check_edit_approved(user: User, permission: str, obj: Model): | |||||
if isinstance(obj, Unit): | ||||||
unit = obj | ||||||
obj = unit.translation | ||||||
# Read only check is unconditional as there is another one | ||||||
# Read-only check is unconditional as there is another one | ||||||
# in PluralTextarea.render | ||||||
if unit.readonly: | ||||||
if not unit.source_unit.translated: | ||||||
return Denied(gettext("The source string needs review.")) | ||||||
return Denied(gettext("The string is read only.")) | ||||||
return Denied(gettext("The string is read-only.")) | ||||||
# Ignore approved state if review is not disabled. This might | ||||||
# happen after disabling them. | ||||||
if ( | ||||||
|
@@ -281,13 +281,13 @@ def check_edit_approved(user: User, permission: str, obj: Model): | |||||
): | ||||||
return Denied( | ||||||
gettext( | ||||||
"Only reviewers can change approved strings, please add a suggestion if you think the string should be changed." | ||||||
"Only reviewers can change approved strings. Please add a suggestion if you think the string should be changed." | ||||||
) | ||||||
) | ||||||
if isinstance(obj, Translation): | ||||||
component = obj.component | ||||||
if obj.is_readonly: | ||||||
return Denied(gettext("The translation is read only.")) | ||||||
return Denied(gettext("The translation is read-only.")) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Better language, but not consistent form. |
||||||
elif isinstance(obj, Component): | ||||||
component = obj | ||||||
if component is not None and component.is_glossary: | ||||||
|
@@ -323,7 +323,7 @@ def check_unit_delete(user: User, permission: str, obj: Model): | |||||
): | ||||||
return Denied( | ||||||
gettext( | ||||||
"Cannot remove terminology translation, remove source string instead." | ||||||
"Cannot remove terminology translation. Remove the source string instead." | ||||||
) | ||||||
) | ||||||
obj = obj.translation | ||||||
|
@@ -335,7 +335,7 @@ def check_unit_delete(user: User, permission: str, obj: Model): | |||||
|
||||||
# Does file format support removing? | ||||||
if not component.file_format_cls.can_delete_unit: | ||||||
return Denied(gettext("File format does not support this.")) | ||||||
return Denied(gettext("The file format does not support this.")) | ||||||
|
||||||
if component.is_glossary: | ||||||
permission = "glossary.delete" | ||||||
|
@@ -352,7 +352,7 @@ def check_unit_add(user: User, permission, translation): | |||||
|
||||||
# Does file format support adding? | ||||||
if not component.file_format_cls.can_add_unit: | ||||||
return Denied(gettext("File format does not support this.")) | ||||||
return Denied(gettext("The file format does not support this.")) | ||||||
|
||||||
if component.is_glossary: | ||||||
permission = "glossary.add" | ||||||
|
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.
Better language, but not consistent form.