#NEWLINE# @ login_required #NEWLINE# @ no_cache #NEWLINE# def requester_details( request , requester_id ) : #NEWLINE# #INDENT# def row_formatter( input ) : #NEWLINE# #INDENT# for cc in input : #NEWLINE# #INDENT# row = [ ] #NEWLINE# url = reverse ( 'hit_group_details' , kwargs = { #NEWLINE# #INDENT# 'hit_group_id' : cc [ 5 ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# row . append ( ( '<a href="%s">%s</a>' % ( url , cc [ 0 ] ) ) ) #NEWLINE# row . extend ( cc [ 1 : 5 ] ) #NEWLINE# url = reverse ( 'admin-toggle-hitgroup-status' , args = ( cc [ 5 ] , ) ) #NEWLINE# row . append ( ( '<a href="%s">%s</a>' % ( url , ( ( cc [ 6 ] and 'public' ) or 'private' ) ) ) ) #NEWLINE# ( yield row ) #NEWLINE# #UNINDENT# #UNINDENT# requester_name = HitGroupContent . objects . filter ( requester_id = requester_id ) #NEWLINE# requester_name = requester_name . values_list ( 'requester_name' , flat = True ) . distinct ( ) #NEWLINE# if requester_name : #NEWLINE# #INDENT# requester_name = requester_name [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# requester_name = requester_id #NEWLINE# #UNINDENT# date_from = ( datetime . date . today ( ) - datetime . timedelta ( days = 30 ) ) #NEWLINE# data = query_to_tuples ( '\n        SELECT\n            title, hits_available, p.reward, p.occurrence_date,\n            (SELECT end_time FROM main_crawl WHERE id = (SELECT max(crawl_id) FROM main_hitgroupstatus WHERE group_id = q.group_id AND hit_group_content_id = p.group_content_id)) - p.occurrence_date, p.group_id, q.is_public\n        FROM\n            main_hitgroupfirstoccurences p\n                JOIN main_hitgroupcontent q ON (p.group_content_id = q.id AND p.requester_id = q.requester_id)\n        WHERE\n            p.requester_id = %s\n            AND p.occurrence_date > %s\n            AND q.occurrence_date > %s\n        ' , requester_id , date_from , date_from ) #NEWLINE# columns = ( ( 'string' , 'HIT Title' ) , ( 'number' , '#HITs' ) , ( 'number' , 'Reward' ) , ( 'datetime' , 'Posted' ) , ( 'number' , 'Duration (Days)' ) , ( 'string' , 'Status' ) ) #NEWLINE# ctx = { #NEWLINE# #INDENT# 'data' : text_row_formater ( row_formatter ( data ) ) , #NEWLINE# 'columns' : tuple ( columns ) , #NEWLINE# 'title' : ( 'Last 100 Tasks posted by %s' % requester_name ) , #NEWLINE# 'user' : request . user , #NEWLINE# #UNINDENT# } #NEWLINE# return direct_to_template ( request , 'main/requester_details.html' , row_formatter )