Outlining managers. I know some of these managers sub-modules only have one file in them, but let's keep the convention for consistency.

This commit is contained in:
Greg Taylor 2008-06-15 03:01:58 +00:00
parent 8ba1a93eeb
commit 43f0ae6af6
10 changed files with 68 additions and 15 deletions

View file

@ -0,0 +1,17 @@
"""
Custom manager for ConnectScreen objects.
"""
from django.db import models
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