Exemplo n.º 1
0
def page():
	"""Hybrid for creating start page and accepting login posts."""

	user_form = UserForm(request.form)

	data = {
		"current_page" : "home_page",
		"status" : system_status.retrieve_status(),
		"logged_in" : user_account.is_logged_in(),
		"user_name" : user_account.current_user_name(),
		"form" : user_form
	}

	if request.method == "GET":
		return render_template("home.html", **data)

	if not user_form.validate():
		flash(__("Data submitted was not valid"), "error")
		return render_template("home.html", **data)
		
	user = user_account.user_by_form(user_form)

	if user == None:
		flash(__("Invalid username or password"), "error")
		return render_template("home.html", **data)

	if login_user(user, remember = True):
		flash(__("You have been logged in"), "success")
		data["logged_in"] = True
		data["user_name"] = user_form.name.data
	else:
		flash(__("Could not login"), "error")
		
	return render_template("home.html", **data)
Exemplo n.º 2
0
def page():
	"""Creates a page with list of images."""

	data = {
		"current_page" : "images_page",
		"status" : system_status.retrieve_status(),
		"logged_in" : user_account.is_logged_in(),
		"user_name" : user_account.current_user_name(),
		"images" : dropbox_images.get_all_images()
	}

	return render_template("images.html", **data)
Exemplo n.º 3
0
def page():
	"""Creates a detailed status page for the device."""

	data = {
		"current_page" : "status_page",
		"status" : gsystem_status.retrieve_status(),
		"detailed_status" : system_status.get_detailed_status(),
		"logged_in" : user_account.is_logged_in(),
		"user_name" : user_account.current_user_name()
	}

	return render_template("status.html", **data)
Exemplo n.º 4
0
def page():
	"""Creates a page where users can connect to dropbox or manually sync against dropbox."""

	auth_callback_url = url_for("dropbox_authorize_page", _external = True)

	data = {
		"current_page" : "dropbox_page",
		"status" : gsystem_status.retrieve_status(),
		"dropbox_auth_url" : static_facade.get_authorize_url(auth_callback_url),
		"logged_in" : user_account.is_logged_in(),
		"user_name" : user_account.current_user_name()
	}

	return render_template("dropbox.html", **data)
Exemplo n.º 5
0
def page():
	"""Creates a page where users can configure the device."""

	config_form = ConfigForm(request.form)

	data = {
		"current_page" : "config_page",
		"status" : system_status.retrieve_status(),
		"logged_in" : user_account.is_logged_in(),
		"user_name" : user_account.current_user_name(),
		"form" : config_form
	}

	if request.method == "POST":
		if config_form.validate():
			user_config.save_by_form(config_form)
			flash(__("Data saved"), "success")
		else:
			flash(__("The data submitted was not valid"), "error")
	else:
		user_config.form_by_user(config_form)
		
	return render_template("config.html", **data)
Exemplo n.º 6
0
def get_detailed_status():
	"""Retrieves detailed status data for multiple tables."""

	status = system_status.retrieve_status()
	config = user_config.get_current_config()

	if status.latest_sync == 0:
		next_sync = __("Waiting for first sync")
	else:
		next_sync = status.latest_sync + (config.image_download_wait * 60)
		next_sync = cutetime(next_sync)

	access_token = dropbox_access.get_access_token()

	if user_account.is_logged_in() is False or access_token == (None, None):
		next_sync = __("Dropbox connection needed")

	return {
		"latest_sync" : status.latest_sync,
		"total_images_saved" : dropbox_images.get_amount(),
		"uptime" : status.uptime_start,
		"next_sync" : next_sync,
		"background_job" : JobEnum.value_repr(status.current_background_job)
	}