api.py 887 Bytes
Newer Older
Guyzmo's avatar
Guyzmo committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#from django.contrib.auth.models import User
from tastypie import fields
from tastypie.authorization import DjangoAuthorization
from tastypie.resources import ModelResource, ALL#, ALL_WITH_RELATIONS
from bt.models import Violation


#class UserResource(ModelResource):
#    class Meta:
#        queryset = User.objects.all()
#        resource_name = 'auth/user'
#        excludes = ['email', 'password', 'is_superuser']


class APIResource(ModelResource):
#    user = fields.ForeignKey(UserResource, 'user')

    class Meta:
        queryset = Violation.objects.all()
        list_allowed_methods = ['get', 'post']
        detail_allowed_methods = ['get', 'post', 'put', 'delete']
        resource_name = 'violations'
        authorization = DjangoAuthorization()
        filtering = {
            'country': ALL,
            'operator': ALL,
            'activationid': ALL,
        }