Exemplo n.º 1
0
    def post(self, request):
        form = ContactForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            name = data["name"]

            email = data["email"]
            message = data["message"]
            contact = Contact()
            contact.name = name
            contact.email = email
            contact.message = message
            contact.save()
            return HttpResponseRedirect('/merci/')
        else:

            block_script = BlockText.objects.all().filter(
                location="script").order_by("-id")
            script_site = None
            if block_script.count() > 0:
                script_site = block_script[0]

            return render(
                request, self.template_name, {
                    "form": form,
                    "message": "merci de corriger les erreurs suivants",
                    "script_site": script_site
                })
Exemplo n.º 2
0
def send(request):
    name = request.POST['name']
    email = request.POST['email']
    phone = request.POST['phone']
    message = request.POST['message']
    ip = request.META.get('REMOTE_ADDR')
    country = ""
    city = ""
    os = ""

    if not name or name == "Name":
        return HttpResponse("no_name")

    if not email or email == "E-mail":
        return HttpResponse("no_email")

    try:
        validate_email(email)
    except:
        return HttpResponse("no_valid_email")

    if not phone or phone == "Phone":
        return HttpResponse("no_phone")

    if not message or message == "Message":
        return HttpResponse("no_message")

    try:
        my_email = '*****@*****.**'
        subject = 'New contact!'
        html = "Name: " + name
        html = html + "<br>E-mail: " + email
        html = html + "<br>Phone: " + phone
        html = html + "<br><br>" + message
        _send_email(my_email, subject, html)
        email_feedback = "sent"

    except: 
        email_feedback = "error"

    try:
        contact = Contact()
        contact.name = name
        contact.email = email
        contact.phone = phone
        contact.message = message
        contact.ip = ip
        contact.country = country
        contact.city = city
        contact.os = os
        contact.email_feedback = email_feedback
        contact.date = datetime.now()
        contact.save()

        return HttpResponse("saved")

    except:
        return HttpResponse("error")
Exemplo n.º 3
0
def contact(request):
    if request.method == 'POST':
        contact_data = Contact()
        contact_data.name = request.POST.get('name')
        contact_data.email = request.POST.get('email')
        contact_data.subject = request.POST.get('subject')
        contact_data.message = request.POST.get('message')
        contact_data.save()

    return render(request, 'contact.html')
Exemplo n.º 4
0
def home(request):
    if request.method == 'POST':
        name = request.POST.get('name')
        email = request.POST.get('email')
        message = request.POST.get('message')

        contact = Contact()
        contact.name = name
        contact.email = email
        contact.message = message
        contact.save()
        return render(request, template_name='index.html')
    return render(request, template_name='index.html')
Exemplo n.º 5
0
def submitcontact(request):
    try:
        profiles = Profile.objects.get(user=request.user)
        internalmails_short = InternalMail.objects.filter(user=request.user)[0:3]
    except:
        return  HttpResponseRedirect('/accounts/login/')

    iid = id_generator() + id_generator()
    contacts = Contact()
    contacts.full_name = request.POST['full_name']
    contacts.organization = request.POST['organization']
    contacts.email = request.POST['email']
    contacts.message = request.POST['message']
    contacts.iid = iid
    contacts.save()

    message = "Your message has been submitted !"
    request.session['message'] = message

    return  HttpResponseRedirect('/accounts/profile/')