Format code with black. Add makefile to run fmt/tests

This commit is contained in:
Griatch 2019-09-28 18:18:11 +02:00
parent d00bce9288
commit c2c7fa311a
299 changed files with 19037 additions and 11611 deletions

View file

@ -14,6 +14,7 @@ class ChannelAttributeInline(AttributeInline):
Inline display of Channel Attribute - experimental
"""
model = ChannelDB.db_attributes.through
related_field = "channeldb"
@ -23,6 +24,7 @@ class ChannelTagInline(TagInline):
Inline display of Channel Tags - experimental
"""
model = ChannelDB.db_tags.through
related_field = "channeldb"
@ -32,16 +34,26 @@ class MsgAdmin(admin.ModelAdmin):
Defines display for Msg objects
"""
list_display = ('id', 'db_date_created', 'db_sender', 'db_receivers',
'db_channels', 'db_message', 'db_lock_storage')
list_display = (
"id",
"db_date_created",
"db_sender",
"db_receivers",
"db_channels",
"db_message",
"db_lock_storage",
)
list_display_links = ("id",)
ordering = ["db_date_created", 'db_sender', 'db_receivers', 'db_channels']
#readonly_fields = ['db_message', 'db_sender', 'db_receivers', 'db_channels']
search_fields = ['id', '^db_date_created', '^db_message']
ordering = ["db_date_created", "db_sender", "db_receivers", "db_channels"]
# readonly_fields = ['db_message', 'db_sender', 'db_receivers', 'db_channels']
search_fields = ["id", "^db_date_created", "^db_message"]
save_as = True
save_on_top = True
list_select_related = True
#admin.site.register(Msg, MsgAdmin)
# admin.site.register(Msg, MsgAdmin)
class ChannelAdmin(admin.ModelAdmin):
@ -49,17 +61,28 @@ class ChannelAdmin(admin.ModelAdmin):
Defines display for Channel objects
"""
inlines = [ChannelTagInline, ChannelAttributeInline]
list_display = ('id', 'db_key', 'db_lock_storage', "subscriptions")
list_display_links = ("id", 'db_key')
list_display = ("id", "db_key", "db_lock_storage", "subscriptions")
list_display_links = ("id", "db_key")
ordering = ["db_key"]
search_fields = ['id', 'db_key', 'db_tags__db_key']
search_fields = ["id", "db_key", "db_tags__db_key"]
save_as = True
save_on_top = True
list_select_related = True
raw_id_fields = ('db_object_subscriptions', 'db_account_subscriptions',)
raw_id_fields = ("db_object_subscriptions", "db_account_subscriptions")
fieldsets = (
(None, {'fields': (('db_key',), 'db_lock_storage', 'db_account_subscriptions', 'db_object_subscriptions')}),
(
None,
{
"fields": (
("db_key",),
"db_lock_storage",
"db_account_subscriptions",
"db_object_subscriptions",
)
},
),
)
def subscriptions(self, obj):
@ -93,6 +116,7 @@ class ChannelAdmin(admin.ModelAdmin):
def response_add(self, request, obj, post_url_continue=None):
from django.http import HttpResponseRedirect
from django.urls import reverse
return HttpResponseRedirect(reverse("admin:comms_channeldb_change", args=[obj.id]))

View file

