mirror of
https://github.com/ansible/awx.git
synced 2026-02-01 17:48:10 -03:30
Start adding tastypie subresources
This commit is contained in:
@@ -2,16 +2,24 @@
|
||||
|
||||
from tastypie.resources import ModelResource
|
||||
from tastypie.authentication import BasicAuthentication
|
||||
from tastypie import fields #, utils
|
||||
|
||||
from lib.api.auth import AcomAuthorization
|
||||
from lib.api.resources.projects import Projects
|
||||
from lib.api.resources.users import Users
|
||||
|
||||
import lib.main.models as models
|
||||
|
||||
class Organizations(ModelResource):
|
||||
|
||||
users = fields.ToManyField(Users, 'users')
|
||||
admins = fields.ToManyField(Users, 'admins')
|
||||
projects = fields.ToManyField(Projects, 'projects')
|
||||
|
||||
class Meta:
|
||||
queryset = models.Organization.objects.all()
|
||||
resource_name = 'organizations'
|
||||
authentication = BasicAuthentication()
|
||||
authorization = AcomAuthorization()
|
||||
|
||||
|
||||
|
||||
|
||||
16
lib/api/resources/projects.py
Normal file
16
lib/api/resources/projects.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# myapp/api.py
|
||||
|
||||
from tastypie.resources import ModelResource
|
||||
from tastypie.authentication import BasicAuthentication
|
||||
from lib.api.auth import AcomAuthorization
|
||||
import lib.main.models as models
|
||||
|
||||
class Projects(ModelResource):
|
||||
|
||||
class Meta:
|
||||
queryset = models.Project.objects.all()
|
||||
resource_name = 'projects'
|
||||
authentication = BasicAuthentication()
|
||||
authorization = AcomAuthorization()
|
||||
|
||||
|
||||
16
lib/api/resources/users.py
Normal file
16
lib/api/resources/users.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# myapp/api.py
|
||||
|
||||
from tastypie.resources import ModelResource
|
||||
from tastypie.authentication import BasicAuthentication
|
||||
from lib.api.auth import AcomAuthorization
|
||||
import lib.main.models as models
|
||||
|
||||
class Users(ModelResource):
|
||||
|
||||
class Meta:
|
||||
queryset = models.User.objects.all()
|
||||
resource_name = 'users'
|
||||
authentication = BasicAuthentication()
|
||||
authorization = AcomAuthorization()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user