Add DefaultAccount.get_extra_display_name_info method

This commit is contained in:
Griatch 2024-04-05 09:32:35 +02:00
parent d1447b75a0
commit f88b68dac6
2 changed files with 21 additions and 15 deletions

View file

@ -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

View file

@ -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