def testRemoveAccess(self): # self.createPanePlot() Access.give_access(self.account_id_one, self.account_id_two, PermissionsTest.FILE_NAME) Access.remove_access(self.account_id_one, PermissionsTest.FILE_NAME) shared_doc = Document.select_shared_files(self.account_id_two) # Now file is removed from shared. self.assertEqual(shared_doc, [])
def delete_file(account, name): """ Deletes file belonging to user """ doc = Document.objects.get(file_name=name, account_id=account) if settings.PRODUCTION: doc.delete_file_from_storage() full_path = settings.BASE_DIR + doc.doc_file.url if os.path.isfile(full_path): os.remove(full_path) plotid_str_list = [] typeid_list = doc.pane_typeids.split(",") for typeid in typeid_list: plotid_str_list.append(typeid) owner_id = account file_name = name Access.remove_access(owner_id=owner_id, file_name=file_name) doc.delete() return plotid_str_list