@ -55,6 +55,7 @@ class ChannelCommand(command.Command):
{lower_channelkey}/history 30
"""
# ^note that channeldesc and lower_channelkey will be filled
# automatically by ChannelHandler
@ -106,12 +107,12 @@ class ChannelCommand(command.Command):
string = _("You are not connected to channel '%s'.")
self.msg(string % channelkey)
return
if not channel.access(caller, 'send'):
if not channel.access(caller, "send"):
string = _("You are not permitted to send to channel '%s'.")
self.msg(string % channelkey)
return
if msg == "on":
caller = caller if not hasattr(caller, 'account') else caller.account
caller = caller if not hasattr(caller, "account") else caller.account
unmuted = channel.unmute(caller)
if unmuted:
self.msg("You start listening to %s." % channel)
@ -119,7 +120,7 @@ class ChannelCommand(command.Command):
self.msg("You were already listening to %s." % channel)
return
if msg == "off":
caller = caller if not hasattr(caller, 'account') else caller.account
caller = caller if not hasattr(caller, "account") else caller.account
muted = channel.mute(caller)
if muted:
self.msg("You stop listening to %s." % channel)
@ -130,11 +131,14 @@ class ChannelCommand(command.Command):
# Try to view history
log_file = channel.attributes.get("log_file", default="channel_%s.log" % channel.key)
def send_msg(lines): return self.msg("".join(line.split("[-]", 1)[1]
if "[-]" in line else line for line in lines))
def send_msg(lines):
return self.msg(
"".join(line.split("[-]", 1)[1] if "[-]" in line else line for line in lines)
)
tail_log_file(log_file, self.history_start, 20, callback=send_msg)
else:
caller = caller if not hasattr(caller, 'account') else caller.account
caller = caller if not hasattr(caller, "account") else caller.account
if caller in channel.mutelist:
self.msg("You currently have %s muted." % channel)
return
@ -216,16 +220,19 @@ class ChannelHandler(object):
locks="cmd:all();%s" % channel.locks,
help_category="Channel names",
obj=channel,
is_channel=True)
is_channel=True,
)
# format the help entry
key = channel.key
cmd.__doc__ = cmd.__doc__.format(channelkey=key,
lower_channelkey=key.strip().lower(),
channeldesc=channel.attributes.get(
"desc", default="").strip())
cmd.__doc__ = cmd.__doc__.format(
channelkey=key,
lower_channelkey=key.strip().lower(),
channeldesc=channel.attributes.get("desc", default="").strip(),
)
self._cached_channel_cmds[channel] = cmd
self._cached_channels[key] = channel
self._cached_cmdsets = {}
add_channel = add # legacy alias
def remove(self, channel):
@ -290,12 +297,15 @@ class ChannelHandler(object):
else:
# create a new cmdset holding all viable channels
chan_cmdset = None
chan_cmds = [channelcmd for channel, channelcmd in self._cached_channel_cmds.items()
if channel.subscriptions.has(source_object) and
channelcmd.access(source_object, 'send')]
chan_cmds = [
channelcmd
for channel, channelcmd in self._cached_channel_cmds.items()
if channel.subscriptions.has(source_object)
and channelcmd.access(source_object, "send")
]
if chan_cmds:
chan_cmdset = cmdset.CmdSet()
chan_cmdset.key = 'ChannelCmdSet'
chan_cmdset.key = "ChannelCmdSet"
chan_cmdset.priority = 101
chan_cmdset.duplicates = True
for cmd in chan_cmds:

View file

@ -21,6 +21,7 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
create different types of communication channels.
"""
objects = ChannelManager()
def at_first_save(self):
@ -105,7 +106,12 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
listening = [ob for ob in subs if ob.is_connected and ob not in muted]
if subs:
# display listening subscribers in bold
string = ", ".join([account.key if account not in listening else "|w%s|n" % account.key for account in subs])
string = ", ".join(
[
account.key if account not in listening else "|w%s|n" % account.key
for account in subs
]
)
else:
string = "<None>"
return string
@ -163,7 +169,7 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
"""
# check access
if not self.access(subscriber, 'listen'):
if not self.access(subscriber, "listen"):
return False
# pre-join hook
connect = self.pre_join_channel(subscriber)
@ -204,7 +210,14 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
self.post_leave_channel(subscriber)
return True
def access(self, accessing_obj, access_type='listen', default=False, no_superuser_bypass=False, **kwargs):
def access(
self,
accessing_obj,
access_type="listen",
default=False,
no_superuser_bypass=False,
**kwargs,
):
"""
Determines if another object has permission to access.
@ -221,8 +234,12 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
return (bool): Result of lock check.
"""
return self.locks.check(accessing_obj, access_type=access_type,
default=default, no_superuser_bypass=no_superuser_bypass)
return self.locks.check(
accessing_obj,
access_type=access_type,
default=default,
no_superuser_bypass=no_superuser_bypass,
)
@classmethod
def create(cls, key, account=None, *args, **kwargs):
@ -252,16 +269,18 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
"""
errors = []
obj = None
ip = kwargs.pop('ip', '')
ip = kwargs.pop("ip", "")
try:
kwargs['desc'] = kwargs.pop('description', '')
kwargs['typeclass'] = kwargs.get('typeclass', cls)
kwargs["desc"] = kwargs.pop("description", "")
kwargs["typeclass"] = kwargs.get("typeclass", cls)
obj = create.create_channel(key, *args, **kwargs)
# Record creator id and creation IP
if ip: obj.db.creator_ip = ip
if account: obj.db.creator_id = account.id
if ip:
obj.db.creator_ip = ip
if account:
obj.db.creator_id = account.id
except Exception as exc:
errors.append("An error occurred while creating this '%s' object." % key)
@ -278,10 +297,12 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
self.aliases.clear()
super().delete()
from evennia.comms.channelhandler import CHANNELHANDLER
CHANNELHANDLER.update()
def message_transform(self, msgobj, emit=False, prefix=True,
sender_strings=None, external=False, **kwargs):
def message_transform(
self, msgobj, emit=False, prefix=True, sender_strings=None, external=False, **kwargs
):
"""
Generates the formatted string sent to listeners on a channel.
@ -333,16 +354,29 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
try:
# note our addition of the from_channel keyword here. This could be checked
# by a custom account.msg() to treat channel-receives differently.
entity.msg(msgobj.message, from_obj=msgobj.senders, options={"from_channel": self.id})
entity.msg(
msgobj.message, from_obj=msgobj.senders, options={"from_channel": self.id}
)
except AttributeError as e:
logger.log_trace("%s\nCannot send msg to '%s'." % (e, entity))
if msgobj.keep_log:
# log to file
logger.log_file(msgobj.message, self.attributes.get("log_file") or "channel_%s.log" % self.key)
logger.log_file(
msgobj.message, self.attributes.get("log_file") or "channel_%s.log" % self.key
)
def msg(self, msgobj, header=None, senders=None, sender_strings=None,
keep_log=None, online=False, emit=False, external=False):
def msg(
self,
msgobj,
header=None,
senders=None,
sender_strings=None,
keep_log=None,
online=False,
emit=False,
external=False,
):
"""
Send the given message to all accounts connected to channel. Note that
no permission-checking is done here; it is assumed to have been
@ -391,9 +425,9 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
msgobj = self.pre_send_message(msgobj)
if not msgobj:
return False
msgobj = self.message_transform(msgobj, emit=emit,
sender_strings=sender_strings,
external=external)
msgobj = self.message_transform(
msgobj, emit=emit, sender_strings=sender_strings, external=external
)
self.distribute_message(msgobj, online=online)
self.post_send_message(msgobj)
return True
@ -427,7 +461,7 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
prefix (str): The created channel prefix.
"""
return '' if emit else '[%s] ' % self.key
return "" if emit else "[%s] " % self.key
def format_senders(self, senders=None, **kwargs):
"""
@ -448,8 +482,8 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
"""
if not senders:
return ''
return ', '.join(senders)
return ""
return ", ".join(senders)
def pose_transform(self, msgobj, sender_string, **kwargs):
"""
@ -472,16 +506,16 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
pose = False
message = msgobj.message
message_start = message.lstrip()
if message_start.startswith((':', ';')):
if message_start.startswith((":", ";")):
pose = True
message = message[1:]
if not message.startswith((':', "'", ',')):
if not message.startswith(' '):
message = ' ' + message
if not message.startswith((":", "'", ",")):
if not message.startswith(" "):
message = " " + message
if pose:
return '%s%s' % (sender_string, message)
return "%s%s" % (sender_string, message)
else:
return '%s: %s' % (sender_string, message)
return "%s: %s" % (sender_string, message)
def format_external(self, msgobj, senders, emit=False, **kwargs):
"""
@ -503,7 +537,7 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
"""
if emit or not senders:
return msgobj.message
senders = ', '.join(senders)
senders = ", ".join(senders)
return self.pose_transform(msgobj, senders)
def format_message(self, msgobj, emit=False, **kwargs):
@ -522,14 +556,14 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
"""
# We don't want to count things like external sources as senders for
# the purpose of constructing the message string.
senders = [sender for sender in msgobj.senders if hasattr(sender, 'key')]
senders = [sender for sender in msgobj.senders if hasattr(sender, "key")]
if not senders:
emit = True
if emit:
return msgobj.message
else:
senders = [sender.key for sender in msgobj.senders]
senders = ', '.join(senders)
senders = ", ".join(senders)
return self.pose_transform(msgobj, senders)
def pre_join_channel(self, joiner, **kwargs):
@ -643,8 +677,9 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
"""
content_type = ContentType.objects.get_for_model(self.__class__)
return reverse("admin:%s_%s_change" % (content_type.app_label,
content_type.model), args=(self.id,))
return reverse(
"admin:%s_%s_change" % (content_type.app_label, content_type.model), args=(self.id,)
)
@classmethod
def web_get_create_url(cls):
@ -673,9 +708,9 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
"""
try:
return reverse('%s-create' % slugify(cls._meta.verbose_name))
return reverse("%s-create" % slugify(cls._meta.verbose_name))
except:
return '#'
return "#"
def web_get_detail_url(self):
"""
@ -704,11 +739,12 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
"""
try:
return reverse('%s-detail' % slugify(self._meta.verbose_name),
kwargs={'slug': slugify(self.db_key)})
return reverse(
"%s-detail" % slugify(self._meta.verbose_name),
kwargs={"slug": slugify(self.db_key)},
)
except:
return '#'
return "#"
def web_get_update_url(self):
"""
@ -737,10 +773,12 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
"""
try:
return reverse('%s-update' % slugify(self._meta.verbose_name),
kwargs={'slug': slugify(self.db_key)})
return reverse(
"%s-update" % slugify(self._meta.verbose_name),
kwargs={"slug": slugify(self.db_key)},
)
except:
return '#'
return "#"
def web_get_delete_url(self):
"""
@ -768,10 +806,12 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
"""
try:
return reverse('%s-delete' % slugify(self._meta.verbose_name),
kwargs={'slug': slugify(self.db_key)})
return reverse(
"%s-delete" % slugify(self._meta.verbose_name),
kwargs={"slug": slugify(self.db_key)},
)
except:
return '#'
return "#"
# Used by Django Sites/Admin
get_absolute_url = web_get_detail_url

View file

@ -6,7 +6,7 @@ Comm system components.
from django.db.models import Q
from evennia.typeclasses.managers import (TypedObjectManager, TypeclassManager)
from evennia.typeclasses.managers import TypedObjectManager, TypeclassManager
from evennia.utils import logger
_GA = object.__getattribute__
@ -22,6 +22,7 @@ class CommError(Exception):
"""
Raised by comm system, to allow feedback to player when caught.
"""
pass
@ -29,6 +30,7 @@ class CommError(Exception):
# helper functions
#
def dbref(inp, reqhash=True):
"""
Valid forms of dbref (database reference number) are either a
@ -46,7 +48,7 @@ def dbref(inp, reqhash=True):
if reqhash and not (isinstance(inp, str) and inp.startswith("#")):
return None
if isinstance(inp, str):
inp = inp.lstrip('#')
inp = inp.lstrip("#")
try:
if int(inp) < 0:
return None
@ -85,7 +87,7 @@ def identify_object(inp):
return inp, None
def to_object(inp, objtype='account'):
def to_object(inp, objtype="account"):
"""
Locates the object related to the given accountname or channel key.
If input was already the correct object, return it.
@ -101,28 +103,28 @@ def to_object(inp, objtype='account'):
obj, typ = identify_object(inp)
if typ == objtype:
return obj
if objtype == 'account':
if typ == 'object':
if objtype == "account":
if typ == "object":
return obj.account
if typ == 'string':
if typ == "string":
return _AccountDB.objects.get(user_username__iexact=obj)
if typ == 'dbref':
if typ == "dbref":
return _AccountDB.objects.get(id=obj)
logger.log_err("%s %s %s %s %s" % (objtype, inp, obj, typ, type(inp)))
raise CommError()
elif objtype == 'object':
if typ == 'account':
elif objtype == "object":
if typ == "account":
return obj.obj
if typ == 'string':
if typ == "string":
return _ObjectDB.objects.get(db_key__iexact=obj)
if typ == 'dbref':
if typ == "dbref":
return _ObjectDB.objects.get(id=obj)
logger.log_err("%s %s %s %s %s" % (objtype, inp, obj, typ, type(inp)))
raise CommError()
elif objtype == 'channel':
if typ == 'string':
elif objtype == "channel":
if typ == "string":
return _ChannelDB.objects.get(db_key__iexact=obj)
if typ == 'dbref':
if typ == "dbref":
return _ChannelDB.objects.get(id=obj)
logger.log_err("%s %s %s %s %s" % (objtype, inp, obj, typ, type(inp)))
raise CommError()
@ -134,6 +136,7 @@ def to_object(inp, objtype='account'):
# Msg manager
#
class MsgManager(TypedObjectManager):
"""
This MsgManager implements methods for searching and manipulating
@ -200,19 +203,25 @@ class MsgManager(TypedObjectManager):
obj, typ = identify_object(sender)
if exclude_channel_messages:
# explicitly exclude channel recipients
if typ == 'account':
return list(self.filter(db_sender_accounts=obj,
db_receivers_channels__isnull=True).exclude(db_hide_from_accounts=obj))
elif typ == 'object':
return list(self.filter(db_sender_objects=obj,
db_receivers_channels__isnull=True).exclude(db_hide_from_objects=obj))
if typ == "account":
return list(
self.filter(db_sender_accounts=obj, db_receivers_channels__isnull=True).exclude(
db_hide_from_accounts=obj
)
)
elif typ == "object":
return list(
self.filter(db_sender_objects=obj, db_receivers_channels__isnull=True).exclude(
db_hide_from_objects=obj
)
)
else:
raise CommError
else:
# get everything, channel or not
if typ == 'account':
if typ == "account":
return list(self.filter(db_sender_accounts=obj).exclude(db_hide_from_accounts=obj))
elif typ == 'object':
elif typ == "object":
return list(self.filter(db_sender_objects=obj).exclude(db_hide_from_objects=obj))
else:
raise CommError
@ -232,11 +241,11 @@ class MsgManager(TypedObjectManager):
"""
obj, typ = identify_object(recipient)
if typ == 'account':
if typ == "account":
return list(self.filter(db_receivers_accounts=obj).exclude(db_hide_from_accounts=obj))
elif typ == 'object':
elif typ == "object":
return list(self.filter(db_receivers_objects=obj).exclude(db_hide_from_objects=obj))
elif typ == 'channel':
elif typ == "channel":
return list(self.filter(db_receivers_channels=obj).exclude(db_hide_from_channels=obj))
else:
raise CommError
@ -287,20 +296,24 @@ class MsgManager(TypedObjectManager):
# filter by sender
sender, styp = identify_object(sender)
if styp == 'account':
if styp == "account":
sender_restrict = Q(db_sender_accounts=sender) & ~Q(db_hide_from_accounts=sender)
elif styp == 'object':
elif styp == "object":
sender_restrict = Q(db_sender_objects=sender) & ~Q(db_hide_from_objects=sender)
else:
sender_restrict = Q()
# filter by receiver
receiver, rtyp = identify_object(receiver)
if rtyp == 'account':
receiver_restrict = Q(db_receivers_accounts=receiver) & ~Q(db_hide_from_accounts=receiver)
elif rtyp == 'object':
if rtyp == "account":
receiver_restrict = Q(db_receivers_accounts=receiver) & ~Q(
db_hide_from_accounts=receiver
)
elif rtyp == "object":
receiver_restrict = Q(db_receivers_objects=receiver) & ~Q(db_hide_from_objects=receiver)
elif rtyp == 'channel':
receiver_restrict = Q(db_receivers_channels=receiver) & ~Q(db_hide_from_channels=receiver)
elif rtyp == "channel":
receiver_restrict = Q(db_receivers_channels=receiver) & ~Q(
db_hide_from_channels=receiver
)
else:
receiver_restrict = Q()
# filter by full text
@ -310,6 +323,7 @@ class MsgManager(TypedObjectManager):
fulltext_restrict = Q()
# execute the query
return list(self.filter(sender_restrict & receiver_restrict & fulltext_restrict))
# back-compatibility alias
message_search = search_message
@ -318,6 +332,7 @@ class MsgManager(TypedObjectManager):
# Channel manager
#
class ChannelDBManager(TypedObjectManager):
"""
This ChannelManager implements methods for searching and
@ -361,9 +376,10 @@ class ChannelDBManager(TypedObjectManager):
return self.get(id=dbref)
except self.model.DoesNotExist:
pass
results = self.filter(Q(db_key__iexact=channelkey) |
Q(db_tags__db_tagtype__iexact="alias",
db_tags__db_key__iexact=channelkey)).distinct()
results = self.filter(
Q(db_key__iexact=channelkey)
| Q(db_tags__db_tagtype__iexact="alias", db_tags__db_key__iexact=channelkey)
).distinct()
return results[0] if results else None
def get_subscriptions(self, subscriber):
@ -401,14 +417,17 @@ class ChannelDBManager(TypedObjectManager):
except self.model.DoesNotExist:
pass
if exact:
channels = self.filter(Q(db_key__iexact=ostring) |
Q(db_tags__db_tagtype__iexact="alias",
db_tags__db_key__iexact=ostring)).distinct()
channels = self.filter(
Q(db_key__iexact=ostring)
| Q(db_tags__db_tagtype__iexact="alias", db_tags__db_key__iexact=ostring)
).distinct()
else:
channels = self.filter(Q(db_key__icontains=ostring) |
Q(db_tags__db_tagtype__iexact="alias",
db_tags__db_key__icontains=ostring)).distinct()
channels = self.filter(
Q(db_key__icontains=ostring)
| Q(db_tags__db_tagtype__iexact="alias", db_tags__db_key__icontains=ostring)
).distinct()
return channels
# back-compatibility alias
channel_search = search_channel
@ -417,4 +436,5 @@ class ChannelManager(ChannelDBManager, TypeclassManager):
"""
Wrapper to group the typeclass manager to a consistent name.
"""
pass

