#NEWLINE# def check_stats_permission( request , addon , for_contributions = False ) : #NEWLINE# #INDENT# '\n    Check if user is allowed to view stats for ``addon``.\n\n    Raises PermissionDenied if user is not allowed.\n    ' #NEWLINE# if ( addon . public_stats and ( not for_contributions ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# if ( not request . user . is_authenticated ( ) ) : #NEWLINE# #INDENT# raise PermissionDenied #NEWLINE# #UNINDENT# if ( not for_contributions ) : #NEWLINE# #INDENT# if ( addon . has_author ( request . user ) or acl . action_allowed ( request , 'Stats' , 'View' ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( addon . has_author ( request . user ) or acl . action_allowed ( request , 'RevenueStats' , 'View' ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# raise PermissionDenied