#NEWLINE# def handle_noargs( self , **options ) : #NEWLINE# #INDENT# mks = Member . objects . exclude ( current_party__isnull = True ) . order_by ( 'current_party' ) . values ( 'id' , 'name' , 'current_party' ) #NEWLINE# for agenda in Agenda . objects . all ( ) : #NEWLINE# #INDENT# f = open ( os . path . join ( settings . DATA_ROOT , ( 'agenda_%d.csv' % agenda . id ) ) , 'wt' ) #NEWLINE# csv_writer = csv . writer ( f ) #NEWLINE# header = [ ] #NEWLINE# header . append ( 'Vote id' ) #NEWLINE# header . append ( 'Vote title' ) #NEWLINE# header . append ( 'Vote time' ) #NEWLINE# header . append ( 'Score' ) #NEWLINE# header . append ( 'Importance' ) #NEWLINE# for mk in mks : #NEWLINE# #INDENT# header . append ( ( '%s %d' % ( mk [ 'name' ] . encode ( 'utf8' ) , mk [ 'id' ] ) ) ) #NEWLINE# #UNINDENT# csv_writer . writerow ( header ) #NEWLINE# for agenda_vote in AgendaVote . objects . filter ( agenda = agenda ) . select_related ( 'vote' ) : #NEWLINE# #INDENT# row = [ ] #NEWLINE# row . append ( agenda_vote . vote . id ) #NEWLINE# row . append ( agenda_vote . vote . title . encode ( 'utf8' ) ) #NEWLINE# row . append ( agenda_vote . vote . time . isoformat ( ) ) #NEWLINE# row . append ( agenda_vote . score ) #NEWLINE# row . append ( agenda_vote . importance ) #NEWLINE# mks_for = agenda_vote . vote . get_voters_id ( 'for' ) #NEWLINE# mks_against = agenda_vote . vote . get_voters_id ( 'against' ) #NEWLINE# for mk in mks : #NEWLINE# #INDENT# if ( mk [ 'id' ] in mks_for ) : #NEWLINE# #INDENT# row . append ( 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( mk [ 'id' ] in mks_against ) : #NEWLINE# #INDENT# row . append ( ( - 1 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# row . append ( 0 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# csv_writer . writerow ( row ) #NEWLINE# #UNINDENT# f . close ( )