Example #1
0
def delete_chart(report_id, chart_id):
	report = session.query(Report).filter_by(id=report_id).first()

	if not has_privileges(report):
		return abort(401)

	session.query(Chart).filter_by(id=chart_id, report=report_id).delete()
	report.modified = datetime.datetime.now()
	session.commit()

	return jsonify(data=None)
Example #2
0
def report_view(report_id):
	form = LoginForm(session)

	report = session.query(Report).filter_by(id=report_id).first()

	author = session.query(User).filter_by(id=report.user).first()

	if report.public:
		return render_template('report_edit.html', form=form, 
			user=current_user, report=report, author=author.user, edit=False)
	elif has_privileges(report):
		 return redirect(url_for('report_edit', report_id=report_id))
	else:
		return abort(404)
Example #3
0
def chart_edit(report_id):
	report = session.query(Report).filter_by(id=report_id).first()

	if not has_privileges(report):
		return abort(401)

	form = LoginForm(session)
	return render_template('edit.html', form=form, user=current_user)
Example #4
0
def remove_report(report_id):
	report = session.query(Report).filter_by(id=report_id, user=current_user.id).first()

	session.delete(report)

	session.commit()

	return redirect(url_for("profile"))
Example #5
0
def get_endpoints():
	available_endpoints = session.query(Endpoint).all()

	endpoints = []
	for endpoint in available_endpoints:
		endpoints.append({'id': endpoint.id, 'url': endpoint.url })

	return jsonify(endpoints=endpoints)
Example #6
0
def make_private(report_id):
	report = session.query(Report).filter_by(id=report_id, user=current_user.id).first()

	if report is not None:
		report.public = False

	session.commit()

	return redirect(url_for("profile"))
Example #7
0
def update_report(report_id):
	report = session.query(Report).filter_by(id=report_id).first()

	if not has_privileges(report):
		return abort(401)

	report.name = request.form['name']
	session.commit()

	return jsonify(data=None)
Example #8
0
def new_chart(report_id):
	report = session.query(Report).filter_by(id=report_id).first()

	if not has_privileges(report):
		return abort(401)

	chart = Chart('Default title')
	chart.id = -1

	form = LoginForm(session)
	return render_template('edit.html', form=form, user=current_user, report=report, chart=chart, new=True)
Example #9
0
def shorten(uri):
	long_prefix = get_long_prefix(uri)
		
	prefix = session.query(Prefix).filter_by(uri=long_prefix).first()
	if prefix is None:
		prefix = Prefix(get_long_prefix(uri))

		session.add(prefix)
		session.commit()

	return uri.replace(prefix.uri, prefix.prefix + ':')
Example #10
0
def chart_save(report_id, chart_id):
	report = session.query(Report).filter_by(id=report_id).first()

	if not has_privileges(report):
		return abort(401)

	if chart_id == 'new':
		name = request.form['name']
		chart = Chart(name)
		report.charts.append(chart)
	else:
		chart = session.query(Chart).filter_by(id=chart_id).first()

	chart.json = request.form['chart']

	report.modified = datetime.datetime.now()

	session.commit()	

	report = session.query(Report).filter_by(id=chart.report).first()

	return redirect(url_for("report_edit", report_id=report.id))
Example #11
0
def load_user(user_id):
	user = session.query(User).get(user_id)
	return user
Example #12
0
def enlarge(uri):
	short_prefix = get_short_prefix(uri)

	prefix = session.query(Prefix).filter_by(prefix=short_prefix).first()

	return uri.replace(prefix.prefix +':', prefix.uri)