Ejemplo n.º 1
0
def report_shiny_in_wrapper(request, rid, path=None):
	if not rid or rid == '':
		return aux.fail_with404(request)
	try:
		fitem = Report.objects.get(id=rid)
	except ObjectDoesNotExist:
		return aux.fail_with404(request)
	# Enforce user access restrictions
	if not fitem.has_access_to_shiny(request.user):
		raise PermissionDenied

	p1 = fitem.type.shiny_report.report_link_rel_path(fitem.id)
	return aux.proxy_to(request, '%s/%s' % (p1, path), settings.SHINY_TARGET_URL)
Ejemplo n.º 2
0
def report_shiny_view_tab(request, rid):
	if not rid or rid == '':
		return aux.fail_with404(request)
	try:
		report = Report.objects.get(id=rid)
		assert isinstance(report, Report)
	except ObjectDoesNotExist:
		return aux.fail_with404(request)
	# Enforce user access restrictions
	if not report.has_access_to_shiny(request.user):
		raise PermissionDenied

	# return HttpResponseRedirect(reverse(report_shiny_in_wrapper, kwargs={ 'rid': rid }))
	return HttpResponseRedirect(report.get_shiny_report.url(report))
Ejemplo n.º 3
0
def report_shiny_view_tab_merged(request, rid, outside=False, u_key=None):
	try:
		a_report = Report.objects.get(id=rid)
	except ObjectDoesNotExist:
		return aux.fail_with404(request, 'There is no report with id ' + rid + ' in DB')

	if outside:
		# TODO
		# nozzle = reverse(report_nozzle_out_wrapper, kwargs={'s_key': a_report.shiny_key, 'u_key': u_key})
		nozzle = ''
		base_url = '' # reverse(report_shiny_view_tab_out, kwargs={'s_key': a_report.shiny_key, 'u_key': u_key})
		frame_src = ''
	else:
		# Enforce user access restrictions for Breeze users
		if not a_report.has_access_to_shiny(request.user):
			raise PermissionDenied
		# nozzle = reverse(report_file_view, kwargs={'rid': a_report.id})
		frame_src = reverse(report_file_view, kwargs={ 'rid': rid })
		nozzle = ''
		base_url = settings.SHINY_URL
		frame_src = '%s%s' % (base_url, a_report.id)

	return render_to_response('shiny_tab.html', RequestContext(request, {
		'nozzle'   : nozzle,
		'args'     : a_report.args_string,
		'base_url' : base_url,
		'outside'  : outside,
		'frame_src': frame_src,
		'title'    : a_report.name
	}))
Ejemplo n.º 4
0
def report_shiny_view_tab_out(request, s_key, u_key):
	__self__ = globals()[this_function_name()]  # instance to self
	try:  # TODO merge ACL with out wrapper in a new func
		# Enforces access control
		# both request will fail if the object is not found
		# we fetch the report
		a_report = Report.objects.get(shiny_key=s_key)
		# and if found, check the user with this key is in the share list of this report
		a_report.offsiteuser_set.get(user_key=u_key)
	except ObjectDoesNotExist:
		return aux.fail_with404(request)

	if request.GET.get('list'):
		page_index, entries_nb = aux.report_common(request)
		# get off-site user
		off_user = OffsiteUser.objects.get(user_key=u_key)
		# list all shiny-enabled report he has access to
		all_reports = off_user.shiny_access.exclude(shiny_key=None)
		for each in all_reports:
			each.url = reverse(__self__, kwargs={ 's_key': each.shiny_key, 'u_key': u_key })

		count = { 'total': all_reports.count() }
		paginator = Paginator(all_reports, entries_nb)  # show 18 items per page
		try:
			a_reports = paginator.page(page_index)
		except PageNotAnInteger:  # if page isn't an integer
			page_index = 1
			a_reports = paginator.page(page_index)
		except EmptyPage:  # if page out of bounds
			page_index = paginator.num_pages
			a_reports = paginator.page(page_index)

		count.update({
			'first': (page_index - 1) * entries_nb + 1,
			'last' : min(page_index * entries_nb, count['total'])
		})
		base_url = reverse(__self__, kwargs={ 's_key': a_report.shiny_key, 'u_key': u_key })
		return render_to_response('out_reports-paginator.html', RequestContext(request, {
			'reports'          : a_reports,
			'pagination_number': paginator.num_pages,
			'count'            : count,
			'base_url'         : base_url,
			'page'             : page_index
		}))
	# return report_shiny_view_tab_merged(request, a_report.id, outside=True, u_key=u_key)

	return report_shiny_view_tab_merged(request, a_report.id, outside=True, u_key=u_key)
Ejemplo n.º 5
0
def ui_checker_proxy(obj):
	"""	Run a self-test based on requested URL
	:param obj: SysCheckUnit object
	:type obj: SysCheckUnit | str
	:return: is test successful
	:rtype: bool
	"""
	if type(obj) == str:
		obj = ui_get_object(obj)
	if not isinstance(obj, SysCheckUnit) or not obj:
		from breeze import auxiliary as aux
		return aux.fail_with404(HttpRequest(), 'NOT FOUND')

	if obj.type in [RunType.both, RunType.runtime]:
		if obj.checker_function is check_watcher or obj.lp:
			return obj.checker_function()
		else:
			return obj.split_run(from_ui=True)
	return False