Skip to content

Conversation

iledarn
Copy link

@iledarn iledarn commented Aug 10, 2021

No description provided.

@trojikman trojikman requested a review from yelizariev August 11, 2021 10:18
@trojikman trojikman self-assigned this Aug 11, 2021
Copy link
Collaborator

@yelizariev yelizariev left a 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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"author": "IT-Projects LLC, Ildar Nasyrov",
"author": "IT Projects Labs, Ildar Nasyrov",

@@ -0,0 +1,17 @@
{
"name": "Controllable Becoming a Superuser",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"],
Copy link
Collaborator

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

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""",
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)!"""
)
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
)

@yelizariev
Copy link
Collaborator

@iledarn use

pre-commit install

@yelizariev
Copy link
Collaborator

@trojikman
ридми и документацию переделать нужно

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants