@@ -27,7 +27,9 @@ class CreditAllocationResourceViewSet(viewsets.ModelViewSet):
2727 permission_classes = [permissions .IsAuthenticated ]
2828
2929 def get_queryset (self ):
30- return models .CreditAllocationResource .objects .filter (allocation__pk = self .kwargs ["allocation_pk" ])
30+ return models .CreditAllocationResource .objects .filter (
31+ allocation__pk = self .kwargs ["allocation_pk" ]
32+ )
3133
3234 def _create_update_credit_allocations (self , request , allocation_pk ):
3335 """Allocate credits to a dictionary of resource classes.
@@ -65,15 +67,15 @@ def _create_update_credit_allocations(self, request, allocation_pk):
6567 # When creating with multiple resources a list of multiple entries is returned,
6668 # each with their own unique ID
6769 if len (serializer .data ) == 1 :
68- return Response (serializer .data [0 ], status = status .HTTP_201_CREATED )
70+ return Response (serializer .data [0 ], status = status .HTTP_201_CREATED )
6971 else :
70- return Response (serializer .data , status = status .HTTP_201_CREATED )
72+ return Response (serializer .data , status = status .HTTP_201_CREATED )
7173
7274 def create (self , request , allocation_pk = None ):
73- return self ._create_update_credit_allocations (request ,allocation_pk )
74-
75+ return self ._create_update_credit_allocations (request , allocation_pk )
76+
7577 def update (self , request , allocation_pk = None , pk = None ):
76- return self ._create_update_credit_allocations (request ,allocation_pk )
78+ return self ._create_update_credit_allocations (request , allocation_pk )
7779
7880 def _validate_request (self , request ):
7981
@@ -129,19 +131,25 @@ def retrieve(self, request, pk=None):
129131 )
130132
131133 # TODO(johngarbutt) look for any during the above allocations
132- consumers_query = models .Consumer .objects .filter (resource_provider_account__account__pk = pk )
134+ consumers_query = models .Consumer .objects .filter (
135+ resource_provider_account__account__pk = pk
136+ )
133137 consumers = serializers .Consumer (
134138 consumers_query , many = True , context = {"request" : request }
135139 )
136140
137141 account_summary ["allocations" ] = allocations .data
138142 account_summary ["consumers" ] = consumers .data
139143
140- all_allocation_resources_query = models .CreditAllocationResource .objects .filter (allocation__account__pk = pk )
144+ all_allocation_resources_query = models .CreditAllocationResource .objects .filter (
145+ allocation__account__pk = pk
146+ )
141147 # add resource_hours_remaining... must be a better way!
142148 # TODO(johngarbut) we don't check the dates line up!!
143149 for allocation in account_summary ["allocations" ]:
144- resources_for_allocation_query = all_allocation_resources_query .filter (allocation__id = allocation ["id" ])
150+ resources_for_allocation_query = all_allocation_resources_query .filter (
151+ allocation__id = allocation ["id" ]
152+ )
145153 resources_for_allocation = serializers .CreditAllocationResourceSerializer (
146154 resources_for_allocation_query , many = True , context = {"request" : request }
147155 )
0 commit comments