View file

@ -6,39 +6,85 @@ from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
dependencies = []
operations = [
migrations.CreateModel(
name='ChannelDB',
name="ChannelDB",
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('db_key', models.CharField(max_length=255, verbose_name='key', db_index=True)),
('db_typeclass_path', models.CharField(help_text="this defines what 'type' of entity this is. This variable holds a Python path to a module with a valid Evennia Typeclass.", max_length=255, null=True, verbose_name='typeclass')),
('db_date_created', models.DateTimeField(auto_now_add=True, verbose_name='creation date')),
('db_lock_storage', models.TextField(help_text="locks limit access to an entity. A lock is defined as a 'lock string' on the form 'type:lockfunctions', defining what functionality is locked and how to determine access. Not defining a lock means no access is granted.", verbose_name='locks', blank=True)),
(
"id",
models.AutoField(
verbose_name="ID", serialize=False, auto_created=True, primary_key=True
),
),
("db_key", models.CharField(max_length=255, verbose_name="key", db_index=True)),
(
"db_typeclass_path",
models.CharField(
help_text="this defines what 'type' of entity this is. This variable holds a Python path to a module with a valid Evennia Typeclass.",
max_length=255,
null=True,
verbose_name="typeclass",
),
),
(
"db_date_created",
models.DateTimeField(auto_now_add=True, verbose_name="creation date"),
),
(
"db_lock_storage",
models.TextField(
help_text="locks limit access to an entity. A lock is defined as a 'lock string' on the form 'type:lockfunctions', defining what functionality is locked and how to determine access. Not defining a lock means no access is granted.",
verbose_name="locks",
blank=True,
),
),
],
options={
'verbose_name': 'Channel',
'verbose_name_plural': 'Channels',
},
options={"verbose_name": "Channel", "verbose_name_plural": "Channels"},
bases=(models.Model,),
),
migrations.CreateModel(
name='Msg',
name="Msg",
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('db_sender_external', models.CharField(help_text="identifier for external sender, for example a sender over an IRC connection (i.e. someone who doesn't have an exixtence in-game).", max_length=255, null=True, verbose_name='external sender', db_index=True)),
('db_header', models.TextField(null=True, verbose_name='header', blank=True)),
('db_message', models.TextField(verbose_name='messsage')),
('db_date_sent', models.DateTimeField(auto_now_add=True, verbose_name='date sent', db_index=True)),
('db_lock_storage', models.TextField(help_text='access locks on this message.', verbose_name='locks', blank=True)),
('db_hide_from_channels', models.ManyToManyField(related_name='hide_from_channels_set', null=True, to='comms.ChannelDB')),
(
"id",
models.AutoField(
verbose_name="ID", serialize=False, auto_created=True, primary_key=True
),
),
(
"db_sender_external",
models.CharField(
help_text="identifier for external sender, for example a sender over an IRC connection (i.e. someone who doesn't have an exixtence in-game).",
max_length=255,
null=True,
verbose_name="external sender",
db_index=True,
),
),
("db_header", models.TextField(null=True, verbose_name="header", blank=True)),
("db_message", models.TextField(verbose_name="messsage")),
(
"db_date_sent",
models.DateTimeField(
auto_now_add=True, verbose_name="date sent", db_index=True
),
),
(
"db_lock_storage",
models.TextField(
help_text="access locks on this message.", verbose_name="locks", blank=True
),
),
(
"db_hide_from_channels",
models.ManyToManyField(
related_name="hide_from_channels_set", null=True, to="comms.ChannelDB"
),
),
],
options={
'verbose_name': 'Message',
},
options={"verbose_name": "Message"},
bases=(models.Model,),
),
]

View file

@ -6,16 +6,15 @@ from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('objects', '0001_initial'),
('comms', '0001_initial'),
]
dependencies = [("objects", "0001_initial"), ("comms", "0001_initial")]
operations = [
migrations.AddField(
model_name='msg',
name='db_hide_from_objects',
field=models.ManyToManyField(related_name='hide_from_objects_set', null=True, to='objects.ObjectDB'),
model_name="msg",
name="db_hide_from_objects",
field=models.ManyToManyField(
related_name="hide_from_objects_set", null=True, to="objects.ObjectDB"
),
preserve_default=True,
),
)
]

View file

