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:
parent
8ba1a93eeb
commit
43f0ae6af6
10 changed files with 68 additions and 15 deletions
17
apps/config/managers/connectscreen.py
Normal file
17
apps/config/managers/connectscreen.py
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue