示例#1
0
 def _check_name(self):
     for record in self:
         if not file.check_name(record.name):
             raise ValidationError(_("The file name is invalid."))
         files = record.sudo().directory.files.name_get()
         if list(filter(lambda file: file[1] == record.name and file[0] != record.id, files)):
             raise ValidationError(_("A file with the same name already exists."))
示例#2
0
 def _check_name(self):
     for record in self:
         if not file.check_name(record.name):
             raise ValidationError(_("The directory name is invalid."))
         if record.is_root_directory:
             childs = record.sudo().root_storage.root_directories.name_get()
         else:
             childs = record.sudo().parent_directory.child_directories.name_get()
         if list(filter(lambda child: child[1] == record.name and child[0] != record.id, childs)):
             raise ValidationError(_("A directory with the same name already exists."))
示例#3
0
 def test_check_name(self):
     self.assertTrue(file.check_name("Test"))
     self.assertFalse(file.check_name("T/est"))