@ -8,65 +8,108 @@ from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('objects', '0001_initial'),
("objects", "0001_initial"),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('typeclasses', '0001_initial'),
('comms', '0002_msg_db_hide_from_objects'),
("typeclasses", "0001_initial"),
("comms", "0002_msg_db_hide_from_objects"),
]
operations = [
migrations.AddField(
model_name='msg',
name='db_hide_from_accounts',
field=models.ManyToManyField(related_name='hide_from_accounts_set', null=True, to=settings.AUTH_USER_MODEL),
model_name="msg",
name="db_hide_from_accounts",
field=models.ManyToManyField(
related_name="hide_from_accounts_set", null=True, to=settings.AUTH_USER_MODEL
),
preserve_default=True,
),
migrations.AddField(
model_name='msg',
name='db_receivers_channels',
field=models.ManyToManyField(help_text='channel recievers', related_name='channel_set', null=True, to='comms.ChannelDB'),
model_name="msg",
name="db_receivers_channels",
field=models.ManyToManyField(
help_text="channel recievers",
related_name="channel_set",
null=True,
to="comms.ChannelDB",
),
preserve_default=True,
),
migrations.AddField(
model_name='msg',
name='db_receivers_objects',
field=models.ManyToManyField(help_text='object receivers', related_name='receiver_object_set', null=True, to='objects.ObjectDB'),
model_name="msg",
name="db_receivers_objects",
field=models.ManyToManyField(
help_text="object receivers",
related_name="receiver_object_set",
null=True,
to="objects.ObjectDB",
),
preserve_default=True,
),
migrations.AddField(
model_name='msg',
name='db_receivers_accounts',
field=models.ManyToManyField(help_text='account receivers', related_name='receiver_account_set', null=True, to=settings.AUTH_USER_MODEL),
model_name="msg",
name="db_receivers_accounts",
field=models.ManyToManyField(
help_text="account receivers",
related_name="receiver_account_set",
null=True,
to=settings.AUTH_USER_MODEL,
),
preserve_default=True,
),
migrations.AddField(
model_name='msg',
name='db_sender_objects',
field=models.ManyToManyField(related_name='sender_object_set', null=True, verbose_name='sender(object)', to='objects.ObjectDB', db_index=True),
model_name="msg",
name="db_sender_objects",
field=models.ManyToManyField(
related_name="sender_object_set",
null=True,
verbose_name="sender(object)",
to="objects.ObjectDB",
db_index=True,
),
preserve_default=True,
),
migrations.AddField(
model_name='msg',
name='db_sender_accounts',
field=models.ManyToManyField(related_name='sender_account_set', null=True, verbose_name='sender(account)', to=settings.AUTH_USER_MODEL, db_index=True),
model_name="msg",
name="db_sender_accounts",
field=models.ManyToManyField(
related_name="sender_account_set",
null=True,
verbose_name="sender(account)",
to=settings.AUTH_USER_MODEL,
db_index=True,
),
preserve_default=True,
),
migrations.AddField(
model_name='channeldb',
name='db_attributes',
field=models.ManyToManyField(help_text='attributes on this object. An attribute can hold any pickle-able python object (see docs for special cases).', to='typeclasses.Attribute', null=True),
model_name="channeldb",
name="db_attributes",
field=models.ManyToManyField(
help_text="attributes on this object. An attribute can hold any pickle-able python object (see docs for special cases).",
to="typeclasses.Attribute",
null=True,
),
preserve_default=True,
),
migrations.AddField(
model_name='channeldb',
name='db_subscriptions',
field=models.ManyToManyField(related_name='subscription_set', null=True, verbose_name='subscriptions', to=settings.AUTH_USER_MODEL, db_index=True),
model_name="channeldb",
name="db_subscriptions",
field=models.ManyToManyField(
related_name="subscription_set",
null=True,
verbose_name="subscriptions",
to=settings.AUTH_USER_MODEL,
db_index=True,
),
preserve_default=True,
),
migrations.AddField(
model_name='channeldb',
name='db_tags',
field=models.ManyToManyField(help_text='tags on this object. Tags are simple string markers to identify, group and alias objects.', to='typeclasses.Tag', null=True),
model_name="channeldb",
name="db_tags",
field=models.ManyToManyField(
help_text="tags on this object. Tags are simple string markers to identify, group and alias objects.",
to="typeclasses.Tag",
null=True,
),
preserve_default=True,
),
]

View file

@ -13,10 +13,6 @@ def convert_defaults(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
('comms', '0003_auto_20140917_0756'),
]
dependencies = [("comms", "0003_auto_20140917_0756")]
operations = [
migrations.RunPython(convert_defaults),
]
operations = [migrations.RunPython(convert_defaults)]

View file

@ -17,10 +17,6 @@ def convert_channelnames(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
('comms', '0004_auto_20150118_1631'),
]
dependencies = [("comms", "0004_auto_20150118_1631")]
operations = [
migrations.RunPython(convert_channelnames),
]
operations = [migrations.RunPython(convert_channelnames)]

View file

@ -6,16 +6,19 @@ from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('objects', '0004_auto_20150118_1622'),
('comms', '0005_auto_20150223_1517'),
]
dependencies = [("objects", "0004_auto_20150118_1622"), ("comms", "0005_auto_20150223_1517")]
operations = [
migrations.AddField(
model_name='channeldb',
name='db_object_subscriptions',
field=models.ManyToManyField(related_name='object_subscription_set', null=True, verbose_name='subscriptions', to='objects.ObjectDB', db_index=True),
model_name="channeldb",
name="db_object_subscriptions",
field=models.ManyToManyField(
related_name="object_subscription_set",
null=True,
verbose_name="subscriptions",
to="objects.ObjectDB",
db_index=True,
),
preserve_default=True,
),
)
]

View file

@ -7,14 +7,18 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('typeclasses', '0004_auto_20151101_1759'),
('comms', '0006_channeldb_db_object_subscriptions'),
("typeclasses", "0004_auto_20151101_1759"),
("comms", "0006_channeldb_db_object_subscriptions"),
]
operations = [
migrations.AddField(
model_name='msg',
name='db_tags',
field=models.ManyToManyField(help_text='tags on this message. Tags are simple string markers to identify, group and alias messages.', to='typeclasses.Tag', null=True),
),
model_name="msg",
name="db_tags",
field=models.ManyToManyField(
help_text="tags on this message. Tags are simple string markers to identify, group and alias messages.",
to="typeclasses.Tag",
null=True,
),
)
]

View file

@ -7,18 +7,11 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('comms', '0007_msg_db_tags'),
]
dependencies = [("comms", "0007_msg_db_tags")]
operations = [
migrations.AlterModelOptions(
name='msg',
options={'verbose_name': 'Msg'},
),
migrations.AlterModelOptions(name="msg", options={"verbose_name": "Msg"}),
migrations.RenameField(
model_name='msg',
old_name='db_date_sent',
new_name='db_date_created',
model_name="msg", old_name="db_date_sent", new_name="db_date_created"
),
]

View file

@ -8,59 +8,110 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('comms', '0008_auto_20160905_0902'),
]
dependencies = [("comms", "0008_auto_20160905_0902")]
operations = [
migrations.AlterField(
model_name='msg',
name='db_hide_from_channels',
field=models.ManyToManyField(blank=True, null=True, related_name='hide_from_channels_set', to='comms.ChannelDB'),
model_name="msg",
name="db_hide_from_channels",
field=models.ManyToManyField(
blank=True, null=True, related_name="hide_from_channels_set", to="comms.ChannelDB"
),
),
migrations.AlterField(
model_name='msg',
name='db_hide_from_objects',
field=models.ManyToManyField(blank=True, null=True, related_name='hide_from_objects_set', to='objects.ObjectDB'),
model_name="msg",
name="db_hide_from_objects",
field=models.ManyToManyField(
blank=True, null=True, related_name="hide_from_objects_set", to="objects.ObjectDB"
),
),
migrations.AlterField(
model_name='msg',
name='db_hide_from_accounts',
field=models.ManyToManyField(blank=True, null=True, related_name='hide_from_accounts_set', to=settings.AUTH_USER_MODEL),
model_name="msg",
name="db_hide_from_accounts",
field=models.ManyToManyField(
blank=True,
null=True,
related_name="hide_from_accounts_set",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_channels',
field=models.ManyToManyField(blank=True, help_text='channel recievers', null=True, related_name='channel_set', to='comms.ChannelDB'),
model_name="msg",
name="db_receivers_channels",
field=models.ManyToManyField(
blank=True,
help_text="channel recievers",
null=True,
related_name="channel_set",
to="comms.ChannelDB",
),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_objects',
field=models.ManyToManyField(blank=True, help_text='object receivers', null=True, related_name='receiver_object_set', to='objects.ObjectDB'),
model_name="msg",
name="db_receivers_objects",
field=models.ManyToManyField(
blank=True,
help_text="object receivers",
null=True,
related_name="receiver_object_set",
to="objects.ObjectDB",
),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_accounts',
field=models.ManyToManyField(blank=True, help_text='account receivers', null=True, related_name='receiver_account_set', to=settings.AUTH_USER_MODEL),
model_name="msg",
name="db_receivers_accounts",
field=models.ManyToManyField(
blank=True,
help_text="account receivers",
null=True,
related_name="receiver_account_set",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name='msg',
name='db_sender_external',
field=models.CharField(blank=True, db_index=True, help_text="identifier for external sender, for example a sender over an IRC connection (i.e. someone who doesn't have an exixtence in-game).", max_length=255, null=True, verbose_name='external sender'),
model_name="msg",
name="db_sender_external",
field=models.CharField(
blank=True,
db_index=True,
help_text="identifier for external sender, for example a sender over an IRC connection (i.e. someone who doesn't have an exixtence in-game).",
max_length=255,
null=True,
verbose_name="external sender",
),
),
migrations.AlterField(
model_name='msg',
name='db_sender_objects',
field=models.ManyToManyField(blank=True, db_index=True, null=True, related_name='sender_object_set', to='objects.ObjectDB', verbose_name='sender(object)'),
model_name="msg",
name="db_sender_objects",
field=models.ManyToManyField(
blank=True,
db_index=True,
null=True,
related_name="sender_object_set",
to="objects.ObjectDB",
verbose_name="sender(object)",
),
),
migrations.AlterField(
model_name='msg',
name='db_sender_accounts',
field=models.ManyToManyField(blank=True, db_index=True, null=True, related_name='sender_account_set', to=settings.AUTH_USER_MODEL, verbose_name='sender(account)'),
model_name="msg",
name="db_sender_accounts",
field=models.ManyToManyField(
blank=True,
db_index=True,
null=True,
related_name="sender_account_set",
to=settings.AUTH_USER_MODEL,
verbose_name="sender(account)",
),
),
migrations.AlterField(
model_name='msg',
name='db_tags',
field=models.ManyToManyField(blank=True, help_text='tags on this message. Tags are simple string markers to identify, group and alias messages.', null=True, to='typeclasses.Tag'),
model_name="msg",
name="db_tags",
field=models.ManyToManyField(
blank=True,
help_text="tags on this message. Tags are simple string markers to identify, group and alias messages.",
null=True,
to="typeclasses.Tag",
),
),
]

View file

@ -8,19 +8,31 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('comms', '0009_auto_20160921_1731'),
]
dependencies = [("comms", "0009_auto_20160921_1731")]
operations = [
migrations.AlterField(
model_name='channeldb',
name='db_object_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, null=True, related_name='object_subscription_set', to='objects.ObjectDB', verbose_name='subscriptions'),
model_name="channeldb",
name="db_object_subscriptions",
field=models.ManyToManyField(
blank=True,
db_index=True,
null=True,
related_name="object_subscription_set",
to="objects.ObjectDB",
verbose_name="subscriptions",
),
),
migrations.AlterField(
model_name='channeldb',
name='db_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, null=True, related_name='subscription_set', to=settings.AUTH_USER_MODEL, verbose_name='subscriptions'),
model_name="channeldb",
name="db_subscriptions",
field=models.ManyToManyField(
blank=True,
db_index=True,
null=True,
related_name="subscription_set",
to=settings.AUTH_USER_MODEL,
verbose_name="subscriptions",
),
),
]

View file

@ -7,20 +7,30 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('scripts', '0007_auto_20150403_2339'),
('comms', '0010_auto_20161206_1912'),
]
dependencies = [("scripts", "0007_auto_20150403_2339"), ("comms", "0010_auto_20161206_1912")]
operations = [
migrations.AddField(
model_name='msg',
name='db_receivers_scripts',
field=models.ManyToManyField(blank=True, help_text='script_receivers', null=True, related_name='receiver_script_set', to='scripts.ScriptDB'),
model_name="msg",
name="db_receivers_scripts",
field=models.ManyToManyField(
blank=True,
help_text="script_receivers",
null=True,
related_name="receiver_script_set",
to="scripts.ScriptDB",
),
),
migrations.AddField(
model_name='msg',
name='db_sender_scripts',
field=models.ManyToManyField(blank=True, db_index=True, null=True, related_name='sender_script_set', to='scripts.ScriptDB', verbose_name='sender(script)'),
model_name="msg",
name="db_sender_scripts",
field=models.ManyToManyField(
blank=True,
db_index=True,
null=True,
related_name="sender_script_set",
to="scripts.ScriptDB",
verbose_name="sender(script)",
),
),
]

