user_resource.py 872 B

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals
  3. from tastypie import fields
  4. from tastypie.resources import ModelResource, ALL, ALL_WITH_RELATIONS
  5. from tastypie.authorization import Authorization
  6. from core.models.user import User
  7. from api.resources.group_resource import GroupResource
  8. '''
  9. '''
  10. class UserResource(ModelResource):
  11. groups = fields.ToManyField(GroupResource, 'groups')
  12. class Meta:
  13. queryset = User.objects.all()
  14. authorization = Authorization()
  15. always_return_data = True
  16. # filtering = {
  17. # 'slug': ALL,
  18. # 'groups': ALL_WITH_RELATIONS,
  19. # 'created': ['exact', 'range', 'gt', 'gte', 'lt', 'lte'],
  20. # }
  21. '''
  22. '''
  23. def obj_create(self, bundle, **kwargs):
  24. print(bundle)
  25. print(kwargs)
  26. return super(UserResource, self).obj_create(bundle)