2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-21 23:01:52 +00:00
troggle/databaseReset.py
substantialnoninfringinguser e8da6b9b8b [svn] Further attempts to make troggle work on windows using surveys stored on an external server
settings.PHOTOS changed to setting.PHOTO_ROOT
Made databaseReset.py get info from external server if appropriate (hope this did not break linus disk based scripts)
Still needs more work, to get everything working
Auto create photos directory if it does not already exist

Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8262 by julian @ 3/2/2009 1:30 AM
2009-05-13 05:58:18 +01:00

34 lines
1.1 KiB
Python

import os
import settings
os.environ['PYTHONPATH'] = settings.PYTHON_PATH
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from django.core import management
from django.db import connection
cursor = connection.cursor()
cursor.execute("drop database %s" % settings.DATABASE_NAME)
cursor.execute("create database %s" % settings.DATABASE_NAME)
cursor.execute("ALTER DATABASE %s CHARACTER SET=utf8" % settings.DATABASE_NAME)
cursor.execute("USE %s" % settings.DATABASE_NAME)
management.call_command('syncdb')
from django.contrib.auth.models import User
user = User.objects.create_user('m', 'm@m.com', 'm')
user.is_staff = True
user.is_superuser = True
user.save()
#Make directories that troggle requires
if not os.path.isdir(settings.PHOTOS_ROOT):
os.mkdir(settings.PHOTOS_ROOT)
import parsers.cavetab
parsers.cavetab.LoadCaveTab()
import parsers.people
parsers.people.LoadPersonsExpos()
import parsers.logbooks
parsers.logbooks.LoadLogbooks()
import parsers.survex
parsers.survex.LoadAllSurvexBlocks()
import parsers.QMs
import parsers.surveys