View file

@ -8,74 +8,127 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('comms', '0010_auto_20161206_1912'),
]
dependencies = [("comms", "0010_auto_20161206_1912")]
operations = [
migrations.AlterField(
model_name='channeldb',
name='db_attributes',
field=models.ManyToManyField(help_text='attributes on this object. An attribute can hold any pickle-able python object (see docs for special cases).', to='typeclasses.Attribute'),
model_name="channeldb",
name="db_attributes",
field=models.ManyToManyField(
help_text="attributes on this object. An attribute can hold any pickle-able python object (see docs for special cases).",
to="typeclasses.Attribute",
),
),
migrations.AlterField(
model_name='channeldb',
name='db_object_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='object_subscription_set', to='objects.ObjectDB', verbose_name='subscriptions'),
model_name="channeldb",
name="db_object_subscriptions",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="object_subscription_set",
to="objects.ObjectDB",
verbose_name="subscriptions",
),
),
migrations.AlterField(
model_name='channeldb',
name='db_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='subscription_set', to=settings.AUTH_USER_MODEL, verbose_name='subscriptions'),
model_name="channeldb",
name="db_subscriptions",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="subscription_set",
to=settings.AUTH_USER_MODEL,
verbose_name="subscriptions",
),
),
migrations.AlterField(
model_name='channeldb',
name='db_tags',
field=models.ManyToManyField(help_text='tags on this object. Tags are simple string markers to identify, group and alias objects.', to='typeclasses.Tag'),
model_name="channeldb",
name="db_tags",
field=models.ManyToManyField(
help_text="tags on this object. Tags are simple string markers to identify, group and alias objects.",
to="typeclasses.Tag",
),
),
migrations.AlterField(
model_name='msg',
name='db_hide_from_channels',
field=models.ManyToManyField(blank=True, related_name='hide_from_channels_set', to='comms.ChannelDB'),
model_name="msg",
name="db_hide_from_channels",
field=models.ManyToManyField(
blank=True, related_name="hide_from_channels_set", to="comms.ChannelDB"
),
),
migrations.AlterField(
model_name='msg',
name='db_hide_from_objects',
field=models.ManyToManyField(blank=True, related_name='hide_from_objects_set', to='objects.ObjectDB'),
model_name="msg",
name="db_hide_from_objects",
field=models.ManyToManyField(
blank=True, related_name="hide_from_objects_set", to="objects.ObjectDB"
),
),
migrations.AlterField(
model_name='msg',
name='db_hide_from_accounts',
field=models.ManyToManyField(blank=True, related_name='hide_from_accounts_set', to=settings.AUTH_USER_MODEL),
model_name="msg",
name="db_hide_from_accounts",
field=models.ManyToManyField(
blank=True, related_name="hide_from_accounts_set", to=settings.AUTH_USER_MODEL
),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_channels',
field=models.ManyToManyField(blank=True, help_text='channel recievers', related_name='channel_set', to='comms.ChannelDB'),
model_name="msg",
name="db_receivers_channels",
field=models.ManyToManyField(
blank=True,
help_text="channel recievers",
related_name="channel_set",
to="comms.ChannelDB",
),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_objects',
field=models.ManyToManyField(blank=True, help_text='object receivers', related_name='receiver_object_set', to='objects.ObjectDB'),
model_name="msg",
name="db_receivers_objects",
field=models.ManyToManyField(
blank=True,
help_text="object receivers",
related_name="receiver_object_set",
to="objects.ObjectDB",
),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_accounts',
field=models.ManyToManyField(blank=True, help_text='account receivers', related_name='receiver_account_set', to=settings.AUTH_USER_MODEL),
model_name="msg",
name="db_receivers_accounts",
field=models.ManyToManyField(
blank=True,
help_text="account receivers",
related_name="receiver_account_set",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name='msg',
name='db_sender_objects',
field=models.ManyToManyField(blank=True, db_index=True, related_name='sender_object_set', to='objects.ObjectDB', verbose_name='sender(object)'),
model_name="msg",
name="db_sender_objects",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="sender_object_set",
to="objects.ObjectDB",
verbose_name="sender(object)",
),
),
migrations.AlterField(
model_name='msg',
name='db_sender_accounts',
field=models.ManyToManyField(blank=True, db_index=True, related_name='sender_account_set', to=settings.AUTH_USER_MODEL, verbose_name='sender(account)'),
model_name="msg",
name="db_sender_accounts",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="sender_account_set",
to=settings.AUTH_USER_MODEL,
verbose_name="sender(account)",
),
),
migrations.AlterField(
model_name='msg',
name='db_tags',
field=models.ManyToManyField(blank=True, help_text='tags on this message. Tags are simple string markers to identify, group and alias messages.', to='typeclasses.Tag'),
model_name="msg",
name="db_tags",
field=models.ManyToManyField(
blank=True,
help_text="tags on this message. Tags are simple string markers to identify, group and alias messages.",
to="typeclasses.Tag",
),
),
]

View file

@ -7,10 +7,6 @@ from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('comms', '0011_auto_20170606_1731'),
('comms', '0011_auto_20170217_2039'),
]
dependencies = [("comms", "0011_auto_20170606_1731"), ("comms", "0011_auto_20170217_2039")]
operations = [
]
operations = []

View file

@ -13,72 +13,131 @@ def _table_exists(db_cursor, tablename):
class Migration(migrations.Migration):
dependencies = [
('accounts', '0007_copy_player_to_account'),
('comms', '0012_merge_20170617_2017'),
("accounts", "0007_copy_player_to_account"),
("comms", "0012_merge_20170617_2017"),
]
db_cursor = connection.cursor()
operations = [
migrations.AddField(
model_name='channeldb',
name='db_account_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='account_subscription_set', to='accounts.AccountDB', verbose_name='account subscriptions'),
model_name="channeldb",
name="db_account_subscriptions",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="account_subscription_set",
to="accounts.AccountDB",
verbose_name="account subscriptions",
),
),
migrations.AlterField(
model_name='channeldb',
name='db_object_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='object_subscription_set', to='objects.ObjectDB', verbose_name='object subscriptions'),
model_name="channeldb",
name="db_object_subscriptions",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="object_subscription_set",
to="objects.ObjectDB",
verbose_name="object subscriptions",
),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_scripts',
field=models.ManyToManyField(blank=True, help_text='script_receivers', related_name='receiver_script_set', to='scripts.ScriptDB'),
model_name="msg",
name="db_receivers_scripts",
field=models.ManyToManyField(
blank=True,
help_text="script_receivers",
related_name="receiver_script_set",
to="scripts.ScriptDB",
),
),
migrations.AlterField(
model_name='msg',
name='db_sender_scripts',
field=models.ManyToManyField(blank=True, db_index=True, related_name='sender_script_set', to='scripts.ScriptDB', verbose_name='sender(script)'),
model_name="msg",
name="db_sender_scripts",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="sender_script_set",
to="scripts.ScriptDB",
verbose_name="sender(script)",
),
),
migrations.AlterField(
model_name='channeldb',
name='db_object_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='object_subscription_set', to='objects.ObjectDB', verbose_name='object subscriptions'),
model_name="channeldb",
name="db_object_subscriptions",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="object_subscription_set",
to="objects.ObjectDB",
verbose_name="object subscriptions",
),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_scripts',
field=models.ManyToManyField(blank=True, help_text='script_receivers', related_name='receiver_script_set', to='scripts.ScriptDB'),
model_name="msg",
name="db_receivers_scripts",
field=models.ManyToManyField(
blank=True,
help_text="script_receivers",
related_name="receiver_script_set",
to="scripts.ScriptDB",
),
),
migrations.AlterField(
model_name='msg',
name='db_sender_scripts',
field=models.ManyToManyField(blank=True, db_index=True, related_name='sender_script_set', to='scripts.ScriptDB', verbose_name='sender(script)'),
model_name="msg",
name="db_sender_scripts",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="sender_script_set",
to="scripts.ScriptDB",
verbose_name="sender(script)",
),
),
]
if _table_exists(db_cursor, 'comms_msg_db_hide_from_players'):
if _table_exists(db_cursor, "comms_msg_db_hide_from_players"):
# OBS - this is run BEFORE migrations are run!
# not a migration of an existing database
operations += [
migrations.AddField(
model_name='channeldb',
name='db_account_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='account_subscription_set', to='accounts.AccountDB', verbose_name='account subscriptions'),
model_name="channeldb",
name="db_account_subscriptions",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="account_subscription_set",
to="accounts.AccountDB",
verbose_name="account subscriptions",
),
),
migrations.AddField(
model_name='msg',
name='db_hide_from_accounts',
field=models.ManyToManyField(blank=True, related_name='hide_from_accounts_set', to='accounts.AccountDB'),
model_name="msg",
name="db_hide_from_accounts",
field=models.ManyToManyField(
blank=True, related_name="hide_from_accounts_set", to="accounts.AccountDB"
),
),
migrations.AddField(
model_name='msg',
name='db_receivers_accounts',
field=models.ManyToManyField(blank=True, help_text='account receivers', related_name='receiver_account_set', to='accounts.AccountDB'),
model_name="msg",
name="db_receivers_accounts",
field=models.ManyToManyField(
blank=True,
help_text="account receivers",
related_name="receiver_account_set",
to="accounts.AccountDB",
),
),
migrations.AddField(
model_name='msg',
name='db_sender_accounts',
field=models.ManyToManyField(blank=True, db_index=True, related_name='sender_account_set', to='accounts.AccountDB', verbose_name='sender(account)'),
model_name="msg",
name="db_sender_accounts",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="sender_account_set",
to="accounts.AccountDB",
verbose_name="sender(account)",
),
),
]

View file

@ -8,15 +8,16 @@ from django.db import migrations
# the player->account transition. Now it will do nothing since players.PlayerDB
# no longer exists.
def forwards(apps, schema_editor):
try:
apps.get_model('players', 'PlayerDB')
apps.get_model("players", "PlayerDB")
except LookupError:
return
AccountDB = apps.get_model('accounts', 'AccountDB')
AccountDB = apps.get_model("accounts", "AccountDB")
Msg = apps.get_model('comms', 'Msg')
Msg = apps.get_model("comms", "Msg")
for msg in Msg.objects.all():
for player in msg.db_sender_players.all():
account = AccountDB.objects.get(id=player.id)
@ -28,7 +29,7 @@ def forwards(apps, schema_editor):
account = AccountDB.objects.get(id=player.id)
msg.db_hide_from_accounts.add(account)
ChannelDB = apps.get_model('comms', 'ChannelDB')
ChannelDB = apps.get_model("comms", "ChannelDB")
for channel in ChannelDB.objects.all():
for player in channel.db_subscriptions.all():
account = AccountDB.objects.get(id=player.id)
@ -37,10 +38,6 @@ def forwards(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
('comms', '0013_auto_20170705_1726'),
]
dependencies = [("comms", "0013_auto_20170705_1726")]
operations = [
migrations.RunPython(forwards)
]
operations = [migrations.RunPython(forwards)]

View file

@ -12,9 +12,7 @@ def _table_exists(db_cursor, tablename):
class Migration(migrations.Migration):
dependencies = [
('comms', '0014_auto_20170705_1736'),
]
dependencies = [("comms", "0014_auto_20170705_1736")]
db_cursor = connection.cursor()
@ -24,15 +22,9 @@ class Migration(migrations.Migration):
else:
operations = [
migrations.RemoveField(
model_name='channeldb',
name='db_subscriptions', # this is now db_account_subscriptions
),
migrations.RemoveField(
model_name='msg',
name='db_receivers_players',
),
migrations.RemoveField(
model_name='msg',
name='db_sender_players',
model_name="channeldb",
name="db_subscriptions", # this is now db_account_subscriptions
),
migrations.RemoveField(model_name="msg", name="db_receivers_players"),
migrations.RemoveField(model_name="msg", name="db_sender_players"),
]

View file

@ -7,18 +7,11 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('comms', '0015_auto_20170706_2041'),
]
dependencies = [("comms", "0015_auto_20170706_2041")]
operations = [
migrations.RemoveField(
model_name='channeldb',
name='db_subscriptions',
),
migrations.RemoveField(model_name="channeldb", name="db_subscriptions"),
migrations.AlterField(
model_name='msg',
name='db_message',
field=models.TextField(verbose_name='message'),
model_name="msg", name="db_message", field=models.TextField(verbose_name="message")
),
]

View file

@ -7,114 +7,188 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('comms', '0016_auto_20180925_1735'),
]
dependencies = [("comms", "0016_auto_20180925_1735")]
operations = [
migrations.AlterField(
model_name='channeldb',
name='db_account_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='account_subscription_set', to=settings.AUTH_USER_MODEL, verbose_name='account subscriptions'),
model_name="channeldb",
name="db_account_subscriptions",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="account_subscription_set",
to=settings.AUTH_USER_MODEL,
verbose_name="account subscriptions",
),
),
migrations.AlterField(
model_name='channeldb',
name='db_attributes',
field=models.ManyToManyField(help_text='attributes on this object. An attribute can hold any pickle-able python object (see docs for special cases).', to='typeclasses.Attribute'),
model_name="channeldb",
name="db_attributes",
field=models.ManyToManyField(
help_text="attributes on this object. An attribute can hold any pickle-able python object (see docs for special cases).",
to="typeclasses.Attribute",
),
),
migrations.AlterField(
model_name='channeldb',
name='db_date_created',
field=models.DateTimeField(auto_now_add=True, verbose_name='creation date'),
model_name="channeldb",
name="db_date_created",
field=models.DateTimeField(auto_now_add=True, verbose_name="creation date"),
),
migrations.AlterField(
model_name='channeldb',
name='db_key',
field=models.CharField(db_index=True, max_length=255, verbose_name='key'),
model_name="channeldb",
name="db_key",
field=models.CharField(db_index=True, max_length=255, verbose_name="key"),
),
migrations.AlterField(
model_name='channeldb',
name='db_lock_storage',
field=models.TextField(blank=True, help_text="locks limit access to an entity. A lock is defined as a 'lock string' on the form 'type:lockfunctions', defining what functionality is locked and how to determine access. Not defining a lock means no access is granted.", verbose_name='locks'),
model_name="channeldb",
name="db_lock_storage",
field=models.TextField(
blank=True,
help_text="locks limit access to an entity. A lock is defined as a 'lock string' on the form 'type:lockfunctions', defining what functionality is locked and how to determine access. Not defining a lock means no access is granted.",
verbose_name="locks",
),
),
migrations.AlterField(
model_name='channeldb',
name='db_object_subscriptions',
field=models.ManyToManyField(blank=True, db_index=True, related_name='object_subscription_set', to='objects.ObjectDB', verbose_name='object subscriptions'),
model_name="channeldb",
name="db_object_subscriptions",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="object_subscription_set",
to="objects.ObjectDB",
verbose_name="object subscriptions",
),
),
migrations.AlterField(
model_name='channeldb',
name='db_tags',
field=models.ManyToManyField(help_text='tags on this object. Tags are simple string markers to identify, group and alias objects.', to='typeclasses.Tag'),
model_name="channeldb",
name="db_tags",
field=models.ManyToManyField(
help_text="tags on this object. Tags are simple string markers to identify, group and alias objects.",
to="typeclasses.Tag",
),
),
migrations.AlterField(
model_name='channeldb',
name='db_typeclass_path',
field=models.CharField(help_text="this defines what 'type' of entity this is. This variable holds a Python path to a module with a valid Evennia Typeclass.", max_length=255, null=True, verbose_name='typeclass'),
model_name="channeldb",
name="db_typeclass_path",
field=models.CharField(
help_text="this defines what 'type' of entity this is. This variable holds a Python path to a module with a valid Evennia Typeclass.",
max_length=255,
null=True,
verbose_name="typeclass",
),
),
migrations.AlterField(
model_name='msg',
name='db_date_created',
field=models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='date sent'),
model_name="msg",
name="db_date_created",
field=models.DateTimeField(auto_now_add=True, db_index=True, verbose_name="date sent"),
),
migrations.AlterField(
model_name='msg',
name='db_header',
field=models.TextField(blank=True, null=True, verbose_name='header'),
model_name="msg",
name="db_header",
field=models.TextField(blank=True, null=True, verbose_name="header"),
),
migrations.AlterField(
model_name='msg',
name='db_lock_storage',
field=models.TextField(blank=True, help_text='access locks on this message.', verbose_name='locks'),
model_name="msg",
name="db_lock_storage",
field=models.TextField(
blank=True, help_text="access locks on this message.", verbose_name="locks"
),
),
migrations.AlterField(
model_name='msg',
name='db_message',
field=models.TextField(verbose_name='message'),
model_name="msg", name="db_message", field=models.TextField(verbose_name="message")
),
migrations.AlterField(
model_name='msg',
name='db_receivers_accounts',
field=models.ManyToManyField(blank=True, help_text='account receivers', related_name='receiver_account_set', to=settings.AUTH_USER_MODEL),
model_name="msg",
name="db_receivers_accounts",
field=models.ManyToManyField(
blank=True,
help_text="account receivers",
related_name="receiver_account_set",
to=settings.AUTH_USER_MODEL,
),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_channels',
field=models.ManyToManyField(blank=True, help_text='channel recievers', related_name='channel_set', to='comms.ChannelDB'),
model_name="msg",
name="db_receivers_channels",
field=models.ManyToManyField(
blank=True,
help_text="channel recievers",
related_name="channel_set",
to="comms.ChannelDB",
),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_objects',
field=models.ManyToManyField(blank=True, help_text='object receivers', related_name='receiver_object_set', to='objects.ObjectDB'),
model_name="msg",
name="db_receivers_objects",
field=models.ManyToManyField(
blank=True,
help_text="object receivers",
related_name="receiver_object_set",
to="objects.ObjectDB",
),
),
migrations.AlterField(
model_name='msg',
name='db_receivers_scripts',
field=models.ManyToManyField(blank=True, help_text='script_receivers', related_name='receiver_script_set', to='scripts.ScriptDB'),
model_name="msg",
name="db_receivers_scripts",
field=models.ManyToManyField(
blank=True,
help_text="script_receivers",
related_name="receiver_script_set",
to="scripts.ScriptDB",
),
),
migrations.AlterField(
model_name='msg',
name='db_sender_accounts',
field=models.ManyToManyField(blank=True, db_index=True, related_name='sender_account_set', to=settings.AUTH_USER_MODEL, verbose_name='sender(account)'),
model_name="msg",
name="db_sender_accounts",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="sender_account_set",
to=settings.AUTH_USER_MODEL,
verbose_name="sender(account)",
),
),
migrations.AlterField(
model_name='msg',
name='db_sender_external',
field=models.CharField(blank=True, db_index=True, help_text="identifier for external sender, for example a sender over an IRC connection (i.e. someone who doesn't have an exixtence in-game).", max_length=255, null=True, verbose_name='external sender'),
model_name="msg",
name="db_sender_external",
field=models.CharField(
blank=True,
db_index=True,
help_text="identifier for external sender, for example a sender over an IRC connection (i.e. someone who doesn't have an exixtence in-game).",
max_length=255,
null=True,
verbose_name="external sender",
),
),
migrations.AlterField(
model_name='msg',
name='db_sender_objects',
field=models.ManyToManyField(blank=True, db_index=True, related_name='sender_object_set', to='objects.ObjectDB', verbose_name='sender(object)'),
model_name="msg",
name="db_sender_objects",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="sender_object_set",
to="objects.ObjectDB",
verbose_name="sender(object)",
),
),
migrations.AlterField(
model_name='msg',
name='db_sender_scripts',
field=models.ManyToManyField(blank=True, db_index=True, related_name='sender_script_set', to='scripts.ScriptDB', verbose_name='sender(script)'),
model_name="msg",
name="db_sender_scripts",
field=models.ManyToManyField(
blank=True,
db_index=True,
related_name="sender_script_set",
to="scripts.ScriptDB",
verbose_name="sender(script)",
),
),
migrations.AlterField(
model_name='msg',
name='db_tags',
field=models.ManyToManyField(blank=True, help_text='tags on this message. Tags are simple string markers to identify, group and alias messages.', to='typeclasses.Tag'),
model_name="msg",
name="db_tags",
field=models.ManyToManyField(
blank=True,
help_text="tags on this message. Tags are simple string markers to identify, group and alias messages.",
to="typeclasses.Tag",
),
),
]

