Migration needed. Changed how connection screens are defined, rather than being a database model, they are created on-the fly. I didn't migrate over the screen data into the new module file though, so if you had custom connection screens, you need to manually add them to the new module in gamesrc/world/connection_screen.py.

This commit is contained in:
Griatch 2011-04-10 14:21:41 +00:00
parent 52785e8f3e
commit 2ee54678ae
12 changed files with 110 additions and 174 deletions

View file

@ -9,7 +9,6 @@ ConnectScreen model - cycling connect screens
from django.db import models
from src.utils.idmapper.models import SharedMemoryModel
from src.config.manager import ConfigValueManager
from src.config.manager import ConnectScreenManager
#------------------------------------------------------------
#
@ -93,99 +92,3 @@ class ConfigValue(SharedMemoryModel):
def __unicode__(self):
return "%s" % self.key
#------------------------------------------------------------
## ConnectScreen
#
#------------------------------------------------------------
class ConnectScreen(SharedMemoryModel):
"""
Stores connect screens. The admins may have only one or multiple, which
will cycle randomly.
Properties on ConnectScreen:
key - optional identifier
text - the text to show
is_active - if the screen is in rotation
"""
#
# ConnectScreen database model setup
#
# These database fields are all set using their corresponding properties,
# named same as the field, but withtout the db_* prefix.
#
# optional identifier
db_key = models.CharField(max_length=255, blank=True)
# connect screen text (ansi may be used)
db_text = models.TextField()
# if this screen should be used in rotation
db_is_active = models.BooleanField(default=True)
# Database manager
objects = ConnectScreenManager()
# Wrapper properties to easily set database fields. These are
# @property decorators that allows to access these fields using
# normal python operations (without having to remember to save()
# etc). So e.g. a property 'attr' has a get/set/del decorator
# defined that allows the user to do self.attr = value,
# value = self.attr and del self.attr respectively (where self
# is the object in question).
# key property (wraps db_key)
#@property
def key_get(self):
"Getter. Allows for value = self.key"
return self.db_key
#@key.setter
def key_set(self, value):
"Setter. Allows for self.key = value"
self.db_key = value
self.save()
#@key.deleter
def key_del(self):
"Deleter. Allows for del self.key. Deletes entry."
self.delete()
key = property(key_get, key_set, key_del)
# text property (wraps db_text)
#@property
def text_get(self):
"Getter. Allows for value = self.text"
return self.db_text
#@text.setter
def text_set(self, value):
"Setter. Allows for self.text = value"
self.db_text = value
self.save()
#@text.deleter
def text_del(self):
"Deleter. Allows for del self.text."
raise Exception("You can't delete the text of the connect screen!")
text = property(text_get, text_set, text_del)
# is_active property (wraps db_is_active)
#@property
def is_active_get(self):
"Getter. Allows for value = self.is_active"
return self.db_is_active
#@is_active.setter
def is_active_set(self, value):
"Setter. Allows for self.is_active = value"
self.db_is_active = value
self.save()
#@is_active.deleter
def is_active_del(self):
"Deleter. Allows for del self.is_active."
self.db_is_active = False
self.save()
is_active = property(is_active_get, is_active_set, is_active_del)
class Meta:
"Define Django meta options"
verbose_name = "Connect Screen"
verbose_name_plural = "Connect Screens"