mirror of
https://github.com/ansible/awx.git
synced 2026-02-23 22:16:00 -03:30
Get tastypie relationships operational, consolidate resources into one file for easier sharing
This commit is contained in:
@@ -1 +1,42 @@
|
||||
from organizations import *
|
||||
from tastypie.resources import ModelResource, ALL
|
||||
from tastypie.authentication import BasicAuthentication
|
||||
from tastypie import fields, utils
|
||||
from lib.api.auth import AcomAuthorization
|
||||
#from django.conf.urls import url
|
||||
import lib.main.models as models
|
||||
|
||||
class Organizations(ModelResource):
|
||||
|
||||
class Meta:
|
||||
# related fields...
|
||||
queryset = models.Organization.objects.all()
|
||||
resource_name = 'organizations'
|
||||
authentication = BasicAuthentication()
|
||||
authorization = AcomAuthorization()
|
||||
#filtering = {
|
||||
# 'projects': ALL
|
||||
#}
|
||||
|
||||
users = fields.ToManyField('lib.api.resources.Users', 'users', related_name='organizations', blank=True, help_text='list of all organization users')
|
||||
admins = fields.ToManyField('lib.api.resources.Users', 'admins', related_name='admin_of_organizations', blank=True, help_text='list of administrator users')
|
||||
projects = fields.ToManyField('lib.api.resources.Projects', 'projects', related_name='organizations', blank=True, help_text='list of projects')
|
||||
|
||||
class Users(ModelResource):
|
||||
|
||||
class Meta:
|
||||
queryset = models.User.objects.all()
|
||||
resource_name = 'users'
|
||||
authentication = BasicAuthentication()
|
||||
authorization = AcomAuthorization()
|
||||
|
||||
class Projects(ModelResource):
|
||||
|
||||
|
||||
class Meta:
|
||||
queryset = models.Project.objects.all()
|
||||
resource_name = 'projects'
|
||||
authentication = BasicAuthentication()
|
||||
authorization = AcomAuthorization()
|
||||
|
||||
organizations = fields.ToManyField('lib.api.resources.Organizations', 'organizations', help_text='which organizations is this project in?')
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
# myapp/api.py
|
||||
|
||||
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()
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# 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()
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# 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