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 xmlapi(request):
    def xml_errmsg(f):
        return f"""
            There is no file. Re-upload the file.
            {f.errors}"""

    if request.method == 'POST':
        if hasattr(request, 'FILES'):
            f = UploadFileForm(request.POST, request.FILES)
            if f.is_valid():
                data = handle_uploaded_xml(request.FILES['file'])
                c = Contact()
                c.lastname = data['lastname']
                c.firstname = data['firstname']
                c.email = data['email']
                c.address = data['address']
                c.phone = data['phone']
                c.save()
                context = check_saved(c.lastname, c.firstname, c.email)
                return render(request, 'contact/contacts.html', context)
            else:
                err_msg = xml_errmsg(f)
                return HttpResponse(err_msg)
        else:
            err_msg = xml_errmsg(f)
            return HttpResponse(err_msg)
    else:
        print(f"{'#'*50} {__name__} {inspect.stack()[0][3]}\nException : {e}")
        return render(request, 'contact/errmsg.html',
                      {'message': 'Server Internal Error.'})
Exemplo n.º 3
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.º 4
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.º 5
0
 def form_valid(self, form):
     emergency_detail = Contact()
     emergency_detail.branch = Branch.objects.get(id=self.request.POST.get('branch'))
     emergency_detail.contact_name = self.request.POST.get('contact_name')
     emergency_detail.extension_number = self.request.POST.get('extension_number')
     emergency_detail.name = self.request.POST.get('name')
     emergency_detail.email = self.request.POST.get('email')
     emergency_detail.image = self.request.FILES.get('image')
     emergency_detail.save()
     return redirect('emergency:emergencyDetails_list')
Exemplo n.º 6
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.º 7
0
    def post(self, request, *args, **kwargs):
        form_class = self.get_form_class()
        form = self.get_form(form_class)

        contact = Contact()
        if form.is_valid():
            contact.email = form.cleaned_data['email']
            contact.first_name = form.cleaned_data['first_name']
            contact.last_name = form.cleaned_data['last_name']
            contact.profil_picture = form.cleaned_data['profil_picture']
            contact.added_by = self.request.user
            contact.save()
            return HttpResponseRedirect('/contact/')
        else:
            return render(request, self.template_name, {'form': form})
Exemplo n.º 8
0
def submit_query(request):
    contact = Contact()
    contact.name = request.POST.get('name')
    contact.email = request.POST.get('email')
    contact.subject = request.POST.get('subject')
    contact.query = request.POST.get('message')
    contact.resolved = False
    contact.save()
    message = """Subject:  """ + contact.subject \
              + """ Dear """ + contact.name + """
    
        Thank you for letting us know about your issue and sorry for inconvenience. We will surely get back to you as soon as possible and also thank you for
        using our services.
         
        Yours sincerely 
        D's Blog Team
    """
    return redirect('/')
Exemplo n.º 9
0
def vendor(request):
    context = {
        "vendor": Vendor.objects.all()
    }

    if request.method == 'POST':
        vendor = Vendor()
        vendor.vendor_type = request.POST.get('vendor_type')
        vendor.vendor_name = request.POST.get('vendor_name')
        vendor.address = request.POST.get('address')
        vendor.city = request.POST.get('city')
        vendor.state = request.POST.get('state')
        vendor.country = request.POST.get('country')
        vendor.phone_number = request.POST.get('phone_number')
        vendor.mobile1 = request.POST.get('mobile1')
        vendor.email = request.POST.get('email')
        vendor.pan_no = request.POST.get('pan_no')
        vendor.website = request.POST.get('website')
        vendor.tag = request.POST.get('tag')

        contact = Contact()
        contact.name = request.POST.get('vendor_name')

        contact.address = request.POST.get('address')
        contact.city = request.POST.get('city')
        contact.state = request.POST.get('state')
        contact.country = request.POST.get('country')
        contact.phone_number = request.POST.get('phone_number')
        contact.mobile_number = request.POST.get('mobile1')
        contact.email = request.POST.get('email')
        contact.pan_no = request.POST.get('pan_no')
        contact.website = request.POST.get('website')
        contact.tag = request.POST.get('tag')

        contact.save()


        vendor.save()
        return render(request, 'product/vendor/vendor.html', context)

    else:
        return render(request, 'product/vendor/vendor.html', context)
Exemplo n.º 10
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/')
Exemplo n.º 11
0
def add(request):
    f = ContactForm(request.POST)
    if f.is_valid():
        try:
            c = Contact()
            c.lastname = f.cleaned_data['lastname']
            c.firstname = f.cleaned_data['firstname']
            c.email = f.cleaned_data['email']
            c.address = f.cleaned_data['address']
            c.phone = f.cleaned_data['phone']
            c.save()
        except Exception as e:
            print(
                f"{'#'*50} {__name__} {inspect.stack()[0][3]}\nException : {e}"
            )
            return render(request, 'contact/errmsg.html',
                          {'message': 'Server Internal Error.'})
        else:
            context = check_saved(c.lastname, c.firstname, c.email)
            return render(request, 'contact/contacts.html', context)
    else:
        err_msg = data_errmsg(f)
        return HttpResponse(err_msg)