<s> from grouper . audit import get_audits <EOL> from grouper . constants import AUDIT_MANAGER , AUDIT_VIEWER <EOL> from grouper . fe . util import GrouperHandler <EOL> from grouper . model_soup import Audit <EOL> from grouper . models . audit_log import AuditLogCategory , AuditLog <EOL> class AuditsView ( GrouperHandler ) : <EOL> def get ( self ) : <EOL> user = self . get_current_user ( ) <EOL> if not ( user . has_permission ( AUDIT_VIEWER ) or user . has_permission ( AUDIT_MANAGER ) ) : <EOL> return self . forbidden ( ) <EOL> offset = int ( self . get_argument ( "<STR_LIT>" , <NUM_LIT:0> ) ) <EOL> limit = int ( self . get_argument ( "<STR_LIT>" , <NUM_LIT:50> ) ) <EOL> if limit > <NUM_LIT:200> : <EOL> limit = <NUM_LIT:200> <EOL> open_filter = self . get_argument ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> audits = get_audits ( self . session , only_open = ( open_filter == "<STR_LIT>" ) ) <EOL> open_audits = any ( [ not audit . complete for audit in audits ] ) <EOL> total = audits . count ( ) <EOL> audits = audits . offset ( offset ) . limit ( limit ) . all ( ) <EOL> open_audits = self . session . query ( Audit ) . filter ( <EOL> Audit . complete == False ) . all ( ) <EOL> can_start = user . has_permission ( AUDIT_MANAGER ) <EOL> audit_log_entries = AuditLog . get_entries ( self . session , category = AuditLogCategory . audit , <EOL> limit = <NUM_LIT:100> ) <EOL> self . render ( <EOL> "<STR_LIT>" , audits = audits , open_filter = open_filter , can_start = can_start , <EOL> offset = offset , limit = limit , total = total , open_audits = open_audits , <EOL> audit_log_entries = audit_log_entries , <EOL> ) </s>
