From f88b68dac60e2a4cb08867240ae8d8d1f4dc057b Mon Sep 17 00:00:00 2001 From: Griatch Date: Fri, 5 Apr 2024 09:32:35 +0200 Subject: [PATCH] Add DefaultAccount.get_extra_display_name_info method --- CHANGELOG.md | 2 ++ evennia/accounts/accounts.py | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8da538d8f6..669b4ea2e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ (InspectorCaracal) - Fix: `find #dbref` results didn't include the results of `.get_extra_display_name_info` (the #dbref display by default) (Griatch) +- Fix: Add `DefaultAccount.get_extra_display_name_info` method for API + compliance with `DefaultObject` in commands. (Griatch) [pull3438]: https://github.com/evennia/evennia/pull/3446 diff --git a/evennia/accounts/accounts.py b/evennia/accounts/accounts.py index b01592ddfa..594424f269 100644 --- a/evennia/accounts/accounts.py +++ b/evennia/accounts/accounts.py @@ -16,14 +16,13 @@ import time import typing from random import getrandbits +import evennia from django.conf import settings from django.contrib.auth import authenticate, password_validation from django.core.exceptions import ImproperlyConfigured, ValidationError from django.utils import timezone from django.utils.module_loading import import_string from django.utils.translation import gettext as _ - -import evennia from evennia.accounts.manager import AccountManager from evennia.accounts.models import AccountDB from evennia.commands.cmdsethandler import CmdSetHandler @@ -31,24 +30,17 @@ from evennia.comms.models import ChannelDB from evennia.objects.models import ObjectDB from evennia.scripts.scripthandler import ScriptHandler from evennia.server.models import ServerConfig -from evennia.server.signals import ( - SIGNAL_ACCOUNT_POST_CREATE, - SIGNAL_ACCOUNT_POST_LOGIN_FAIL, - SIGNAL_OBJECT_POST_PUPPET, - SIGNAL_OBJECT_POST_UNPUPPET, -) +from evennia.server.signals import (SIGNAL_ACCOUNT_POST_CREATE, + SIGNAL_ACCOUNT_POST_LOGIN_FAIL, + SIGNAL_OBJECT_POST_PUPPET, + SIGNAL_OBJECT_POST_UNPUPPET) from evennia.server.throttle import Throttle from evennia.typeclasses.attributes import ModelAttributeBackend, NickHandler from evennia.typeclasses.models import TypeclassBase from evennia.utils import class_from_module, create, logger from evennia.utils.optionhandler import OptionHandler -from evennia.utils.utils import ( - is_iter, - lazy_property, - make_iter, - to_str, - variable_from_module, -) +from evennia.utils.utils import (is_iter, lazy_property, make_iter, to_str, + variable_from_module) __all__ = ("DefaultAccount", "DefaultGuest") @@ -373,6 +365,18 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase): session.protocol_flags.get("SCREENREADER") for session in self.sessions.all() ) + def get_extra_display_name_info(self, looker, **kwargs): + """ + Used in .get_display_name() to provide extra information to the looker. We split this + to be consistent with the Object version of this method. + + This is used e.g. by the `find` command by default. + + """ + if looker and self.locks.check_lockstring(looker, "perm(Admin)"): + return f"(#{self.id})" + return "" + def get_display_name(self, looker, **kwargs): """ This is used by channels and other OOC communications methods to give a