Part 1 of initial database population re-factor, along with a comsys model change. DO NOT UPDATE TO THIS IN PRODUCTION ENVIRONMENTS YET! Wait for the all-clear.

This commit is contained in:
Greg Taylor 2009-01-18 03:14:52 +00:00
parent 8ebea8c22e
commit c0ebbc3967
6 changed files with 29 additions and 10 deletions

View file

@ -1,12 +1,23 @@
from django.contrib.auth.models import User, Group
from src.objects.models import Object
from src.config.models import ConfigValue
from src import comsys, defines_global
def handle_setup():
# Set the initial user's username on the #1 object.
god_user = User.objects.filter(id=1)[0]
god_user_obj = Object.objects.filter(id=1)[0]
god_user = User.objects.get(id=1)
god_user_obj = Object(id=1, type=defines_global.OTYPE_PLAYER)
god_user_obj.set_name(god_user.username)
god_user_obj.save()
limbo_obj = Object()
limbo_obj.type = defines_global.OTYPE_ROOM
limbo_obj.owner = god_user_obj
limbo_obj.set_name('Limbo')
limbo_obj.save()
god_user_obj.home = limbo_obj
god_user_obj.save()
groups = ("Immortals", "Wizards", "Builders", "Player Helpers")
for group in groups:
@ -14,5 +25,11 @@ def handle_setup():
newgroup.name = group
newgroup.save()
chan_pub = comsys.create_channel("Public", god_user_obj, description="Public Discussion")
chan_pub.is_joined_by_default = True
chan_pub.save()
comsys.create_channel("Errors", god_user_obj, description="Error log")
comsys.create_channel("Info", god_user_obj, description="Informative messages")
# We don't want to do initial setup tasks every startup, only the first.
ConfigValue.objects.set_configvalue('game_firstrun', '0')