Changeset - 35b75b6f963c
[Not reviewed]
0 1 0
James Polley - 7 years ago 2017-09-30 01:01:39
jp@jamezpolley.com
Badger should fail gracefully if auth_groups hasn't been populated

Let's say you've just installed symposion for the first time, and
you're running the intial `./manage.py migrate`

In that circumstance, there isn't an auth_group table. Naturally this
means you get Some Errors when trying to look for a particular group.

This change handles that error and drives on.
1 file changed with 8 insertions and 2 deletions:
0 comments (0 inline, 0 general)
vendor/registrasion/registrasion/contrib/badger.py
Show inline comments
...
 
@@ -25,6 +25,7 @@ import pdb
 
from django.core.management.base import BaseCommand
 

	
 
from django.contrib.auth.models import User, Group
 
from django.db.utils import OperationalError
 
from pinaxcon.registrasion.models import AttendeeProfile
 
from registrasion.controllers.cart import CartController
 
from registrasion.controllers.invoice import InvoiceController
...
 
@@ -124,8 +125,13 @@ def set_colour(soup, slice_id, colour):
 
    style = elem.get('style')
 
    elem.set('style', style.replace('fill:#316a9a', 'fill:#%s' % colour))
 

	
 
Volunteers = Group.objects.filter(name='Conference volunteers').first().user_set.all()
 
Organisers = Group.objects.filter(name='Conference organisers').first().user_set.all()
 
## It's possible that this script will be run before the database has been populated
 
try:
 
    Volunteers = Group.objects.filter(name='Conference volunteers').first().user_set.all()
 
    Organisers = Group.objects.filter(name='Conference organisers').first().user_set.all()
 
except (OperationalError, AttributeError):
 
    Volunteers = []
 
    Organisers = []
 

	
 
def is_volunteer(attendee):
 
    '''
0 comments (0 inline, 0 general)