-
Notifications
You must be signed in to change notification settings - Fork 260
🎉 access_superuser #328
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
base: 14.0
Are you sure you want to change the base?
🎉 access_superuser #328
Conversation
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.
Попереименовать надо
"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", |
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.
"author": "IT-Projects LLC, Ildar Nasyrov", | |
"author": "IT Projects Labs, Ildar Nasyrov", |
@@ -0,0 +1,17 @@ | |||
{ | |||
"name": "Controllable Becoming a Superuser", |
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.
"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", |
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.
"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"], |
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.
There is no banner yet
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""", | ||
) |
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.
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""", | |
) |
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) |
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.
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 |
_( | ||
""" | ||
Insufficient rights for making someone a Sudoer | ||
(You yourself should be in Superuser mode) | ||
or this User is not a System User | ||
(Administration: Settings)!""" | ||
) | ||
) |
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.
_( | |
""" | |
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") | |
) |
@iledarn use
|
@trojikman |
No description provided.