Added bulk acceptance and progress bar in review org applications view.
In the list of organization applications for reviewing, if you click the button "click here" the whole first text line will fade out and the progress bar will fade in while starting to contact the server for the list of orgs to accept and then make synchronous calls for acceptance, while updating the progress bar, the name of the organization currently accepting and the number of orgs already accepted against the total.
Inside the script, what's inside the parenthesis is converted due to regexp (in this case (link_id)) and then read the json_object.applications[index].link_id. By doing this with an eval(), you can use other names as well and the script will be reading for example json_object.applications[index].attribute_name if you insert "(attribute_name)" inside the link returned by {{ bulk_accept_link }}.
Notes by Lennard:
-Put Done outside the for-loop so that it also shows when there are 0 pre-accepted organizations.
-Made some minor style fixes
Patch by: Mario Ferraro
Reviewed by: Lennard de Rijk
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Base class for implementing API proxy stubs."""
from google.appengine.api import apiproxy_rpc
from google.appengine.runtime import apiproxy_errors
MAX_REQUEST_SIZE = 1 << 20
class APIProxyStub(object):
"""Base class for implementing API proxy stub classes.
To implement an API proxy stub:
- Extend this class.
- Override __init__ to pass in appropriate default service name.
- Implement service methods as _Dynamic_<method>(request, response).
"""
def __init__(self, service_name, max_request_size=MAX_REQUEST_SIZE):
"""Constructor.
Args:
service_name: Service name expected for all calls.
max_request_size: int, maximum allowable size of the incoming request. A
apiproxy_errors.RequestTooLargeError will be raised if the inbound
request exceeds this size. Default is 1 MB.
"""
self.__service_name = service_name
self.__max_request_size = max_request_size
def CreateRPC(self):
"""Creates RPC object instance.
Returns:
a instance of RPC.
"""
return apiproxy_rpc.RPC(stub=self)
def MakeSyncCall(self, service, call, request, response):
"""The main RPC entry point.
Args:
service: Must be name as provided to service_name of constructor.
call: A string representing the rpc to make. Must be part of
the underlying services methods and impemented by _Dynamic_<call>.
request: A protocol buffer of the type corresponding to 'call'.
response: A protocol buffer of the type corresponding to 'call'.
"""
assert service == self.__service_name, ('Expected "%s" service name, '
'was "%s"' % (self.__service_name,
service))
if request.ByteSize() > self.__max_request_size:
raise apiproxy_errors.RequestTooLargeError(
'The request to API call %s.%s() was too large.' % (service, call))
messages = []
assert request.IsInitialized(messages), messages
method = getattr(self, '_Dynamic_' + call)
method(request, response)