summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
c7ee3d6)
For clarity and convenience, create an is_admin() boolean check for
whether a User's account or an actor Element's owner's account is
flagged as an administrator. Put them to use in places where the
administrator facet was previously checked directly. This allows us
to do a little additional safety checking to avoid hitting corner
cases where we try to check some object which may or may not have an
owner.
+ def is_admin(self):
+ """Boolean check whether an actor is controlled by an admin owner."""
+ return(self.owner and self.owner.is_admin())
+
def can_run(self, command):
"""Check if the user can run this command object."""
def can_run(self, command):
"""Check if the user can run this command object."""
return(False)
# avatars of administrators can run any command
return(False)
# avatars of administrators can run any command
- if self.owner and self.owner.account.get("administrator"):
return(True)
# everyone can run non-administrative commands
return(True)
# everyone can run non-administrative commands
avatar, 6)
return avatars
avatar, 6)
return avatars
+ def is_admin(self):
+ """Boolean check whether user's account is an admin."""
+ return(self.account.get("administrator", False))
+
def broadcast(message, add_prompt=True):
"""Send a message to all connected users."""
def broadcast(message, add_prompt=True):
"""Send a message to all connected users."""
# display to connected administrators
for user in universe.userlist:
# display to connected administrators
for user in universe.userlist:
- if user.state == "active" and user.account.get(
- "administrator"
- ) and user.account.get("loglevel", 0) <= level:
+ if (
+ user.state == "active"
+ and user.is_admin()
+ and user.account.get("loglevel", 0) <= level):
# iterate over every line in the message
full_message = ""
for line in lines:
# iterate over every line in the message
full_message = ""
for line in lines: