Пример #1
0
def suggest(request):
    """ Suggest form
        Display and proceed suggest a website form submission
    """
    form = SuggestForm(
        request.POST or None,
        request.FILES or None,
        initial=dict(url='http://')
    )

    if form.is_valid():
        website = form.save(commit=False)
        website.submitter = request.user
        website.save()
        send_message('suggest', {
            'website': website.url,
            'username': request.user.username,
            'sender': request.user.email
        })
        messages.success(request, _('Thanks for your proposition.'))
        return redirect('websites_index')

    return render(request, 'websites/suggest.html', {'form': form})
Пример #2
0
def suggest(request):
    """
    Suggest form
    Display and proceed suggest a website form submission
    """
    if request.method == 'POST':
        form = SuggestForm(request.POST, request.FILES)
        if form.is_valid():
            website = form.save(commit=False)
            website.submitter = request.user
            website.save()
            send_message('suggest', {
                'website': website.url,
                'username': request.user.username,
                'sender': request.user.email,
            })
            return redirect('confirm_suggest_website')
    else:
        form = SuggestForm(initial=dict(url='http://'))
    return render(request, 'websites/suggest.html', {
        'form': form,
    })