Example #1
0
def owner_user_ref(request):
	"""
	Assuming the system has been set up, make the owner's account
	always referenceable in the templates. (TODO: Fix query redundancy)
	"""
	if not is_installed():
		return {}

	# If the user model is changed, reset form becomes inaccessible
	if request.META['PATH_INFO'].startswith('/reset'):
		return {}

	try:
		user = User.objects.get(pk=settings.OUR_USER_PK)
	except User.DoesNotExist:
		return {} # TODO: Is it wise to surpress this?

	return {'owner': user}
Example #2
0
	def process_view(self, request, view_func, view_args, view_kwargs):
		"""Runs just prior to having the view dispatched to and checks
		if the user exists in the database."""
		if is_installed():
			return None

		path = request.META['PATH_INFO']

		if path.startswith(settings.MEDIA_URL):
			return None

		# TODO: Not very configurable...
		if path not in ['', '/', '/reset', '/reset/']:
			return HttpResponseRedirect('/')

		if path.startswith('/reset'):
			return False

		# Call installation view instead!
		from sylph.core.backend.views import install_main
		return install_main(request)