def get_root_folder(): root_folder = Folder() root_folder.name = '-ROOT-' root_folder.description = 'System root folder' root_folder.owner = get_admin_user() root_folder.save() return root_folder
def add_test_folders(self, amount=4): for each in enumerate(range(amount), 1): folder = Folder() folder.name = f'TestFolder-{each[0]}' folder.description = f'Test Folder #{each[0]}' folder.owner = admin_user folder.parent = self._get_root_folder() folder.save()
def get_user_home_folder(request, home_folder: Folder) -> Folder: user_folder = Folder() user_folder.name = request.user.username user_folder.description = f'Home folder for {request.user.username}' user_folder.owner = request.user user_folder.parent = home_folder user_folder.save() return user_folder
def add_root_folders(self) -> None: for each in root_folders: folder = Folder() folder.name = each['name'] folder.description = each['description'] folder.owner = each['owner'] folder.parent = Folder.objects.get(name=each['parent']) folder.save()
def test_folder_add(self): folder = Folder() folder.name = SYS_ROOT_FOLDER_NAME folder.description = 'The system root folder' folder.owner = self.admin_user folder.save() self.assertTrue(Folder.objects.get(name=SYS_ROOT_FOLDER_NAME)) self.assertTrue(Folder.objects.get(description='The system root folder'))
def add_init_folders(self): for each in init_folders: folder = Folder() for k, v in each.items(): setattr(folder, k, v) folder.save()