Create parallel Player/Account fields and copy all
This commit is contained in:
parent
ee0e9cc053
commit
63c96de443
10 changed files with 226 additions and 2 deletions
22
evennia/scripts/migrations/0009_scriptdb_db_account.py
Normal file
22
evennia/scripts/migrations/0009_scriptdb_db_account.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.2 on 2017-07-05 17:27
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0002_copy_player_to_account'),
|
||||
('scripts', '0008_auto_20170606_1731'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='scriptdb',
|
||||
name='db_account',
|
||||
field=models.ForeignKey(blank=True, help_text=b'the account to store this script on (should not be set if db_obj is set)', null=True, on_delete=django.db.models.deletion.CASCADE, to='accounts.AccountDB', verbose_name=b'scripted account'),
|
||||
),
|
||||
]
|
||||
33
evennia/scripts/migrations/0010_auto_20170705_1736.py
Normal file
33
evennia/scripts/migrations/0010_auto_20170705_1736.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.2 on 2017-07-05 17:36
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def forwards(apps, schema_editor):
|
||||
|
||||
try:
|
||||
apps.get_model('players', 'PlayerDB')
|
||||
except LookupError:
|
||||
return
|
||||
AccountDB = apps.get_model('accounts', 'AccountDB')
|
||||
ScriptDB = apps.get_model('scripts', 'ScriptDB')
|
||||
|
||||
for script in ScriptDB.objects.all():
|
||||
player = script.db_player
|
||||
if player:
|
||||
account = AccountDB.objects.get(id=player.id)
|
||||
script.db_account = account
|
||||
script.save(update_fields=['db_account'])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('scripts', '0009_scriptdb_db_account'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(forwards)
|
||||
]
|
||||
|
|
@ -86,8 +86,12 @@ class ScriptDB(TypedObject):
|
|||
# A reference to the database object affected by this Script, if any.
|
||||
db_obj = models.ForeignKey("objects.ObjectDB", null=True, blank=True, verbose_name='scripted object',
|
||||
help_text='the object to store this script on, if not a global script.')
|
||||
# TODO Player-Account
|
||||
db_player = models.ForeignKey("players.PlayerDB", null=True, blank=True, verbose_name="scripted player",
|
||||
help_text='the player to store this script on (should not be set if obj is set)')
|
||||
db_account = models.ForeignKey("accounts.AccountDB", null=True, blank=True, verbose_name="scripted account",
|
||||
help_text='the account to store this script on (should not be set if db_obj is set)')
|
||||
|
||||
# how often to run Script (secs). -1 means there is no timer
|
||||
db_interval = models.IntegerField('interval', default=-1, help_text='how often to repeat script, in seconds. -1 means off.')
|
||||
# start script right away or wait interval seconds first
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue