<s> from collections import namedtuple <EOL> from datetime import datetime <EOL> from sqlalchemy import Column , Integer , String , Text , Boolean , DateTime , asc <EOL> from grouper . constants import MAX_NAME_LENGTH <EOL> from grouper . models . base . model_base import Model <EOL> MappedPermission = namedtuple ( '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> class Permission ( Model ) : <EOL> """<STR_LIT>""" <EOL> __tablename__ = "<STR_LIT>" <EOL> id = Column ( Integer , primary_key = True ) <EOL> name = Column ( String ( length = MAX_NAME_LENGTH ) , unique = True , nullable = False ) <EOL> description = Column ( Text , nullable = False ) <EOL> created_on = Column ( DateTime , default = datetime . utcnow , nullable = False ) <EOL> _audited = Column ( '<STR_LIT>' , Boolean , default = False , nullable = False ) <EOL> @ staticmethod <EOL> def get ( session , name = None ) : <EOL> if name is not None : <EOL> return session . query ( Permission ) . filter_by ( name = name ) . scalar ( ) <EOL> return None <EOL> @ staticmethod <EOL> def get_all ( session ) : <EOL> return session . query ( Permission ) . order_by ( asc ( "<STR_LIT:name>" ) ) . all ( ) <EOL> @ property <EOL> def audited ( self ) : <EOL> return self . _audited </s>
