|
|
|
@ -1,7 +1,7 @@
@@ -1,7 +1,7 @@
|
|
|
|
|
from pyramid.security import Allow, Authenticated, Deny, Everyone |
|
|
|
|
|
|
|
|
|
from .base import BaseResource, PaginationResourceMixin |
|
|
|
|
from ordr2.models import User |
|
|
|
|
from ordr2.models import User, Role |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -24,10 +24,14 @@ class UserList(BaseResource, PaginationResourceMixin):
@@ -24,10 +24,14 @@ class UserList(BaseResource, PaginationResourceMixin):
|
|
|
|
|
def prepare_filtered_query(self, dbsession, filter_params): |
|
|
|
|
''' setup the base filtered query ''' |
|
|
|
|
query = dbsession.query(self.sql_model_class) |
|
|
|
|
role = filter_params.get('role', None) |
|
|
|
|
if role is not None: |
|
|
|
|
role_name = filter_params.get('role', None) |
|
|
|
|
try: |
|
|
|
|
role_name = role_name.lower() |
|
|
|
|
role = Role(role_name) |
|
|
|
|
query = query.filter_by(role=role) |
|
|
|
|
self.filters['role'] = role |
|
|
|
|
except (AttributeError, ValueError): |
|
|
|
|
role_name = None |
|
|
|
|
self.filters['role'] = role_name |
|
|
|
|
return query |
|
|
|
|
|
|
|
|
|
|
|
|
|
|