@task(soft_time_limit=ADMIN_EXPORT_TIMEOUT)
def async_data_export(file_format, values_list, qs_model, filename):
 from django.contrib import admin
 admin_obj = admin.site._registry[qs_model]
 queryset = qs_model.objects.filter(id__in=values_list)
 resource_class = admin_obj.get_export_resource_class()
 data = resource_class().export(queryset)
 export_data = file_format.export_data(data)
 kwargs = {'aws_access_key_id': settings.AWS_ACCESS_KEY_ID, 'aws_secret_access_key': settings.AWS_SECRET_ACCESS_KEY, 'calling_format': OrdinaryCallingFormat()}
 conn = boto.connect_s3(**kwargs)
 bucket = conn.get_bucket(settings.MOZILLIANS_ADMIN_BUCKET)
 key = bucket.new_key(filename)
 key.set_contents_from_string(export_data)

@ task ( soft_time_limit = ADMIN_EXPORT_TIMEOUT ) def async_data_export ( file_format , values_list , qs_model , filename ) : from django . contrib import admin admin_obj = admin . site . _registry [ qs_model ] queryset = qs_model . objects . filter ( id__in = values_list ) resource_class = admin_obj . get_export_resource_class ( ) data = resource_class ( ) . export ( queryset ) export_data = file_format . export_data ( data ) kwargs = { 'aws_access_key_id' : settings . AWS_ACCESS_KEY_ID , 'aws_secret_access_key' : settings . AWS_SECRET_ACCESS_KEY , 'calling_format' : OrdinaryCallingFormat ( ) } conn = boto . connect_s3 ( ** kwargs ) bucket = conn . get_bucket ( settings . MOZILLIANS_ADMIN_BUCKET ) key = bucket . new_key ( filename ) key . set_contents_from_string ( export_data )
task to export data from admin site and store it to s3 .