🎉 access_superuser#328
Open
iledarn wants to merge 1 commit into
Open
Conversation
yelizariev
reviewed
Aug 11, 2021
Collaborator
yelizariev
left a comment
There was a problem hiding this comment.
Попереименовать надо
| "name": "Controllable Becoming a Superuser", | ||
| "summary": "Not any Admin can become a Superuser - there is new setting now allowing that", | ||
| "version": "14.0.0.0.1", | ||
| "author": "IT-Projects LLC, Ildar Nasyrov", |
Collaborator
There was a problem hiding this comment.
Suggested change
| "author": "IT-Projects LLC, Ildar Nasyrov", | |
| "author": "IT Projects Labs, Ildar Nasyrov", |
| @@ -0,0 +1,17 @@ | |||
| { | |||
| "name": "Controllable Becoming a Superuser", | |||
Collaborator
There was a problem hiding this comment.
Suggested change
| "name": "Controllable Becoming a Superuser", | |
| "name": "Block Superuser Mode", |
| @@ -0,0 +1,17 @@ | |||
| { | |||
| "name": "Controllable Becoming a Superuser", | |||
| "summary": "Not any Admin can become a Superuser - there is new setting now allowing that", | |||
Collaborator
There was a problem hiding this comment.
Suggested change
| "summary": "Not any Admin can become a Superuser - there is new setting now allowing that", | |
| "summary": "Specify which admins can switch to the Superuser mode", |
| "version": "14.0.0.0.1", | ||
| "author": "IT-Projects LLC, Ildar Nasyrov", | ||
| "category": "Extra Tools", | ||
| "images": ["images/banner.jpg"], |
Collaborator
There was a problem hiding this comment.
There is no banner yet
Comment on lines
+9
to
+13
| is_sudoer = fields.Boolean( | ||
| default=True, | ||
| help=""" | ||
| Is a User eligible to become a Superuser. If True and User is Admin (Administrator: Settings) - then ok""", | ||
| ) |
Collaborator
There was a problem hiding this comment.
Suggested change
| is_sudoer = fields.Boolean( | |
| default=True, | |
| help=""" | |
| Is a User eligible to become a Superuser. If True and User is Admin (Administrator: Settings) - then ok""", | |
| ) | |
| can_sudo = fields.Boolean( | |
| string="Superuser Admin" | |
| default=True, | |
| help="""User is eligible to switch to Superuser mode""", | |
| ) |
Comment on lines
+36
to
+59
| if "is_sudoer" in vals and not vals["is_sudoer"]: | ||
| if self.env.is_superuser(): | ||
| raise UserError( | ||
| _( | ||
| """ | ||
| To clear 'Is Sudoer' setting - | ||
| please exit from Superuser mode, | ||
| this way the System can | ||
| check that you are not trying to do it | ||
| on your own, which is prohibited | ||
| because someone should be a sudoer""" | ||
| ) | ||
| ) | ||
| elif self == self.env.user: | ||
| raise UserError( | ||
| _( | ||
| """ | ||
| You cannot uncheck 'Is Sudoer' setting on yourself - | ||
| this prevents the situation when no one is | ||
| eligible becoming Superuser""" | ||
| ) | ||
| ) | ||
|
|
||
| return super(Users, self).write(vals) |
Collaborator
There was a problem hiding this comment.
Suggested change
| if "is_sudoer" in vals and not vals["is_sudoer"]: | |
| if self.env.is_superuser(): | |
| raise UserError( | |
| _( | |
| """ | |
| To clear 'Is Sudoer' setting - | |
| please exit from Superuser mode, | |
| this way the System can | |
| check that you are not trying to do it | |
| on your own, which is prohibited | |
| because someone should be a sudoer""" | |
| ) | |
| ) | |
| elif self == self.env.user: | |
| raise UserError( | |
| _( | |
| """ | |
| You cannot uncheck 'Is Sudoer' setting on yourself - | |
| this prevents the situation when no one is | |
| eligible becoming Superuser""" | |
| ) | |
| ) | |
| return super(Users, self).write(vals) | |
| res = super(Users, self).write(vals) | |
| if not self.search_count([('can_sudo', '=', True), ('id', '!=', 1)]): | |
| raise UserError( | |
| _( | |
| "There must be at least one Superuser Admin" | |
| ) | |
| ) | |
| return res |
Comment on lines
+27
to
+34
| _( | ||
| """ | ||
| Insufficient rights for making someone a Sudoer | ||
| (You yourself should be in Superuser mode) | ||
| or this User is not a System User | ||
| (Administration: Settings)!""" | ||
| ) | ||
| ) |
Collaborator
There was a problem hiding this comment.
Suggested change
| _( | |
| """ | |
| Insufficient rights for making someone a Sudoer | |
| (You yourself should be in Superuser mode) | |
| or this User is not a System User | |
| (Administration: Settings)!""" | |
| ) | |
| ) | |
| _("To assign a Superuser Admin, you must be Superuser Admin yourself") | |
| ) |
Collaborator
|
@iledarn use |
Collaborator
|
@trojikman |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.