write the bio ORM calls to a file that we can call later (theme import script)
This commit is contained in:
Родитель
04831ac684
Коммит
5ed923b431
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import uuid
|
||||
from getpass import getpass
|
||||
from optparse import make_option
|
||||
|
@ -12,6 +13,8 @@ import MySQLdb as mysql
|
|||
from addons import cron
|
||||
import amo
|
||||
|
||||
BIOS_TO_IMPORT = os.environ.get('BIOS', 'bios_to_import.py')
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""
|
||||
|
@ -198,7 +201,6 @@ class Command(BaseCommand):
|
|||
|
||||
try:
|
||||
# Create UserProfile.
|
||||
# TODO: Insert bio=user['description'] (translated field).
|
||||
self.cursor_z.execute("""
|
||||
INSERT INTO users (created, modified,
|
||||
username, display_name, password, emailhidden, email,
|
||||
|
@ -206,6 +208,12 @@ class Command(BaseCommand):
|
|||
%(password)s, 1, %(email)s, %(notes)s)""", data)
|
||||
data['user_id'] = self.cursor_z.lastrowid
|
||||
|
||||
# We'll import the bios one day. It's all good.
|
||||
with open(BIOS_TO_IMPORT, 'a') as f:
|
||||
f.write('u = UserProfile.objects.get(id=%(user_id)s)\n'
|
||||
'u.bio = """%(bio)s"""\n'
|
||||
'u.save()\n\n' % data)
|
||||
|
||||
# Create Django User.
|
||||
self.cursor_z.execute("""
|
||||
INSERT INTO auth_user (id, username, first_name,
|
||||
|
|
Загрузка…
Ссылка в новой задаче