Forráskód Böngészése

HUE-3455 [doc2] Oozie documents are getting a time appended to their name

Up to the user to name his documents.
Adding a date does not really help much recognizing documents with same generic names
anyway.
Romain Rigaux 9 éve
szülő
commit
17dc4a0

+ 0 - 10
desktop/core/src/desktop/models.py

@@ -1053,16 +1053,6 @@ class Document2(models.Model):
     if invalid_chars.search(self.name):
       raise FilesystemException(_('Document %s contains an invalid character.') % self.name)
 
-    # If different document with same name and same path (parent) exists, rename current document with datetime
-    if Document2.objects.filter(
-            owner=self.owner,
-            name=self.name,
-            type=self.type,
-            parent_directory=self.parent_directory
-            ).exclude(pk=self.pk).exists():
-        timestamp = str(datetime.now()).split('.', 1)[0]
-        self.name = '%s %s' % (self.name, timestamp)
-
     # Validate home and Trash directories are only created once per user and cannot be created or modified after
     if self.name in [Document2.HOME_DIR, Document2.TRASH_DIR] and self.type == 'directory' and \
           Document2.objects.filter(name=self.name, owner=self.owner, type='directory').exists():

+ 0 - 17
desktop/core/src/desktop/tests_doc2.py

@@ -302,23 +302,6 @@ class TestDocument2(object):
     assert_true('invalid character' in data['message'])
 
 
-  def test_validate_same_name_and_path(self):
-    # Test that creating a document with the same name at the same path will auto-rename the document
-    test_dir = Directory.objects.create(name='test_dir', owner=self.user, parent_directory=self.home_dir)
-    response = self.client.post('/desktop/api2/doc/mkdir', {'parent_uuid': json.dumps(self.home_dir.uuid), 'name': json.dumps('test_dir')})
-    data = json.loads(response.content)
-    assert_equal(0, data['status'], data)
-
-    pattern = re.compile("test_dir \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}")
-    assert_true(pattern.match(data['directory']['name']), data)
-
-    # But can create same name in different location
-    response = self.client.post('/desktop/api2/doc/mkdir', {'parent_uuid': json.dumps(test_dir.uuid), 'name': json.dumps('test_dir')})
-    data = json.loads(response.content)
-    assert_equal(0, data['status'], data)
-    assert_equal('test_dir', data['directory']['name'])
-
-
   def test_validate_immutable_user_directories(self):
     # Test that home and Trash directories cannot be recreated or modified
     test_dir = Directory.objects.create(name='test_dir', owner=self.user, parent_directory=self.home_dir)