Removed the admin media files from the distribution again. Instead the server will now create the necessary symlink (Linux) or copy (Windows) of the default files in django/contrib/admin/media at initial startup. Currently only tested under Linux. If you don't want to re-run the initialization, copy/link the admin directory to ADMIN_MEDIA_PREFIX yourself. This deals with issue 124.

Also added a 'remove' functionality to the migrate.py script, for easily getting back the normal syncdb operation (useful when deleting/resetting the database a lot).
This commit is contained in:
Griatch 2011-02-20 22:07:35 +00:00
parent acc89d0be2
commit f0b4c581f7
83 changed files with 74 additions and 103 deletions

View file

@ -182,11 +182,39 @@ def start_game_time():
print " Starting in-game time ..."
from src.utils import gametime
gametime.init_gametime()
def create_admin_media_links():
"""
This traverses to src/web/media and tries to create a symbolic
link to the django media files from within the MEDIA_ROOT.
These are files we normally don't
want to mess with (use templates to customize the admin
look). Linking is needed since the Twisted webserver otherwise has no
notion of where the default files are - and we cannot hard-code it
since the django install may be at different locations depending
on system.
"""
import django, os
dpath = os.path.join(django.__path__[0], 'contrib', 'admin', 'media')
apath = os.path.join(settings.ADMIN_MEDIA_ROOT)
if os.path.isdir(apath):
print " ADMIN_MEDIA_ROOT already exists. Ignored."
return
if os.name == 'nt':
print " Admin-media files copied to ADMIN_MEDIA_ROOT (Windows mode)."
os.mkdir(apath)
os.system('xcopy "%s" "%s" /e /q /c' % (dpath, apath))
if os.name == 'posix':
os.symlink(dpath, apath)
print " Admin-media symlinked to ADMIN_MEDIA_ROOT."
else:
print " Admin-media files should be copied manually to ADMIN_MEDIA_ROOT."
def handle_setup(last_step):
"""
Main logic for the module. It allows to restart the initialization
if one of the modules should crash.
Main logic for the module. It allows for restarting
the initialization at any point if one of the modules
should crash.
"""
if last_step < 0:
@ -206,7 +234,8 @@ def handle_setup(last_step):
create_permission_groups,
create_system_scripts,
import_MUX_help_files,
start_game_time]
start_game_time,
create_admin_media_links]
if not settings.IMPORT_MUX_HELP:
# skip importing of the MUX helpfiles, they are