First step with both account+player at the same time, copying player to account.
This commit is contained in:
parent
99dbaad7ba
commit
ee0e9cc053
9 changed files with 2112 additions and 0 deletions
54
evennia/accounts/migrations/0001_initial.py
Normal file
54
evennia/accounts/migrations/0001_initial.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.2 on 2017-07-03 19:13
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.contrib.auth.validators
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
import evennia.accounts.manager
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('auth', '0008_alter_user_username_max_length'),
|
||||
('typeclasses', '0008_lock_and_perm_rename'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='AccountDB',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('password', models.CharField(max_length=128, verbose_name='password')),
|
||||
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
|
||||
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
|
||||
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.ASCIIUsernameValidator()], verbose_name='username')),
|
||||
('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')),
|
||||
('last_name', models.CharField(blank=True, max_length=30, verbose_name='last name')),
|
||||
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')),
|
||||
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')),
|
||||
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')),
|
||||
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')),
|
||||
('db_key', models.CharField(db_index=True, max_length=255, verbose_name=b'key')),
|
||||
('db_typeclass_path', models.CharField(help_text=b"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=b'typeclass')),
|
||||
('db_date_created', models.DateTimeField(auto_now_add=True, verbose_name=b'creation date')),
|
||||
('db_lock_storage', models.TextField(blank=True, help_text=b"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=b'locks')),
|
||||
('db_is_connected', models.BooleanField(default=False, help_text=b'If player is connected to game or not', verbose_name=b'is_connected')),
|
||||
('db_cmdset_storage', models.CharField(help_text=b'optional python path to a cmdset class. If creating a Character, this will default to settings.CMDSET_CHARACTER.', max_length=255, null=True, verbose_name=b'cmdset')),
|
||||
('db_is_bot', models.BooleanField(default=False, help_text=b'Used to identify irc/rss bots', verbose_name=b'is_bot')),
|
||||
('db_attributes', models.ManyToManyField(help_text=b'attributes on this object. An attribute can hold any pickle-able python object (see docs for special cases).', to='typeclasses.Attribute')),
|
||||
('db_tags', models.ManyToManyField(help_text=b'tags on this object. Tags are simple string markers to identify, group and alias objects.', to='typeclasses.Tag')),
|
||||
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
|
||||
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Account',
|
||||
},
|
||||
managers=[
|
||||
('objects', evennia.accounts.manager.AccountDBManager()),
|
||||
],
|
||||
),
|
||||
]
|
||||
58
evennia/accounts/migrations/0002_copy_player_to_account.py
Normal file
58
evennia/accounts/migrations/0002_copy_player_to_account.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.2 on 2017-07-03 19:17
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps as global_apps
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def forwards(apps, schema_editor):
|
||||
try:
|
||||
PlayerDB = apps.get_model('players', 'PlayerDB')
|
||||
except LookupError:
|
||||
# playerdb not available. Skip.
|
||||
return
|
||||
|
||||
AccountDB = apps.get_model('accounts', 'AccountDB')
|
||||
for player in PlayerDB.objects.all():
|
||||
account = AccountDB(id=player.id,
|
||||
password=player.password,
|
||||
is_superuser=player.is_superuser,
|
||||
last_login=player.last_login,
|
||||
username=player.username,
|
||||
first_name=player.first_name,
|
||||
last_name=player.last_name,
|
||||
email=player.email,
|
||||
is_staff=player.is_staff,
|
||||
is_active=player.is_active,
|
||||
date_joined=player.date_joined,
|
||||
db_key=player.db_key,
|
||||
db_typeclass_path=player.db_typeclass_path,
|
||||
db_date_created=player.db_date_created,
|
||||
db_lock_storage=player.db_lock_storage,
|
||||
db_is_connected=player.db_is_connected,
|
||||
db_cmdset_storage=player.db_cmdset_storage,
|
||||
db_is_bot=player.db_is_bot)
|
||||
account.save()
|
||||
for group in player.groups.all():
|
||||
account.groups.add(group)
|
||||
for user_permission in player.user_permissions.all():
|
||||
account.user_permissions.add(user_permission)
|
||||
for attr in player.db_attributes.all():
|
||||
account.db_attributes.add(attr)
|
||||
for tag in player.db_tags.all():
|
||||
account.db_tags.add(tag)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(forwards, migrations.RunPython.noop)
|
||||
]
|
||||
|
||||
if global_apps.is_installed('players'):
|
||||
dependencies.append(('players', '0006_auto_20170606_1731'))
|
||||
0
evennia/accounts/migrations/__init__.py
Normal file
0
evennia/accounts/migrations/__init__.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue