# Path: pyston/filters/filters.py
# OPERATORS = Enum(
#     ('GT', 'gt'),
#     ('LT', 'lt'),
#     ('EQ', 'eq'),
#     ('NEQ', 'neq'),
#     ('LTE', 'lte'),
#     ('GTE', 'gte'),
#     ('CONTAINS', 'contains'),
#     ('ICONTAINS', 'icontains'),
#     ('RANGE', 'range'),
#     ('EXACT', 'exact'),
#     ('IEXACT', 'iexact'),
#     ('STARTSWITH', 'startswith'),
#     ('ISTARTSWITH', 'istartswith'),
#     ('ENDSWITH', 'endswith'),
#     ('IENDSWITH', 'iendswith'),
#     ('IN', 'in'),
#     ('RANGE', 'range'),
#     ('ALL', 'all'),
#     ('ISNULL', 'isnull'),
# )
# 
# Path: pyston/contrib/dynamo/resource.py
# class BaseDynamoResource(BaseModelResource):
# 
#     register = True
#     abstract = True
# 
#     allowed_methods = ('get', 'head', 'options')
#     paginator = DynamoCursorBasedPaginator()
#     serializer = DynamoResourceSerializer
#     order_manager = DynamoOrderManager()
#     filter_manager = DynamoFilterManager()
# 
#     range_key = None
# 
#     def _get_hash_key(self):
#         raise NotImplementedError
# 
#     def _get_obj_or_none(self, pk=None):
#         if not pk:
#             return None
#         try:
#             return self.model.get(self._get_hash_key(), pk)
#         except self.model.DoesNotExist:
#             return None
# 
#     def _get_queryset(self):
#         return self.model.objects.set_hash_key(self._get_hash_key())
# 
#     def get_range_key(self):
#         return self.range_key
# 
# Path: pyston/contrib/dynamo/filter.py
# class BaseDynamoFilter(Filter):
# 
#     allowed_operators = None
# 
#     def get_allowed_operators(self):
#         return self.allowed_operators
# 
#     def clean_value(self, value, operator_slug, request):
#         return value
# 
#     def get_q(self, value, operator_slug, request):
#         if operator_slug not in self.get_allowed_operators():
#             raise OperatorFilterError
#         else:
#             return self.get_filter_term(self.clean_value(value, operator_slug, request), operator_slug, request)
# 
#     def get_filter_term(self, value, operator_slug, request):
#         raise NotImplementedError
# 
# Path: example/dj/apps/app/dynamo/models.py
# class Comment(DynamoModel):
# 
#     issue_id = UnicodeAttribute(hash_key=True)
#     user_id = UnicodeAttribute(range_key=True)
#     content = UnicodeAttribute()
#     is_public = BooleanAttribute()
#     priority = NumberAttribute()
# 
#     def __str__(self):
#         return self.id
# 
#     class Meta:
#         table_name = 'comment'


from pyston.filters.filters import OPERATORS
from pyston.contrib.dynamo.resource import BaseDynamoResource
from pyston.contrib.dynamo.filter import BaseDynamoFilter
from .models import Comment



class UserIDFilter(BaseDynamoFilter):

    allowed_operators = (OPERATORS.EQ,)

    def get_filter_term(self, value, operator_slug, request):
        return {'user_id__startswith': value}


class CommentDynamoResource(BaseDynamoResource):

    model = Comment
    fields = (
        'issue_id', 'user_id', 'content', 'is_public', 'priority'
    )
    filters = {
        'user_id': UserIDFilter,

# Path: pyston/filters/filters.py
# OPERATORS = Enum(
#     ('GT', 'gt'),
#     ('LT', 'lt'),
#     ('EQ', 'eq'),
#     ('NEQ', 'neq'),
#     ('LTE', 'lte'),
#     ('GTE', 'gte'),
#     ('CONTAINS', 'contains'),
#     ('ICONTAINS', 'icontains'),
#     ('RANGE', 'range'),
#     ('EXACT', 'exact'),
#     ('IEXACT', 'iexact'),
#     ('STARTSWITH', 'startswith'),
#     ('ISTARTSWITH', 'istartswith'),
#     ('ENDSWITH', 'endswith'),
#     ('IENDSWITH', 'iendswith'),
#     ('IN', 'in'),
#     ('RANGE', 'range'),
#     ('ALL', 'all'),
#     ('ISNULL', 'isnull'),
# )
# 
# Path: pyston/contrib/dynamo/resource.py
# class BaseDynamoResource(BaseModelResource):
# 
#     register = True
#     abstract = True
# 
#     allowed_methods = ('get', 'head', 'options')
#     paginator = DynamoCursorBasedPaginator()
#     serializer = DynamoResourceSerializer
#     order_manager = DynamoOrderManager()
#     filter_manager = DynamoFilterManager()
# 
#     range_key = None
# 
#     def _get_hash_key(self):
#         raise NotImplementedError
# 
#     def _get_obj_or_none(self, pk=None):
#         if not pk:
#             return None
#         try:
#             return self.model.get(self._get_hash_key(), pk)
#         except self.model.DoesNotExist:
#             return None
# 
#     def _get_queryset(self):
#         return self.model.objects.set_hash_key(self._get_hash_key())
# 
#     def get_range_key(self):
#         return self.range_key
# 
# Path: pyston/contrib/dynamo/filter.py
# class BaseDynamoFilter(Filter):
# 
#     allowed_operators = None
# 
#     def get_allowed_operators(self):
#         return self.allowed_operators
# 
#     def clean_value(self, value, operator_slug, request):
#         return value
# 
#     def get_q(self, value, operator_slug, request):
#         if operator_slug not in self.get_allowed_operators():
#             raise OperatorFilterError
#         else:
#             return self.get_filter_term(self.clean_value(value, operator_slug, request), operator_slug, request)
# 
#     def get_filter_term(self, value, operator_slug, request):
#         raise NotImplementedError
# 
# Path: example/dj/apps/app/dynamo/models.py
# class Comment(DynamoModel):
# 
#     issue_id = UnicodeAttribute(hash_key=True)
#     user_id = UnicodeAttribute(range_key=True)
#     content = UnicodeAttribute()
#     is_public = BooleanAttribute()
#     priority = NumberAttribute()
# 
#     def __str__(self):
#         return self.id
# 
#     class Meta:
#         table_name = 'comment'


# Path: example/dj/apps/app/dynamo/resource.py
from pyston.filters.filters import OPERATORS
from pyston.contrib.dynamo.resource import BaseDynamoResource
from pyston.contrib.dynamo.filter import BaseDynamoFilter
from .models import Comment




class UserIDFilter(BaseDynamoFilter):

    allowed_operators = (OPERATORS.EQ,)

    def get_filter_term(self, value, operator_slug, request):
        return {'user_id__startswith': value}


class CommentDynamoResource(BaseDynamoResource):

    model = Comment
    fields = (
        'issue_id', 'user_id', 'content', 'is_public', 'priority'
    )
    filters = {
        'user_id': UserIDFilter,

    }