#NEWLINE# @ admin_required ( reviewers = True ) #NEWLINE# @ addon_view_factory ( qs = Addon . with_unlisted . all ) #NEWLINE# def addon_manage( request , addon ) : #NEWLINE# #INDENT# form = AddonStatusForm ( ( request . POST or None ) , instance = addon ) #NEWLINE# pager = amo . utils . paginate ( request , Version . unfiltered . filter ( addon = addon ) , 30 ) #NEWLINE# versions = list ( pager . object_list ) #NEWLINE# files = File . objects . filter ( version__in = versions ) . select_related ( 'version' ) #NEWLINE# formset = FileFormSet ( ( request . POST or None ) , queryset = files ) #NEWLINE# if ( form . is_valid ( ) and formset . is_valid ( ) ) : #NEWLINE# #INDENT# if ( 'status' in form . changed_data ) : #NEWLINE# #INDENT# amo . log ( amo . LOG . CHANGE_STATUS , addon , form . cleaned_data [ 'status' ] ) #NEWLINE# log . info ( ( 'Addon "%s" status changed to: %s' % ( addon . slug , form . cleaned_data [ 'status' ] ) ) ) #NEWLINE# form . save ( ) #NEWLINE# #UNINDENT# for form in formset : #NEWLINE# #INDENT# if ( 'status' in form . changed_data ) : #NEWLINE# #INDENT# log . info ( ( 'Addon "%s" file (ID:%d) status changed to: %s' % ( addon . slug , form . instance . id , files . cleaned_data [ 'status' ] ) ) ) #NEWLINE# form . save ( ) #NEWLINE# #UNINDENT# #UNINDENT# return redirect ( 'zadmin.addon_manage' , addon . slug ) #NEWLINE# #UNINDENT# form_map = dict ( ( ( form . instance . id , form ) for form in formset . forms ) ) #NEWLINE# file_map = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for file in files : #NEWLINE# #INDENT# file_map . setdefault ( file . version_id , [ ] ) . append ( file ) #NEWLINE# #UNINDENT# return render ( request , 'zadmin/addon_manage.html' , { #NEWLINE# #INDENT# 'addon' : addon , #NEWLINE# 'pager' : pager , #NEWLINE# 'versions' : versions , #NEWLINE# 'form' : form , #NEWLINE# 'formset' : formset , #NEWLINE# 'form_map' : form_map , #NEWLINE# 'file_map' : file_map , #NEWLINE# #UNINDENT# } )