示例#1
0
def verify( request, username = None, code = None, **kwargs ):
	kwargs[ 'page' ] = 'account/verify'
	success = False
	
	if request.user.is_authenticated():
		return response.run( request, **kwargs )
	
	if username and code:
		u = User.objects.get( username = username )
		success = u.get_profile().confirm( code )
	
	kwargs[ 'data' ] = { 'success' : success, 'verify' : True }
	return response.run( request, **kwargs )
示例#2
0
def register(request, **kwargs):
	kwargs['page'] = 'account/login'
	success = False
	
	if request.user.is_authenticated():
		return response.run(request, **kwargs)
	
	if request.POST:
		form = RegistrationForm(request.POST)
		if form.is_valid():
			u = User.objects.create_user(request.POST['username'], request.POST['email'], request.POST['password1'])
			u.get_profile().verify()
			success = True
	else:
		form = RegistrationForm()
	
	kwargs['data'] = { 'form' : form, 'success' : success }
	return response.run(request, **kwargs)
示例#3
0
def profile(request, **kwargs):
	kwargs['page'] = 'page/person'
	data = { 'success' : False, 'errors' : None, 'view' : True }
	user = request.user.get_profile().id if request.user.is_authenticated() else -1
	
	if kwargs.get('username', None):
		try:
			u = User.objects.get(username = kwargs.pop('username', None))
			p = u.get_profile()
			data['success'] = True
			data['user'] = u
			data['person'] = p
			data['admin'] = p.guard(user = user, action = 'edit')
		except Exception:
			data['errors'] = 'Invalid username'
	else:
		data['errors'] = 'Invalid username'
	
	kwargs['data'] = data
	return response.run(request, **kwargs)