|
@@ -393,21 +393,28 @@ class ContentApi(object):
|
393
|
393
|
|
394
|
394
|
return result
|
395
|
395
|
|
396
|
|
- def create(self, content_type: str, workspace: Workspace, parent: Content=None, label: str ='', filename: str = '', do_save=False, is_temporary: bool=False, do_notify=True) -> Content:
|
|
396
|
+ def create(self, content_type: str, workspace: Workspace, parent: Content=None, label: str ='', label_is_filename: bool = False, do_save=False, is_temporary: bool=False, do_notify=True) -> Content:
|
397
|
397
|
assert content_type in ContentType.allowed_types()
|
398
|
398
|
|
399
|
399
|
if content_type == ContentType.Folder and not label:
|
400
|
400
|
label = self.generate_folder_label(workspace, parent)
|
401
|
401
|
|
402
|
402
|
content = Content()
|
403
|
|
- if label:
|
404
|
|
- content.label = label
|
405
|
|
- elif filename:
|
406
|
|
- # TODO - G.M - 2018-07-04 - File_name setting automatically
|
|
403
|
+
|
|
404
|
+ if label_is_filename:
|
|
405
|
+ # INFO - G.M - 2018-07-04 - File_name setting automatically
|
407
|
406
|
# set label and file_extension
|
408
|
407
|
content.file_name = label
|
409
|
|
- else:
|
410
|
|
- raise EmptyLabelNotAllowed()
|
|
408
|
+ elif label:
|
|
409
|
+ content.label = label
|
|
410
|
+
|
|
411
|
+ if not content.label:
|
|
412
|
+ if content_type == ContentType.Comment:
|
|
413
|
+ # INFO - G.M - 2018-07-16 - Default label for comments is
|
|
414
|
+ # empty string.
|
|
415
|
+ content.label = ''
|
|
416
|
+ else:
|
|
417
|
+ raise EmptyLabelNotAllowed('Content of this type should have a valid label') # nopep8
|
411
|
418
|
|
412
|
419
|
content.owner = self._user
|
413
|
420
|
content.parent = parent
|