Skip to content

Commit

Permalink
Bugfix: database reference affecting Travis CI build process.
Browse files Browse the repository at this point in the history
  • Loading branch information
ropable committed Aug 21, 2017
1 parent 4bcb7f9 commit 77563f5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions prs2/api.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from django.conf import settings
from referral import api as referral_api
from taggit.models import Tag
from tastypie import fields
from tastypie.api import Api
from tastypie.authentication import SessionAuthentication
from tastypie.cache import SimpleCache
from tastypie.resources import ModelResource, ALL, ALL_WITH_RELATIONS
from tastypie.resources import ModelResource, ALL
from django.contrib.auth.models import User, Group
from django.db import ProgrammingError

v1_api = Api(api_name='v1')
v1_api.register(referral_api.DopTriggerResource())
Expand Down Expand Up @@ -46,9 +46,12 @@ class Meta:
class UserResource(ModelResource):

class Meta:
# Queryset should only return active users in the "PRS user" group.
prs_user = Group.objects.get_or_create(name=settings.PRS_USER_GROUP)[0]
queryset = User.objects.filter(groups__in=[prs_user], is_active=True)
try:
# Queryset should only return active users in the "PRS user" group.
prs_user = Group.objects.get_or_create(name=settings.PRS_USER_GROUP)[0]
queryset = User.objects.filter(groups__in=[prs_user], is_active=True)
except ProgrammingError:
queryset = User.objects.all()
ordering = ['username']
excludes = ['password', 'date_joined', 'is_staff', 'is_superuser', 'last_login']
filtering = {
Expand Down

0 comments on commit 77563f5

Please sign in to comment.