|
@@ -17,13 +17,15 @@
|
|
|
|
|
|
|
|
import json
|
|
import json
|
|
|
import logging
|
|
import logging
|
|
|
|
|
+import re
|
|
|
import time
|
|
import time
|
|
|
|
|
|
|
|
from django.db import transaction
|
|
from django.db import transaction
|
|
|
from django.utils.translation import ugettext as _
|
|
from django.utils.translation import ugettext as _
|
|
|
|
|
|
|
|
from desktop.lib.exceptions_renderable import PopupException
|
|
from desktop.lib.exceptions_renderable import PopupException
|
|
|
-from desktop.models import Document, DocumentPermission, DocumentTag, Document2, Directory, Document2Permission
|
|
|
|
|
|
|
+from desktop.models import Document, DocumentPermission, DocumentTag, Document2, Directory, Document2Permission, \
|
|
|
|
|
+ DOC2_NAME_INVALID_CHARS
|
|
|
from notebook.api import _historify
|
|
from notebook.api import _historify
|
|
|
from notebook.models import import_saved_beeswax_query
|
|
from notebook.models import import_saved_beeswax_query
|
|
|
|
|
|
|
@@ -202,10 +204,13 @@ class DocumentConverter(object):
|
|
|
def _create_doc2(self, document, doctype, name=None, description=None, data=None):
|
|
def _create_doc2(self, document, doctype, name=None, description=None, data=None):
|
|
|
try:
|
|
try:
|
|
|
with transaction.atomic():
|
|
with transaction.atomic():
|
|
|
|
|
+ name = name if name else document.name
|
|
|
|
|
+ name = re.sub(DOC2_NAME_INVALID_CHARS, '', name)
|
|
|
|
|
+
|
|
|
document2 = Document2.objects.create(
|
|
document2 = Document2.objects.create(
|
|
|
owner=self.user,
|
|
owner=self.user,
|
|
|
parent_directory=self._get_parent_directory(document),
|
|
parent_directory=self._get_parent_directory(document),
|
|
|
- name=name if name else document.name,
|
|
|
|
|
|
|
+ name=name,
|
|
|
type=doctype,
|
|
type=doctype,
|
|
|
description=description,
|
|
description=description,
|
|
|
data=data
|
|
data=data
|