mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Merge remote-tracking branch 'upstream/main' into main
This commit is contained in:
commit
78d573eee5
5 changed files with 25 additions and 20 deletions
|
|
@ -7,7 +7,6 @@ import re
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.urls import reverse
|
||||
from django.utils.text import slugify
|
||||
|
||||
from evennia.comms.managers import ChannelManager
|
||||
from evennia.comms.models import ChannelDB
|
||||
from evennia.typeclasses.models import TypeclassBase
|
||||
|
|
@ -188,7 +187,7 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
|
|||
# display listening subscribers in bold
|
||||
string = ", ".join(
|
||||
[
|
||||
account.key if account not in listening else "|w%s|n" % account.key
|
||||
account.key if account not in listening else f"|w{account.key}|n"
|
||||
for account in subs
|
||||
]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ necessary to easily be able to delete connections on the fly).
|
|||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
|
||||
from evennia.comms import managers
|
||||
from evennia.locks.lockhandler import LockHandler
|
||||
from evennia.typeclasses.models import TypedObject
|
||||
|
|
@ -104,8 +103,10 @@ class Msg(SharedMemoryModel):
|
|||
null=True,
|
||||
blank=True,
|
||||
db_index=True,
|
||||
help_text="Identifier for single external sender, for use with senders "
|
||||
"not represented by a regular database model.",
|
||||
help_text=(
|
||||
"Identifier for single external sender, for use with senders "
|
||||
"not represented by a regular database model."
|
||||
),
|
||||
)
|
||||
|
||||
db_receivers_accounts = models.ManyToManyField(
|
||||
|
|
@ -137,8 +138,10 @@ class Msg(SharedMemoryModel):
|
|||
null=True,
|
||||
blank=True,
|
||||
db_index=True,
|
||||
help_text="Identifier for single external receiver, for use with recievers "
|
||||
"not represented by a regular database model.",
|
||||
help_text=(
|
||||
"Identifier for single external receiver, for use with recievers "
|
||||
"not represented by a regular database model."
|
||||
),
|
||||
)
|
||||
|
||||
# header could be used for meta-info about the message if your system needs
|
||||
|
|
@ -167,8 +170,10 @@ class Msg(SharedMemoryModel):
|
|||
db_tags = models.ManyToManyField(
|
||||
Tag,
|
||||
blank=True,
|
||||
help_text="tags on this message. Tags are simple string markers to "
|
||||
"identify, group and alias messages.",
|
||||
help_text=(
|
||||
"tags on this message. Tags are simple string markers to "
|
||||
"identify, group and alias messages."
|
||||
),
|
||||
)
|
||||
|
||||
# Database manager
|
||||
|
|
@ -518,7 +523,7 @@ class TempMsg:
|
|||
# ------------------------------------------------------------
|
||||
|
||||
|
||||
class SubscriptionHandler(object):
|
||||
class SubscriptionHandler:
|
||||
"""
|
||||
This handler manages subscriptions to the
|
||||
channel and hides away which type of entity is
|
||||
|
|
@ -540,13 +545,13 @@ class SubscriptionHandler(object):
|
|||
def _recache(self):
|
||||
self._cache = {
|
||||
account: True
|
||||
for account in self.obj.db_account_subscriptions.all()
|
||||
for account in self.obj.db_account_subscriptions.all().order_by("pk")
|
||||
if hasattr(account, "pk") and account.pk
|
||||
}
|
||||
self._cache.update(
|
||||
{
|
||||
obj: True
|
||||
for obj in self.obj.db_object_subscriptions.all()
|
||||
for obj in self.obj.db_object_subscriptions.all().order_by("pk")
|
||||
if hasattr(obj, "pk") and obj.pk
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
|||
|
||||
objects = ObjectManager()
|
||||
|
||||
# populated by `return_apperance`
|
||||
# populated by `return_appearance`
|
||||
appearance_template = """
|
||||
{header}
|
||||
|c{name}|n
|
||||
|
|
@ -1201,7 +1201,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
|||
self.at_access(result, accessing_obj, access_type, **kwargs)
|
||||
return result
|
||||
|
||||
# name and return_apperance hooks
|
||||
# name and return_appearance hooks
|
||||
|
||||
def get_display_name(self, looker=None, **kwargs):
|
||||
"""
|
||||
|
|
@ -2111,7 +2111,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
|||
Notes:
|
||||
This method shouldn't add extra coloring to the names beyond what is
|
||||
already given by the .get_display_name() (and the .name field) already.
|
||||
Per-type coloring can be applied in `return_apperance`.
|
||||
Per-type coloring can be applied in `return_appearance`.
|
||||
|
||||
"""
|
||||
# a mapping {'exits': [...], 'characters': [...], 'things': [...]}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ The custom manager for Scripts.
|
|||
|
||||
from django.conf import settings
|
||||
from django.db.models import Q
|
||||
|
||||
from evennia.server import signals
|
||||
from evennia.typeclasses.managers import TypeclassManager, TypedObjectManager
|
||||
from evennia.utils.utils import class_from_module, dbid_to_obj, make_iter
|
||||
|
|
|
|||
|
|
@ -78,26 +78,28 @@ class TestScriptHandler(BaseEvenniaTest):
|
|||
|
||||
def setUp(self):
|
||||
self.obj, self.errors = DefaultObject.create("test_object")
|
||||
self.obj.scripts.add(TestingListIntervalScript)
|
||||
|
||||
def tearDown(self):
|
||||
self.obj.delete()
|
||||
|
||||
def test_start(self):
|
||||
"Check that ScriptHandler start function works correctly"
|
||||
self.obj.scripts.add(TestingListIntervalScript)
|
||||
self.num = self.obj.scripts.start(self.obj.scripts.all()[0].key)
|
||||
self.assertTrue(self.num == 1)
|
||||
self.assertEqual(self.num, 1)
|
||||
|
||||
def test_list_script_intervals(self):
|
||||
"Checks that Scripthandler __str__ function lists script intervals correctly"
|
||||
self.obj.scripts.add(TestingListIntervalScript)
|
||||
self.str = str(self.obj.scripts)
|
||||
self.assertTrue("None/1" in self.str)
|
||||
self.assertTrue("1 repeats" in self.str)
|
||||
|
||||
def test_get_all_scripts(self):
|
||||
"Checks that Scripthandler get_all returns correct number of scripts"
|
||||
self.assertEqual([script.key for script in self.obj.scripts.all()], ["interval_test"])
|
||||
|
||||
def test_get_script(self):
|
||||
"Checks that Scripthandler get function returns correct script"
|
||||
self.obj.scripts.add(TestingListIntervalScript)
|
||||
script = self.obj.scripts.get("interval_test")
|
||||
self.assertTrue(bool(script))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue