def pin_form_processor(request):
	if not request.user.is_authenticated():
		return {}
	else:
		data = {}
		for k,v in request.GET.iteritems():
			data[k]=v

		return {'pin_form': get_pin_description_form(request.user)(initial=data), 'board_form': BoardForm()}
def edit_pin(request, pin_pk):
	pin = get_object_or_404(Pin, pk=pin_pk, created_user=request.user, 
		is_active=True, board__is_active=True, board__category__is_active=True)
	form = get_pin_description_form(request.user)(request.POST or None, instance=pin)
	if form.is_valid():
		pin = form.save(commit=False)
		pin.is_active = True
		pin.save()
		messages.success(request, _('Pin edited successfully!'))
		return redirect("single_pin", pin.pk)
	return direct_to_template(request, "pins/edit_pin.html", locals())
def finish_pin(request):
	pin = get_object_or_404(Pin, pk=request.POST['pin_pk'], created_user=request.user)
	form = get_pin_description_form(request.user)(request.POST, instance=pin)
	if form.is_valid():
		pin = form.save(commit=False)
		pin.is_active = True
		pin.save()
		pins.signals.pin_finished.send_robust(finish_pin, instance=pin)
		messages.success(request, _('Pin uploaded successfully!'))
		return redirect("single_pin", pin.pk)
	else:
		messages.error(request, _('Could not upload pin!'))
		return redirect("pin_it")