Exemplo n.º 1
0
def edit_board(request, board_pk):
	board = get_object_or_404(Board, is_active=True, pk=board_pk, user=request.user,
	category__is_active=True)
	form = BoardForm(request.POST or None, instance=board)
	form_type = 'edit'#used in template
	if form.is_valid():
		form.save()
		messages.success(request, _('Board edited successfully.'))
		return redirect(board.get_absolute_url())
	return direct_to_template(request, "pins/rooms/form.html", locals())
Exemplo n.º 2
0
def add_board(request):
	"""
	Allows user to add board
	"""
	form = BoardForm(request.POST or None)
	if form.is_valid():
		board = form.save(commit=False)
		board.user = request.user
		board.save()
		messages.success(request, _('Board created successfully. You can now pin things you love on this board!'))
		return redirect('boards')
	return direct_to_template(request, "pins/rooms/form.html", locals())
Exemplo n.º 3
0
def edit_board(request, board_pk):
    board = get_object_or_404(Board,
                              is_active=True,
                              pk=board_pk,
                              user=request.user,
                              category__is_active=True)
    form = BoardForm(request.POST or None, instance=board)
    form_type = 'edit'  #used in template
    if form.is_valid():
        form.save()
        messages.success(request, _('Board edited successfully.'))
        return redirect(board.get_absolute_url())
    return direct_to_template(request, "pins/rooms/form.html", locals())
Exemplo n.º 4
0
def add_board(request):
    """
	Allows user to add board
	"""
    form = BoardForm(request.POST or None)
    if form.is_valid():
        board = form.save(commit=False)
        board.user = request.user
        board.save()
        messages.success(
            request,
            _('Board created successfully. You can now pin things you love on this board!'
              ))
        return redirect('boards')
    return direct_to_template(request, "pins/rooms/form.html", locals())
Exemplo n.º 5
0
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()
        }