#NEWLINE# def setUp( self ) : #NEWLINE# #INDENT# document_content_type = ContentType . objects . get_for_model ( Document ) #NEWLINE# add_doc_permission = Permission . objects . get ( content_type = document_content_type , codename = 'add_document' ) #NEWLINE# change_doc_permission = Permission . objects . get ( content_type = document_content_type , codename = 'change_document' ) #NEWLINE# self . root_collection = Collection . get_first_root_node ( ) #NEWLINE# self . reports_collection = self . root_collection . add_child ( name = 'Reports' ) #NEWLINE# doc_changers_group = Group . objects . create ( name = 'Document changers' ) #NEWLINE# GroupCollectionPermission . objects . create ( group = doc_changers_group , collection = self . root_collection , permission = change_doc_permission ) #NEWLINE# report_changers_group = Group . objects . create ( name = 'Report changers' ) #NEWLINE# GroupCollectionPermission . objects . create ( group = report_changers_group , collection = self . reports_collection , permission = change_doc_permission ) #NEWLINE# report_adders_group = Group . objects . create ( name = 'Report adders' ) #NEWLINE# GroupCollectionPermission . objects . create ( group = report_adders_group , collection = self . reports_collection , permission = add_doc_permission ) #NEWLINE# User = get_user_model ( ) #NEWLINE# self . superuser = User . objects . create_superuser ( 'superuser' , 'superuser@example.com' , 'password' ) #NEWLINE# self . inactive_superuser = User . objects . create_superuser ( 'inactivesuperuser' , 'inactivesuperuser@example.com' , 'password' , is_active = False ) #NEWLINE# self . doc_changer = User . objects . create_user ( 'docchanger' , 'docchanger@example.com' , 'password' ) #NEWLINE# self . doc_changer . groups . add ( doc_changers_group ) #NEWLINE# self . inactive_doc_changer = User . objects . create_user ( 'inactivedocchanger' , 'inactivedocchanger@example.com' , 'password' , is_active = False ) #NEWLINE# self . inactive_doc_changer . groups . add ( doc_changers_group ) #NEWLINE# self . report_changer = User . objects . create_user ( 'reportchanger' , 'reportchanger@example.com' , 'password' ) #NEWLINE# self . report_changer . groups . add ( report_changers_group ) #NEWLINE# self . report_adder = User . objects . create_user ( 'reportadder' , 'reportadder@example.com' , 'password' ) #NEWLINE# self . report_adder . groups . add ( report_adders_group ) #NEWLINE# self . useless_user = User . objects . create_user ( 'uselessuser' , 'uselessuser@example.com' , 'password' ) #NEWLINE# self . anonymous_user = AnonymousUser ( ) #NEWLINE# self . changer_doc = Document . objects . create ( title = "reportchanger's document" , collection = self . root_collection , uploaded_by_user = self . report_changer ) #NEWLINE# self . changer_report = Document . objects . create ( title = "reportchanger's report" , collection = self . reports_collection , uploaded_by_user = self . report_changer ) #NEWLINE# self . adder_report = Document . objects . create ( title = "reportadder's report" , collection = self . reports_collection , uploaded_by_user = self . report_adder ) #NEWLINE# self . useless_report = Document . objects . create ( title = "uselessuser's report" , collection = self . reports_collection , uploaded_by_user = self . useless_user ) #NEWLINE# self . anonymous_report = Document . objects . create ( title = 'anonymous report' , collection = self . reports_collection )