diff options
author | AlanCoding <arominger@ansible.com> | 2016-03-13 16:45:08 +0100 |
---|---|---|
committer | AlanCoding <arominger@ansible.com> | 2016-03-13 16:45:08 +0100 |
commit | 9f25a48936413c072c0b97d6048abd3eb9952b90 (patch) | |
tree | 40b53388513e5903c4212b8dc547b09431cfa6c6 | |
parent | Added queries that calculate counts for organization resources (diff) | |
download | awx-9f25a48936413c072c0b97d6048abd3eb9952b90.tar.xz awx-9f25a48936413c072c0b97d6048abd3eb9952b90.zip |
fix for POST scenario
-rw-r--r-- | awx/api/views.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/awx/api/views.py b/awx/api/views.py index 09a14f5381..7d7e5b34ad 100644 --- a/awx/api/views.py +++ b/awx/api/views.py @@ -596,15 +596,6 @@ class OrganizationList(ListCreateAPIView): model = Organization serializer_class = OrganizationSerializer - # @paginated - # def get(self, *args, **kwargs): - # # self.paginated_params = {'limit': limit, 'offset': offset, 'ordering': ordering} - # limit = kwargs.pop('limit') - # offset = kwargs.pop('offset') - # ordering = kwargs.pop('ordering') - # # qs[offset:offset + limit] - # return (super(OrganizationList, self).get(*args, **kwargs), 5, None) - def create(self, request, *args, **kwargs): """Create a new organzation. @@ -673,11 +664,16 @@ class OrganizationList(ListCreateAPIView): .annotate(Count('organization')).order_by('organization') count_context = {} + zeroed_dict = {'inventories': 0, 'teams': 0, 'users': 0, + 'job_templates': 0, 'admins': 0, 'projects': 0} for org in org_id_list: org_id = org['id'] - count_context[org_id] = {'inventories': 0, 'teams': 0, 'users': 0, - 'job_templates': 0, 'admins': 0, - 'projects': 0} + count_context[org_id] = zeroed_dict.copy() + if self.request.method == 'POST': + org_id = max([int(k) for k in count_context.keys()]) + 1 + # org_id = instance = self.get_object().id + # self.request.data['id'] + count_context[org_id] = zeroed_dict for res in db_results: for entry in db_results[res]: |