Exemple #1
0
def note_edit(request):
	if request.method == 'POST' and request.user.is_authenticated():
		form_edit = EditForm(request.POST)
		new_note = request.POST['decrypted_note']
		user = request.session['email']
		encipher('edit', user, new_note, request.session['password'])
		auth.logout(request)
		return HttpResponse('Done!')
	elif request.method == 'GET' and request.user.is_authenticated():
		form_edit = EditForm({'decrypted_note' : request.session['decrypted_note']})
	else:
		return HttpResponse('User not authenticated.')
	return render_to_response('editnote.htm', {'form': form_edit}, context_instance = RequestContext(request))
Exemple #2
0
def note_write(request):
	specialmsg = ''
	if request.method == 'POST':
		form = SignForm(request.POST)
		if form.is_valid():
			email = form.cleaned_data['email']
			deathnote = form.cleaned_data['deathnote']
			password = form.cleaned_data['password']
			ntrustees = form.cleaned_data['ntrustees']
			try:
				user = User.objects.create_user(username = email, password = password)
				user.save()
			except IntegrityError:
				specialmsg = 'User already exists!'
				form = SignForm(request.POST)
				return render_to_response('new.htm', {'form':form, 'specialmsg':specialmsg}, context_instance = RequestContext(request))
			piece = encipher('write', email, deathnote, password, ntrustees)
			send_mail('Deathnote update', 'Your note is saved. Your read only key for distribution is:\n ' + ''.join(piece[:]), '*****@*****.**',
    [email], fail_silently=False)
			return render_to_response('confirmation.htm', {'user':email, 'piece':piece})
	else:
		form = SignForm()
	return render_to_response('new.htm', {'form':form, 'specialmsg':specialmsg}, context_instance = RequestContext(request))