浏览代码

[doc2] Make document name explicit in validation exceptions

Romain Rigaux 9 年之前
父节点
当前提交
35945da
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      desktop/core/src/desktop/models.py

+ 3 - 3
desktop/core/src/desktop/models.py

@@ -1027,7 +1027,7 @@ class Document2(models.Model):
     # Validate document name
     invalid_chars = re.compile(r"[<>/{}[\]~`]");
     if invalid_chars.search(self.name):
-      raise FilesystemException(_('Document name contains an invalid character.'))
+      raise FilesystemException(_('Document %s contains an invalid character.') % self.name)
 
     # Validate that directories cannot have same name and parent
     if self.is_directory:
@@ -1044,8 +1044,8 @@ class Document2(models.Model):
 
     # Validate home and Trash directories are only created once per user and cannot be created or modified after
     if self.name in ['', Document2.TRASH_DIR] and \
-       Document2.objects.filter(name=self.name, owner=self.owner, type='directory').exists():
-      raise FilesystemException(_('Cannot create or modify the home or .Trash directory.'))
+          Document2.objects.filter(name=self.name, owner=self.owner, type='directory').exists():
+      raise FilesystemException(_('Cannot create directory with name %s') % self.name)
 
   def move(self, directory, user):
     if not directory.is_directory: