Run migrations! Adds support for saving Msg entities in an Attribute. Note that recovering Msgs from an Attribute saved *before* this fix can still cause tracebacks. They may not be recoverable since dbobjects are not possible to unpickle on their own.

This commit is contained in:
Griatch 2016-09-05 11:15:14 +02:00
parent b46df5643a
commit c66ae693c5
4 changed files with 51 additions and 6 deletions

View file

@ -29,12 +29,12 @@ class MsgAdmin(admin.ModelAdmin):
Defines display for Msg objects
"""
list_display = ('id', 'db_date_sent', 'db_sender', 'db_receivers',
list_display = ('id', 'db_date_created', 'db_sender', 'db_receivers',
'db_channels', 'db_message', 'db_lock_storage')
list_display_links = ("id",)
ordering = ["db_date_sent", 'db_sender', 'db_receivers', 'db_channels']
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_sent', '^db_message']
search_fields = ['id', '^db_date_created', '^db_message']
save_as = True
save_on_top = True
list_select_related = True

View file

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.9 on 2016-09-05 09:02
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('comms', '0007_msg_db_tags'),
]
operations = [
migrations.AlterModelOptions(
name='msg',
options={'verbose_name': 'Msg'},
),
migrations.RenameField(
model_name='msg',
old_name='db_date_sent',
new_name='db_date_created',
),
]

View file

@ -59,7 +59,7 @@ class Msg(SharedMemoryModel):
- db_receivers_channels: Receiving channels
- db_header: Header text
- db_message: The actual message text
- db_date_sent: time message was sent
- db_date_created: time message was created / sent
- db_hide_from_sender: bool if message should be hidden from sender
- db_hide_from_receivers: list of receiver objects to hide message from
- db_hide_from_channels: list of channels objects to hide message from
@ -99,7 +99,7 @@ class Msg(SharedMemoryModel):
# the message body itself
db_message = models.TextField('messsage')
# send date
db_date_sent = 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.')
@ -122,7 +122,7 @@ class Msg(SharedMemoryModel):
class Meta(object):
"Define Django meta options"
verbose_name = "Message"
verbose_name = "Msg"
@lazy_property
def locks(self):

View file

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.9 on 2016-09-05 09:02
from __future__ import unicode_literals
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('players', '0004_auto_20150403_2339'),
]
operations = [
migrations.AlterField(
model_name='playerdb',
name='username',
field=models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=30, unique=True, validators=[django.core.validators.RegexValidator('^[\\w.@+-]+$', 'Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.')], verbose_name='username'),
),
]