Removing mixins.py, as it's not in use. We now have a separate ConnectScreen model under the config app to store connect screens. ConfigValue's value fields are now CharFields instead of TextFields for the sake of efficiency and sanity. It is strongly recommended that you reset your config app and syncdb to load the fixture.

This commit is contained in:
Greg Taylor 2008-06-14 03:15:41 +00:00
parent f1760e6521
commit ffe9a563e0
5 changed files with 37 additions and 27 deletions

View file

@ -24,3 +24,31 @@ class ConfigValue(models.Model):
class Admin:
list_display = ('conf_key', 'conf_value',)
class ConnectScreenManager(models.Manager):
def get_random_connect_screen(self):
"""
Returns a random active connect screen.
"""
try:
return self.filter(is_active=True).order_by('?')[0]
except IndexError:
new_screen = ConnectScreen(name='Default',
connect_screen_text='This is a placeholder connect screen. Remind your admin to edit it through the Admin interface.')
new_screen.save()
return new_screen
class ConnectScreen(models.Model):
"""
Stores connect screens. The admins may have only one or multiple, which
will cycle randomly.
"""
name = models.CharField(max_length=255, help_text="An optional name for this screen (for organizational purposes).", blank=True)
connect_screen_text = models.TextField(help_text="The text for the connect screen. Color codes and substitutions are evaluated.")
is_active = models.BooleanField(default=1, help_text="Only active connect screens are placed in the rotation")
# Custom manager
objects = ConnectScreenManager()
class Admin:
list_display = ('id', 'name', 'is_active')