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.contrib.contenttypes.models import ContentType
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
|
|
||||||
from evennia.comms.managers import ChannelManager
|
from evennia.comms.managers import ChannelManager
|
||||||
from evennia.comms.models import ChannelDB
|
from evennia.comms.models import ChannelDB
|
||||||
from evennia.typeclasses.models import TypeclassBase
|
from evennia.typeclasses.models import TypeclassBase
|
||||||
|
|
@ -188,7 +187,7 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
|
||||||
# display listening subscribers in bold
|
# display listening subscribers in bold
|
||||||
string = ", ".join(
|
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
|
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.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from evennia.comms import managers
|
from evennia.comms import managers
|
||||||
from evennia.locks.lockhandler import LockHandler
|
from evennia.locks.lockhandler import LockHandler
|
||||||
from evennia.typeclasses.models import TypedObject
|
from evennia.typeclasses.models import TypedObject
|
||||||
|
|
@ -104,8 +103,10 @@ class Msg(SharedMemoryModel):
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
db_index=True,
|
db_index=True,
|
||||||
help_text="Identifier for single external sender, for use with senders "
|
help_text=(
|
||||||
"not represented by a regular database model.",
|
"Identifier for single external sender, for use with senders "
|
||||||
|
"not represented by a regular database model."
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
db_receivers_accounts = models.ManyToManyField(
|
db_receivers_accounts = models.ManyToManyField(
|
||||||
|
|
@ -137,8 +138,10 @@ class Msg(SharedMemoryModel):
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
db_index=True,
|
db_index=True,
|
||||||
help_text="Identifier for single external receiver, for use with recievers "
|
help_text=(
|
||||||
"not represented by a regular database model.",
|
"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
|
# 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(
|
db_tags = models.ManyToManyField(
|
||||||
Tag,
|
Tag,
|
||||||
blank=True,
|
blank=True,
|
||||||
help_text="tags on this message. Tags are simple string markers to "
|
help_text=(
|
||||||
"identify, group and alias messages.",
|
"tags on this message. Tags are simple string markers to "
|
||||||
|
"identify, group and alias messages."
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Database manager
|
# Database manager
|
||||||
|
|
@ -518,7 +523,7 @@ class TempMsg:
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
class SubscriptionHandler(object):
|
class SubscriptionHandler:
|
||||||
"""
|
"""
|
||||||
This handler manages subscriptions to the
|
This handler manages subscriptions to the
|
||||||
channel and hides away which type of entity is
|
channel and hides away which type of entity is
|
||||||
|
|
@ -540,13 +545,13 @@ class SubscriptionHandler(object):
|
||||||
def _recache(self):
|
def _recache(self):
|
||||||
self._cache = {
|
self._cache = {
|
||||||
account: True
|
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
|
if hasattr(account, "pk") and account.pk
|
||||||
}
|
}
|
||||||
self._cache.update(
|
self._cache.update(
|
||||||
{
|
{
|
||||||
obj: True
|
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
|
if hasattr(obj, "pk") and obj.pk
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
||||||
|
|
||||||
objects = ObjectManager()
|
objects = ObjectManager()
|
||||||
|
|
||||||
# populated by `return_apperance`
|
# populated by `return_appearance`
|
||||||
appearance_template = """
|
appearance_template = """
|
||||||
{header}
|
{header}
|
||||||
|c{name}|n
|
|c{name}|n
|
||||||
|
|
@ -1201,7 +1201,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
||||||
self.at_access(result, accessing_obj, access_type, **kwargs)
|
self.at_access(result, accessing_obj, access_type, **kwargs)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# name and return_apperance hooks
|
# name and return_appearance hooks
|
||||||
|
|
||||||
def get_display_name(self, looker=None, **kwargs):
|
def get_display_name(self, looker=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
@ -2111,7 +2111,7 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
||||||
Notes:
|
Notes:
|
||||||
This method shouldn't add extra coloring to the names beyond what is
|
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.
|
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': [...]}
|
# a mapping {'exits': [...], 'characters': [...], 'things': [...]}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ The custom manager for Scripts.
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
|
||||||
from evennia.server import signals
|
from evennia.server import signals
|
||||||
from evennia.typeclasses.managers import TypeclassManager, TypedObjectManager
|
from evennia.typeclasses.managers import TypeclassManager, TypedObjectManager
|
||||||
from evennia.utils.utils import class_from_module, dbid_to_obj, make_iter
|
from evennia.utils.utils import class_from_module, dbid_to_obj, make_iter
|
||||||
|
|
|
||||||
|
|
@ -78,26 +78,28 @@ class TestScriptHandler(BaseEvenniaTest):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.obj, self.errors = DefaultObject.create("test_object")
|
self.obj, self.errors = DefaultObject.create("test_object")
|
||||||
|
self.obj.scripts.add(TestingListIntervalScript)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.obj.delete()
|
self.obj.delete()
|
||||||
|
|
||||||
def test_start(self):
|
def test_start(self):
|
||||||
"Check that ScriptHandler start function works correctly"
|
"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.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):
|
def test_list_script_intervals(self):
|
||||||
"Checks that Scripthandler __str__ function lists script intervals correctly"
|
"Checks that Scripthandler __str__ function lists script intervals correctly"
|
||||||
self.obj.scripts.add(TestingListIntervalScript)
|
|
||||||
self.str = str(self.obj.scripts)
|
self.str = str(self.obj.scripts)
|
||||||
self.assertTrue("None/1" in self.str)
|
self.assertTrue("None/1" in self.str)
|
||||||
self.assertTrue("1 repeats" 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):
|
def test_get_script(self):
|
||||||
"Checks that Scripthandler get function returns correct script"
|
"Checks that Scripthandler get function returns correct script"
|
||||||
self.obj.scripts.add(TestingListIntervalScript)
|
|
||||||
script = self.obj.scripts.get("interval_test")
|
script = self.obj.scripts.get("interval_test")
|
||||||
self.assertTrue(bool(script))
|
self.assertTrue(bool(script))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue