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

@ -240,16 +240,17 @@ def get_cobj_from_name(cname):
"""
return CommChannel.objects.get(name=cname)
def create_channel(name, owner):
def create_channel(name, owner, description=None):
"""
Create a new channel.
name: (string) Name of the new channel
owner: (Object) Objec that owns the channel
owner: (Object) Object that owns the channel
"""
new_chan = CommChannel()
new_chan.name = ansi.parse_ansi(name, strip_ansi=True)
new_chan.ansi_name = "[%s]" % (ansi.parse_ansi(name),)
new_chan.set_owner(owner)
new_chan.description = description
new_chan.save()
return new_chan

View file

@ -1 +1 @@
[{"pk": 1, "model": "config.connectscreen", "fields": {"is_active": 1, "name": "Default", "connect_screen_text": "%ch%cb==================================================================%cn\r\n Welcome to Evennia! Please type one of the following to begin:\r\n\r\n If you have an existing account, connect to it by typing:\r\n %chconnect <email> <password2>%cn\r\n If you need to create an account, type (without the <>'s):\r\n %chcreate \"<username>\" <email> <password>%cn\r\n%ch%cb==================================================================%cn\r\n"}}, {"pk": 9, "model": "config.commandalias", "fields": {"user_input": "@desc", "equiv_command": "@describe"}}, {"pk": 3, "model": "config.commandalias", "fields": {"user_input": "@dest", "equiv_command": "@destroy"}}, {"pk": 4, "model": "config.commandalias", "fields": {"user_input": "@nuke", "equiv_command": "@destroy"}}, {"pk": 6, "model": "config.commandalias", "fields": {"user_input": "@tel", "equiv_command": "@teleport"}}, {"pk": 2, "model": "config.commandalias", "fields": {"user_input": "ex", "equiv_command": "examine"}}, {"pk": 7, "model": "config.commandalias", "fields": {"user_input": "i", "equiv_command": "inventory"}}, {"pk": 8, "model": "config.commandalias", "fields": {"user_input": "inv", "equiv_command": "inventory"}}, {"pk": 1, "model": "config.commandalias", "fields": {"user_input": "l", "equiv_command": "look"}}, {"pk": 5, "model": "config.commandalias", "fields": {"user_input": "sa", "equiv_command": "say"}}, {"pk": 1, "model": "config.configvalue", "fields": {"conf_value": "Evennia Test Site", "conf_key": "site_name"}}, {"pk": 2, "model": "config.configvalue", "fields": {"conf_value": "2", "conf_key": "player_dbnum_start"}}, {"pk": 3, "model": "config.configvalue", "fields": {"conf_value": "Credits", "conf_key": "money_name_plural"}}, {"pk": 4, "model": "config.configvalue", "fields": {"conf_value": "Credit", "conf_key": "money_name_singular"}}, {"pk": 5, "model": "config.configvalue", "fields": {"conf_value": "0", "conf_key": "game_firstrun"}}, {"pk": 6, "model": "config.configvalue", "fields": {"conf_value": "1800", "conf_key": "idle_timeout"}}, {"pk": 7, "model": "config.configvalue", "fields": {"conf_value": "2", "conf_key": "default_home"}}]
[{"pk": 1, "model": "config.connectscreen", "fields": {"is_active": 1, "name": "Default", "connect_screen_text": "%ch%cb==================================================================%cn\r\n Welcome to Evennia! Please type one of the following to begin:\r\n\r\n If you have an existing account, connect to it by typing:\r\n %chconnect <email> <password2>%cn\r\n If you need to create an account, type (without the <>'s):\r\n %chcreate \"<username>\" <email> <password>%cn\r\n%ch%cb==================================================================%cn\r\n"}}, {"pk": 9, "model": "config.commandalias", "fields": {"user_input": "@desc", "equiv_command": "@describe"}}, {"pk": 3, "model": "config.commandalias", "fields": {"user_input": "@dest", "equiv_command": "@destroy"}}, {"pk": 4, "model": "config.commandalias", "fields": {"user_input": "@nuke", "equiv_command": "@destroy"}}, {"pk": 6, "model": "config.commandalias", "fields": {"user_input": "@tel", "equiv_command": "@teleport"}}, {"pk": 2, "model": "config.commandalias", "fields": {"user_input": "ex", "equiv_command": "examine"}}, {"pk": 7, "model": "config.commandalias", "fields": {"user_input": "i", "equiv_command": "inventory"}}, {"pk": 8, "model": "config.commandalias", "fields": {"user_input": "inv", "equiv_command": "inventory"}}, {"pk": 1, "model": "config.commandalias", "fields": {"user_input": "l", "equiv_command": "look"}}, {"pk": 5, "model": "config.commandalias", "fields": {"user_input": "sa", "equiv_command": "say"}}, {"pk": 1, "model": "config.configvalue", "fields": {"conf_value": "Evennia Test Site", "conf_key": "site_name"}}, {"pk": 2, "model": "config.configvalue", "fields": {"conf_value": "2", "conf_key": "player_dbnum_start"}}, {"pk": 3, "model": "config.configvalue", "fields": {"conf_value": "Credits", "conf_key": "money_name_plural"}}, {"pk": 4, "model": "config.configvalue", "fields": {"conf_value": "Credit", "conf_key": "money_name_singular"}}, {"pk": 5, "model": "config.configvalue", "fields": {"conf_value": "1", "conf_key": "game_firstrun"}}, {"pk": 6, "model": "config.configvalue", "fields": {"conf_value": "1800", "conf_key": "idle_timeout"}}, {"pk": 7, "model": "config.configvalue", "fields": {"conf_value": "2", "conf_key": "default_home"}}]

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')

View file

@ -356,7 +356,7 @@ class ObjectManager(models.Manager):
# Create a player object of the same ID in the Objects table.
odat = {"id": uid,
"name": uname,
"type": 1,
"type": defines_global.OTYPE_PLAYER,
"location": start_room_obj,
"owner": None}
user_object = self.create_object(odat)

View file

@ -30,7 +30,7 @@ class Attribute(models.Model):
"""
attr_name = models.CharField(max_length=255)
attr_value = models.CharField(max_length=255)
attr_hidden = models.BooleanField(default=0)
attr_hidden = models.BooleanField(default=False)
attr_object = models.ForeignKey("Object")
objects = AttributeManager()
@ -903,6 +903,7 @@ class CommChannel(models.Model):
ansi_name = models.CharField(max_length=255)
owner = models.ForeignKey(Object, related_name="chan_owner")
description = models.CharField(max_length=80)
is_joined_by_default = models.BooleanField(default=False)
req_grp = models.ManyToManyField(Group, blank=True, null=True)
objects = CommChannelManager()

View file

@ -1,5 +1,5 @@
INSERT INTO objects_object VALUES(1,'Wizard','Wizard',1,0,'',2,1,'',2,'','CONNECTED','2007-04-25');
INSERT INTO objects_object VALUES(2,'Limbo','Limbo',1,NULL,'',NULL,2,'Welcome to your new Evennia-based game. From here you are ready to begin development. If you should need help or would like to participate in community discussions, visit http://evennia.com.',NULL,'','','2007-04-25');
INSERT INTO objects_commchannel VALUES(1,'Public','Public',1,'Public Discussion');
INSERT INTO objects_commchannel VALUES(2,'Errors','Errors',1,'Error Log');
INSERT INTO objects_commchannel VALUES(3,'Info','Info',1,'Info Log');
INSERT INTO objects_commchannel VALUES(1,'Public','Public',1,'Public Discussion', false);
INSERT INTO objects_commchannel VALUES(2,'Errors','Errors',1,'Error Log', false);
INSERT INTO objects_commchannel VALUES(3,'Info','Info',1,'Info Log', false);