View file

@ -37,11 +37,12 @@ _DA = object.__delattr__
_CHANNELHANDLER = None
#------------------------------------------------------------
# ------------------------------------------------------------
#
# Msg
#
#------------------------------------------------------------
# ------------------------------------------------------------
class Msg(SharedMemoryModel):
"""
@ -68,6 +69,7 @@ class Msg(SharedMemoryModel):
- db_lock_storage: Internal storage of lock strings.
"""
#
# Msg database model setup
#
@ -78,48 +80,94 @@ class Msg(SharedMemoryModel):
# Sender is either an account, an object or an external sender, like
# an IRC channel; normally there is only one, but if co-modification of
# a message is allowed, there may be more than one "author"
db_sender_accounts = models.ManyToManyField("accounts.AccountDB", related_name='sender_account_set',
blank=True, verbose_name='sender(account)', db_index=True)
db_sender_accounts = models.ManyToManyField(
"accounts.AccountDB",
related_name="sender_account_set",
blank=True,
verbose_name="sender(account)",
db_index=True,
)
db_sender_objects = models.ManyToManyField("objects.ObjectDB", related_name='sender_object_set',
blank=True, verbose_name='sender(object)', db_index=True)
db_sender_scripts = models.ManyToManyField("scripts.ScriptDB", related_name='sender_script_set',
blank=True, verbose_name='sender(script)', db_index=True)
db_sender_external = models.CharField('external sender', max_length=255, null=True, blank=True, db_index=True,
help_text="identifier for external sender, for example a sender over an "
"IRC connection (i.e. someone who doesn't have an exixtence in-game).")
db_sender_objects = models.ManyToManyField(
"objects.ObjectDB",
related_name="sender_object_set",
blank=True,
verbose_name="sender(object)",
db_index=True,
)
db_sender_scripts = models.ManyToManyField(
"scripts.ScriptDB",
related_name="sender_script_set",
blank=True,
verbose_name="sender(script)",
db_index=True,
)
db_sender_external = models.CharField(
"external sender",
max_length=255,
null=True,
blank=True,
db_index=True,
help_text="identifier for external sender, for example a sender over an "
"IRC connection (i.e. someone who doesn't have an exixtence in-game).",
)
# The destination objects of this message. Stored as a
# comma-separated string of object dbrefs. Can be defined along
# with channels below.
db_receivers_accounts = models.ManyToManyField('accounts.AccountDB', related_name='receiver_account_set',
blank=True, help_text="account receivers")
db_receivers_accounts = models.ManyToManyField(
"accounts.AccountDB",
related_name="receiver_account_set",
blank=True,
help_text="account receivers",
)
db_receivers_objects = models.ManyToManyField('objects.ObjectDB', related_name='receiver_object_set',
blank=True, help_text="object receivers")
db_receivers_scripts = models.ManyToManyField('scripts.ScriptDB', related_name='receiver_script_set',
blank=True, help_text="script_receivers")
db_receivers_channels = models.ManyToManyField("ChannelDB", related_name='channel_set',
blank=True, help_text="channel recievers")
db_receivers_objects = models.ManyToManyField(
"objects.ObjectDB",
related_name="receiver_object_set",
blank=True,
help_text="object receivers",
)
db_receivers_scripts = models.ManyToManyField(
"scripts.ScriptDB",
related_name="receiver_script_set",
blank=True,
help_text="script_receivers",
)
db_receivers_channels = models.ManyToManyField(
"ChannelDB", related_name="channel_set", blank=True, help_text="channel recievers"
)
# header could be used for meta-info about the message if your system needs
# it, or as a separate store for the mail subject line maybe.
db_header = models.TextField('header', null=True, blank=True)
db_header = models.TextField("header", null=True, blank=True)
# the message body itself
db_message = models.TextField('message')
db_message = models.TextField("message")
# send date
db_date_created = models.DateTimeField('date sent', editable=False, auto_now_add=True, db_index=True)
db_date_created = models.DateTimeField(
"date sent", editable=False, auto_now_add=True, db_index=True
)
# lock storage
db_lock_storage = models.TextField('locks', blank=True,
help_text='access locks on this message.')
db_lock_storage = models.TextField(
"locks", blank=True, help_text="access locks on this message."
)
# these can be used to filter/hide a given message from supplied objects/accounts/channels
db_hide_from_accounts = models.ManyToManyField("accounts.AccountDB", related_name='hide_from_accounts_set', blank=True)
db_hide_from_accounts = models.ManyToManyField(
"accounts.AccountDB", related_name="hide_from_accounts_set", blank=True
)
db_hide_from_objects = models.ManyToManyField("objects.ObjectDB", related_name='hide_from_objects_set', blank=True)
db_hide_from_channels = models.ManyToManyField("ChannelDB", related_name='hide_from_channels_set', blank=True)
db_hide_from_objects = models.ManyToManyField(
"objects.ObjectDB", related_name="hide_from_objects_set", blank=True
)
db_hide_from_channels = models.ManyToManyField(
"ChannelDB", related_name="hide_from_channels_set", blank=True
)
db_tags = models.ManyToManyField(Tag, blank=True,
help_text='tags on this message. Tags are simple string markers to identify, group and alias messages.')
db_tags = models.ManyToManyField(
Tag,
blank=True,
help_text="tags on this message. Tags are simple string markers to identify, group and alias messages.",
)
# Database manager
objects = managers.MsgManager()
@ -150,15 +198,17 @@ class Msg(SharedMemoryModel):
# is the object in question).
# sender property (wraps db_sender_*)
#@property
# @property
def __senders_get(self):
"Getter. Allows for value = self.sender"
return list(self.db_sender_accounts.all()) + \
list(self.db_sender_objects.all()) + \
list(self.db_sender_scripts.all()) + \
self.extra_senders
return (
list(self.db_sender_accounts.all())
+ list(self.db_sender_objects.all())
+ list(self.db_sender_scripts.all())
+ self.extra_senders
)
#@sender.setter
# @sender.setter
def __senders_set(self, senders):
"Setter. Allows for self.sender = value"
for sender in make_iter(senders):
@ -179,7 +229,7 @@ class Msg(SharedMemoryModel):
elif clsname == "ScriptDB":
self.db_sender_scripts.add(sender)
#@sender.deleter
# @sender.deleter
def __senders_del(self):
"Deleter. Clears all senders"
self.db_sender_accounts.clear()
@ -188,6 +238,7 @@ class Msg(SharedMemoryModel):
self.db_sender_external = ""
self.extra_senders = []
self.save()
senders = property(__senders_get, __senders_set, __senders_del)
def remove_sender(self, senders):
@ -215,18 +266,20 @@ class Msg(SharedMemoryModel):
self.db_sender_accounts.remove(sender)
# receivers property
#@property
# @property
def __receivers_get(self):
"""
Getter. Allows for value = self.receivers.
Returns four lists of receivers: accounts, objects, scripts and channels.
"""
return list(self.db_receivers_accounts.all()) + \
list(self.db_receivers_objects.all()) + \
list(self.db_receivers_scripts.all()) + \
list(self.db_receivers_channels.all())
return (
list(self.db_receivers_accounts.all())
+ list(self.db_receivers_objects.all())
+ list(self.db_receivers_scripts.all())
+ list(self.db_receivers_channels.all())
)
#@receivers.setter
# @receivers.setter
def __receivers_set(self, receivers):
"""
Setter. Allows for self.receivers = value.
@ -247,7 +300,7 @@ class Msg(SharedMemoryModel):
elif clsname == "ChannelDB":
self.db_receivers_channels.add(receiver)
#@receivers.deleter
# @receivers.deleter
def __receivers_del(self):
"Deleter. Clears all receivers"
self.db_receivers_accounts.clear()
@ -255,6 +308,7 @@ class Msg(SharedMemoryModel):
self.db_receivers_scripts.clear()
self.db_receivers_channels.clear()
self.save()
receivers = property(__receivers_get, __receivers_set, __receivers_del)
def remove_receiver(self, receivers):
@ -281,12 +335,12 @@ class Msg(SharedMemoryModel):
self.db_receivers_channels.remove(receiver)
# channels property
#@property
# @property
def __channels_get(self):
"Getter. Allows for value = self.channels. Returns a list of channels."
return self.db_receivers_channels.all()
#@channels.setter
# @channels.setter
def __channels_set(self, value):
"""
Setter. Allows for self.channels = value.
@ -295,11 +349,12 @@ class Msg(SharedMemoryModel):
for val in (v for v in make_iter(value) if v):
self.db_receivers_channels.add(val)
#@channels.deleter
# @channels.deleter
def __channels_del(self):
"Deleter. Allows for del self.channels"
self.db_receivers_channels.clear()
self.save()
channels = property(__channels_get, __channels_set, __channels_del)
def __hide_from_get(self):
@ -307,9 +362,13 @@ class Msg(SharedMemoryModel):
Getter. Allows for value = self.hide_from.
Returns 3 lists of accounts, objects and channels
"""
return self.db_hide_from_accounts.all(), self.db_hide_from_objects.all(), self.db_hide_from_channels.all()
return (
self.db_hide_from_accounts.all(),
self.db_hide_from_objects.all(),
self.db_hide_from_channels.all(),
)
#@hide_from_sender.setter
# @hide_from_sender.setter
def __hide_from_set(self, hiders):
"Setter. Allows for self.hide_from = value. Will append to hiders"
for hider in make_iter(hiders):
@ -325,13 +384,14 @@ class Msg(SharedMemoryModel):
elif clsname == "ChannelDB":
self.db_hide_from_channels.add(hider.__dbclass__)
#@hide_from_sender.deleter
# @hide_from_sender.deleter
def __hide_from_del(self):
"Deleter. Allows for del self.hide_from_senders"
self.db_hide_from_accounts.clear()
self.db_hide_from_objects.clear()
self.db_hide_from_channels.clear()
self.save()
hide_from = property(__hide_from_get, __hide_from_set, __hide_from_del)
#
@ -341,10 +401,12 @@ class Msg(SharedMemoryModel):
def __str__(self):
"This handles what is shown when e.g. printing the message"
senders = ",".join(obj.key for obj in self.senders)
receivers = ",".join(["[%s]" % obj.key for obj in self.channels] + [obj.key for obj in self.receivers])
receivers = ",".join(
["[%s]" % obj.key for obj in self.channels] + [obj.key for obj in self.receivers]
)
return "%s->%s: %s" % (senders, receivers, crop(self.message, width=40))
def access(self, accessing_obj, access_type='read', default=False):
def access(self, accessing_obj, access_type="read", default=False):
"""
Checks lock access.
@ -357,14 +419,14 @@ class Msg(SharedMemoryModel):
result (bool): If access was granted or not.
"""
return self.locks.check(accessing_obj,
access_type=access_type, default=default)
return self.locks.check(accessing_obj, access_type=access_type, default=default)
#------------------------------------------------------------
# ------------------------------------------------------------
#
# TempMsg
#
#------------------------------------------------------------
# ------------------------------------------------------------
class TempMsg(object):
@ -375,7 +437,17 @@ class TempMsg(object):
"""
def __init__(self, senders=None, receivers=None, channels=None, message="", header="", type="", lockstring="", hide_from=None):
def __init__(
self,
senders=None,
receivers=None,
channels=None,
message="",
header="",
type="",
lockstring="",
hide_from=None,
):
"""
Creates the temp message.
@ -409,7 +481,9 @@ class TempMsg(object):
This handles what is shown when e.g. printing the message.
"""
senders = ",".join(obj.key for obj in self.senders)
receivers = ",".join(["[%s]" % obj.key for obj in self.channels] + [obj.key for obj in self.receivers])
receivers = ",".join(
["[%s]" % obj.key for obj in self.channels] + [obj.key for obj in self.receivers]
)
return "%s->%s: %s" % (senders, receivers, crop(self.message, width=40))
def remove_sender(self, sender):
@ -440,7 +514,7 @@ class TempMsg(object):
except ValueError:
pass # nothing to remove
def access(self, accessing_obj, access_type='read', default=False):
def access(self, accessing_obj, access_type="read", default=False):
"""
Checks lock access.
@ -453,15 +527,15 @@ class TempMsg(object):
result (bool): If access was granted or not.
"""
return self.locks.check(accessing_obj,
access_type=access_type, default=default)
return self.locks.check(accessing_obj, access_type=access_type, default=default)
#------------------------------------------------------------
# ------------------------------------------------------------
#
# Channel
#
#------------------------------------------------------------
# ------------------------------------------------------------
class SubscriptionHandler(object):
"""
@ -482,10 +556,18 @@ class SubscriptionHandler(object):
self._cache = None
def _recache(self):
self._cache = {account: True for account in self.obj.db_account_subscriptions.all()
if hasattr(account, 'pk') and account.pk}
self._cache.update({obj: True for obj in self.obj.db_object_subscriptions.all()
if hasattr(obj, 'pk') and obj.pk})
self._cache = {
account: True
for account in self.obj.db_account_subscriptions.all()
if hasattr(account, "pk") and account.pk
}
self._cache.update(
{
obj: True
for obj in self.obj.db_object_subscriptions.all()
if hasattr(obj, "pk") and obj.pk
}
)
def has(self, entity):
"""
@ -568,6 +650,7 @@ class SubscriptionHandler(object):
if self._cache is None:
self._recache()
return self._cache
get = all # alias
def online(self):
@ -581,8 +664,9 @@ class SubscriptionHandler(object):
recache_needed = False
for obj in self.all():
from django.core.exceptions import ObjectDoesNotExist
try:
if hasattr(obj, 'account') and obj.account:
if hasattr(obj, "account") and obj.account:
obj = obj.account
if not obj.is_connected:
continue
@ -617,11 +701,22 @@ class ChannelDB(TypedObject):
- db_object_subscriptions: The Object subscriptions.
"""
db_account_subscriptions = models.ManyToManyField("accounts.AccountDB",
related_name="account_subscription_set", blank=True, verbose_name='account subscriptions', db_index=True)
db_object_subscriptions = models.ManyToManyField("objects.ObjectDB",
related_name="object_subscription_set", blank=True, verbose_name='object subscriptions', db_index=True)
db_account_subscriptions = models.ManyToManyField(
"accounts.AccountDB",
related_name="account_subscription_set",
blank=True,
verbose_name="account subscriptions",
db_index=True,
)
db_object_subscriptions = models.ManyToManyField(
"objects.ObjectDB",
related_name="object_subscription_set",
blank=True,
verbose_name="object subscriptions",
db_index=True,
)
# Database manager
objects = managers.ChannelDBManager()

View file

@ -1,13 +1,12 @@
from evennia.utils.test_resources import EvenniaTest
from evennia import DefaultChannel
class ObjectCreationTest(EvenniaTest):
def test_channel_create(self):
description = "A place to talk about coffee."
obj, errors = DefaultChannel.create('coffeetalk', description=description)
obj, errors = DefaultChannel.create("coffeetalk", description=description)
self.assertTrue(obj, errors)
self.assertFalse(errors, errors)
self.assertEqual(description, obj.db.desc)
self.assertEqual(description, obj.db.desc)