本文整理汇总了Python中desktop.conf.USE_NEW_EDITOR类的典型用法代码示例。如果您正苦于以下问题:Python USE_NEW_EDITOR类的具体用法?Python USE_NEW_EDITOR怎么用?Python USE_NEW_EDITOR使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了USE_NEW_EDITOR类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_bundle
def edit_bundle(request):
bundle_id = request.GET.get('bundle')
doc = None
if bundle_id:
doc = Document2.objects.get(id=bundle_id)
bundle = Bundle(document=doc)
else:
bundle = Bundle()
bundle.set_workspace(request.user)
if USE_NEW_EDITOR.get():
coordinators = [dict([('id', d.id), ('uuid', d.uuid), ('name', d.name)])
for d in Document2.objects.documents(request.user).search_documents(types=['oozie-coordinator2'])]
else:
coordinators = [dict([('id', d.content_object.id), ('uuid', d.content_object.uuid), ('name', d.content_object.name)])
for d in Document.objects.get_docs(request.user, Document2, extra='coordinator2')]
can_edit_json = doc is None or (doc.can_write(request.user) if USE_NEW_EDITOR.get() else doc.doc.get().is_editable(request.user))
return render('editor2/bundle_editor.mako', request, {
'bundle_json': bundle.to_json_for_html(),
'coordinators_json': json.dumps(coordinators, cls=JSONEncoderForHTML),
'doc_uuid': doc.uuid if doc else '',
'is_embeddable': request.GET.get('is_embeddable', False),
'can_edit_json': json.dumps(can_edit_json)
})
示例2: handle_noargs
def handle_noargs(self, **options):
fs = cluster.get_hdfs()
create_directories(fs, [REMOTE_SAMPLE_DIR.get()])
remote_dir = REMOTE_SAMPLE_DIR.get()
# Copy examples binaries
for name in os.listdir(LOCAL_SAMPLE_DIR.get()):
local_dir = fs.join(LOCAL_SAMPLE_DIR.get(), name)
remote_data_dir = fs.join(remote_dir, name)
LOG.info(_('Copying examples %(local_dir)s to %(remote_data_dir)s\n') % {
'local_dir': local_dir, 'remote_data_dir': remote_data_dir})
fs.do_as_user(fs.DEFAULT_USER, fs.copyFromLocal, local_dir, remote_data_dir)
# Copy sample data
local_dir = paths.get_thirdparty_root("sample_data")
remote_data_dir = fs.join(remote_dir, 'data')
LOG.info(_('Copying data %(local_dir)s to %(remote_data_dir)s\n') % {
'local_dir': local_dir, 'remote_data_dir': remote_data_dir})
fs.do_as_user(fs.DEFAULT_USER, fs.copyFromLocal, local_dir, remote_data_dir)
# Load jobs
sample_user = install_sample_user()
management.call_command('loaddata', 'initial_pig_examples.json', verbosity=2)
Document.objects.sync()
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:
# Don't overwrite
doc = Document.objects.get(object_id=1100713)
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:
LOG.warn('Sample pig script document not found.')
except Document2.DoesNotExist:
if doc.content_object:
data = doc.content_object.dict
data.update({'content_type': doc.content_type.model, 'object_id': doc.object_id})
data = json.dumps(data)
doc2 = Document2.objects.create(
owner=sample_user,
parent_directory=examples_dir,
name=doc.name,
type='link-pigscript',
description=doc.description,
data=data)
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()])
示例3: delete_job
def delete_job(request):
if request.method != 'POST':
raise PopupException(_('A POST request is required.'))
jobs = json.loads(request.POST.get('selection'))
for job in jobs:
if job.get('uuid'):
doc2 = Document2.objects.get(id=job['id'])
if USE_NEW_EDITOR.get():
doc2 = Document2.objects.get(id=job['id'])
doc2.can_write_or_exception(request.user)
doc2.trash()
else:
doc = doc2.doc.get()
doc.can_write_or_exception(request.user)
doc.delete()
doc2.delete()
else: # Old version
job = Job.objects.can_read_or_exception(request, job['object_id'])
Job.objects.can_edit_or_exception(request, job)
OldWorklow.objects.destroy(job, request.fs)
response = {}
request.info(_('Document deleted.') if len(jobs) > 1 else _('Document deleted.'))
return JsonResponse(response)
示例4: index
def index(request):
if request.user.is_superuser and request.COOKIES.get('hueLandingPage') != 'home':
return redirect(reverse('about:index'))
else:
if USE_NEW_EDITOR.get():
return home2(request)
else:
return home(request)
示例5: notebooks
def notebooks(request):
editor_type = request.GET.get('type', 'notebook')
if editor_type != 'notebook':
if USE_NEW_EDITOR.get():
notebooks = [doc.to_dict() for doc in Document2.objects.documents(user=request.user).search_documents(types=['query-%s' % editor_type])]
else:
notebooks = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra__startswith='query')) if not d.content_object.is_history and d.content_object.type == 'query-' + editor_type]
else:
if USE_NEW_EDITOR.get():
notebooks = [doc.to_dict() for doc in Document2.objects.documents(user=request.user).search_documents(types=['notebook'])]
else:
notebooks = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra='notebook')) if not d.content_object.is_history]
return render('notebooks.mako', request, {
'notebooks_json': json.dumps(notebooks, cls=JSONEncoderForHTML),
'editor_type': editor_type
})
示例6: get_search_collections
def get_search_collections(self):
if USE_NEW_EDITOR.get():
return Document2.objects.documents(user=self.user).search_documents(
types=["search-dashboard"], order_by="-id"
)
else:
return [
d.content_object
for d in Document.objects.get_docs(self.user, Document2, extra="search-dashboard").order_by("-id")
]
示例7: install
def install(self, django_user):
"""
Install queries. Raise InstallException on failure.
"""
LOG.info('Installing sample query: %s' % (self.name,))
try:
# Don't overwrite
query = SavedQuery.objects.get(owner=django_user, name=self.name, type=self.type)
except SavedQuery.DoesNotExist:
query = SavedQuery(owner=django_user, name=self.name, type=self.type, desc=self.desc)
# The data field needs to be a string. The sample file writes it
# as json (without encoding into a string) for readability.
query.data = json.dumps(self.data)
query.save()
LOG.info('Successfully installed sample design: %s' % (self.name,))
if USE_NEW_EDITOR.get():
# Get or create sample user directories
home_dir = Directory.objects.get_home_directory(django_user)
examples_dir, created = Directory.objects.get_or_create(
parent_directory=home_dir,
owner=django_user,
name=Document2.EXAMPLES_DIR
)
try:
# Don't overwrite
doc2 = Document2.objects.get(owner=django_user, name=self.name, type=self._document_type(self.type))
# If document exists but has been trashed, recover from Trash
if doc2.parent_directory != examples_dir:
doc2.parent_directory = examples_dir
doc2.save()
except Document2.DoesNotExist:
# Create document from saved query
notebook = import_saved_beeswax_query(query)
data = notebook.get_data()
data['isSaved'] = True
uuid = data.get('uuid')
data = json.dumps(data)
doc2 = Document2.objects.create(
uuid=uuid,
owner=django_user,
parent_directory=examples_dir,
name=self.name,
type=self._document_type(self.type),
description=self.desc,
data=data
)
# Share with default group
examples_dir.share(django_user, Document2Permission.READ_PERM, groups=[get_default_user_group()])
LOG.info('Successfully installed sample query: %s' % (self.name,))
示例8: get_shared_search_collections
def get_shared_search_collections(self):
# Those are the ones appearing in the menu
if USE_NEW_EDITOR.get():
return Document2.objects.filter(
Q(owner=self.user) | Q(owner__username__in=SAMPLE_USER_OWNERS), type="search-dashboard"
).order_by("-id")
else:
docs = Document.objects.filter(
Q(owner=self.user) | Q(owner__username__in=SAMPLE_USER_OWNERS), extra="search-dashboard"
)
return [d.content_object for d in docs.order_by("-id")]
示例9: get_owner_search_collections
def get_owner_search_collections(self):
if USE_NEW_EDITOR.get():
if self.user.is_superuser:
docs = Document2.objects.filter(type="search-dashboard")
else:
docs = Document2.objects.filter(type="search-dashboard", owner=self.user)
return docs
else:
if self.user.is_superuser:
docs = Document.objects.filter(extra="search-dashboard")
else:
docs = Document.objects.filter(extra="search-dashboard", owner=self.user)
return [d.content_object for d in docs.order_by("-id")]
示例10: setUp
def setUp(self):
self.client = make_logged_in_client(username="perm_user", groupname="default", recreate=True, is_superuser=False)
self.client_not_me = make_logged_in_client(username="not_perm_user", groupname="default", recreate=True, is_superuser=False)
self.user = User.objects.get(username="perm_user")
self.user_not_me = User.objects.get(username="not_perm_user")
self.old_home_path = '/home2' if USE_NEW_EDITOR.get() else '/home'
grant_access(self.user.username, self.user.username, "desktop")
grant_access(self.user_not_me.username, self.user_not_me.username, "desktop")
PigScript.objects.filter(owner=self.user).delete()
Document.objects.filter(owner=self.user).delete()
示例11: list_editor_coordinators
def list_editor_coordinators(request):
if USE_NEW_EDITOR.get():
docs = Document2.objects.documents(user=request.user).search_documents(types=['oozie-coordinator2'])
coordinators = [doc.to_dict() for doc in docs]
else:
coordinators = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, extra='coordinator2')]
coordinators_v1 = [job.doc.get().to_dict() for job in Document.objects.available(OldCoordinator, request.user)]
if coordinators_v1:
coordinators.extend(coordinators_v1)
return render('editor2/list_editor_coordinators.mako', request, {
'coordinators_json': json.dumps(coordinators, cls=JSONEncoderForHTML),
})
示例12: list_editor_workflows
def list_editor_workflows(request):
if USE_NEW_EDITOR.get():
docs = Document2.objects.documents(user=request.user).search_documents(types=['oozie-workflow2'])
workflows = [doc.to_dict() for doc in docs]
else:
workflows = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, extra='workflow2')]
workflows_v1 = [job.doc.get().to_dict() for job in Document.objects.available(OldWorklow, request.user) if job.managed]
if workflows_v1:
workflows.extend(workflows_v1)
return render('editor2/list_editor_workflows.mako', request, {
'workflows_json': json.dumps(workflows, cls=JSONEncoderForHTML),
})
示例13: list_editor_bundles
def list_editor_bundles(request):
if USE_NEW_EDITOR.get():
docs = Document2.objects.documents(request.user).search_documents(types=['oozie-bundle2'])
bundles = [doc.to_dict() for doc in docs]
else:
bundles = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, extra='bundle2')]
bundles_v1 = [job.doc.get().to_dict() for job in Document.objects.available(OldBundle, request.user)]
if bundles_v1:
bundles.extend(bundles_v1)
return render('editor2/list_editor_bundles.mako', request, {
'bundles_json': json.dumps(bundles, cls=JSONEncoderForHTML),
})
示例14: index
def index(request, is_mobile=False, is_embeddable=False):
hue_collections = SearchController(request.user).get_search_collections()
collection_id = request.GET.get("collection")
if not hue_collections or not collection_id:
return admin_collections(request, True, is_mobile)
try:
collection_doc = Document2.objects.get(id=collection_id)
if USE_NEW_EDITOR.get():
collection_doc.can_read_or_exception(request.user)
else:
collection_doc.doc.get().can_read_or_exception(request.user)
collection = Collection2(request.user, document=collection_doc)
except Exception, e:
raise PopupException(e, title=_("Dashboard does not exist or you don't have the permission to access it."))
示例15: handle
def handle(self, *args, **options):
fs = cluster.get_hdfs()
create_directories(fs, [REMOTE_SAMPLE_DIR.get()])
remote_dir = REMOTE_SAMPLE_DIR.get()
sample_user = install_sample_user()
# Copy examples binaries
for name in os.listdir(LOCAL_SAMPLE_DIR.get()):
local_dir = fs.join(LOCAL_SAMPLE_DIR.get(), name)
remote_data_dir = fs.join(remote_dir, name)
LOG.info(_('Copying examples %(local_dir)s to %(remote_data_dir)s\n') % {
'local_dir': local_dir, 'remote_data_dir': remote_data_dir})
fs.do_as_user(sample_user.username, fs.copyFromLocal, local_dir, remote_data_dir)
# Copy sample data
local_dir = paths.get_thirdparty_root("sample_data")
remote_data_dir = fs.join(remote_dir, 'data')
LOG.info(_('Copying data %(local_dir)s to %(remote_data_dir)s\n') % {
'local_dir': local_dir, 'remote_data_dir': remote_data_dir})
fs.do_as_user(sample_user.username, fs.copyFromLocal, local_dir, remote_data_dir)
# Initialize doc2, whether editor script or link
doc2 = None
# Install editor pig script without doc1 link
LOG.info("Using Hue 4, will install pig editor sample.")
doc2 = self.install_pig_script(sample_user)
if USE_NEW_EDITOR.get():
# Get or create sample user directories
LOG.info("Creating 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)
# If document exists but has been trashed, recover from Trash
if doc2 and doc2.parent_directory != examples_dir:
doc2.parent_directory = examples_dir
doc2.save()
# Share with default group
examples_dir.share(sample_user, Document2Permission.READ_PERM, groups=[get_default_user_group()])