def contact(request): """ Contact form Display and proceed contact form submission """ form = ContactForm(request.POST or None) if form.is_valid(): send_message("contact", form.cleaned_data) return redirect("confirm_contact") return render(request, "pages/contact.html", {"form": form})
def contact(request): """ Contact form Display and proceed contact form submission """ form = ContactForm(request.POST or None) if form.is_valid(): send_message('contact', form.cleaned_data) return redirect('confirm_contact') return render(request, 'pages/contact.html', {'form': form})
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, })
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})