|
@@ -63,10 +63,21 @@ class Command(NoArgsCommand):
|
|
|
Document.objects.sync()
|
|
Document.objects.sync()
|
|
|
|
|
|
|
|
if USE_NEW_EDITOR.get():
|
|
if USE_NEW_EDITOR.get():
|
|
|
|
|
+ # Get or create sample user directories
|
|
|
|
|
+ home_dir = Directory.objects.get_home_directory(sample_user)
|
|
|
|
|
+ examples_dir, created = Directory.objects.get_or_create(
|
|
|
|
|
+ parent_directory=home_dir,
|
|
|
|
|
+ owner=sample_user,
|
|
|
|
|
+ name=Document2.EXAMPLES_DIR)
|
|
|
|
|
+
|
|
|
try:
|
|
try:
|
|
|
# Don't overwrite
|
|
# Don't overwrite
|
|
|
doc = Document.objects.get(object_id=1100713)
|
|
doc = Document.objects.get(object_id=1100713)
|
|
|
doc2 = Document2.objects.get(owner=sample_user, name=doc.name, type='link-pigscript')
|
|
doc2 = Document2.objects.get(owner=sample_user, name=doc.name, type='link-pigscript')
|
|
|
|
|
+ # If document exists but has been trashed, recover from Trash
|
|
|
|
|
+ if doc2.parent_directory != examples_dir:
|
|
|
|
|
+ doc2.parent_directory = examples_dir
|
|
|
|
|
+ doc2.save()
|
|
|
except Document.DoesNotExist:
|
|
except Document.DoesNotExist:
|
|
|
LOG.warn('Sample pig script document not found.')
|
|
LOG.warn('Sample pig script document not found.')
|
|
|
except Document2.DoesNotExist:
|
|
except Document2.DoesNotExist:
|
|
@@ -75,13 +86,6 @@ class Command(NoArgsCommand):
|
|
|
data.update({'content_type': doc.content_type.model, 'object_id': doc.object_id})
|
|
data.update({'content_type': doc.content_type.model, 'object_id': doc.object_id})
|
|
|
data = json.dumps(data)
|
|
data = json.dumps(data)
|
|
|
|
|
|
|
|
- # Get or create sample user directories
|
|
|
|
|
- home_dir = Directory.objects.get_home_directory(sample_user)
|
|
|
|
|
- examples_dir, created = Directory.objects.get_or_create(
|
|
|
|
|
- parent_directory=home_dir,
|
|
|
|
|
- owner=sample_user,
|
|
|
|
|
- name=Document2.EXAMPLES_DIR)
|
|
|
|
|
-
|
|
|
|
|
doc2 = Document2.objects.create(
|
|
doc2 = Document2.objects.create(
|
|
|
owner=sample_user,
|
|
owner=sample_user,
|
|
|
parent_directory=examples_dir,
|
|
parent_directory=examples_dir,
|
|
@@ -90,10 +94,6 @@ class Command(NoArgsCommand):
|
|
|
description=doc.description,
|
|
description=doc.description,
|
|
|
data=data)
|
|
data=data)
|
|
|
|
|
|
|
|
- # Share with default group
|
|
|
|
|
- examples_dir.share(sample_user, Document2Permission.READ_PERM, groups=[get_default_user_group()])
|
|
|
|
|
- doc2.save()
|
|
|
|
|
-
|
|
|
|
|
- LOG.info('Successfully installed sample link to pig script: %s' % (doc2.name,))
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ # Share with default group
|
|
|
|
|
+ examples_dir.share(sample_user, Document2Permission.READ_PERM, groups=[get_default_user_group()])
|
|
|
|
|
+ LOG.info('Successfully installed sample link to pig script: %s' % (doc2.name,))
|