Example #1
0
def create_contact():
    print(request.form)
    if request.method == 'GET':
        return render_template("create_contact.html")
    else:
        name = request.form.get('name')
        address = request.form.get('address')
        ph_num = request.form.get('ph_num')
        email = request.form.get('email')

        contact = Contact(name=name,
                          address=address,
                          ph_num=ph_num,
                          email=email)
        contact.save()
        return render_template("index.html")
Example #2
0
    def create_app(self):

        config_name = 'testing'
        app.config.update(
            SQLALCHEMY_DATABASE_URI=os.getenv('TEST_DB_URI'),
            SECRET_KET=os.getenv('TEST_SECRET_KEY'), 
            WTF_CSRF_ENABLES=False,
            DEBUG=True
        )
        self.user = Admin(
            email='*****@*****.**', 
            password=bcrypt.generate_password_hash('ThisPasswordSucks'))

        self.contact = Contact(
            first_name= 'John', 
            last_name= 'Johnson', 
            email_address= '*****@*****.**', 
            phone_number= '+446789261532', 
            location_id = 1
        )
        self.location = Locations(
            first_line = 'number 1', 
            second_line = 'some street', 
            city = 'Manchester', 
            post_code = 'AAA1 AAA'
        )
        return app
Example #3
0
def contact_mail(request):
    from user.models import User
    # from user.views import send_mail_to_client
    from application.models import Contact
    import json
    data = {"c": True, "sent": False, "ef": False}
    try:
        name = request.POST["name"]
        email = request.POST['email']
        subject = request.POST['subject']
        message = request.POST['message']
        from django.core.exceptions import ValidationError

        from django.core.validators import validate_email
        try:
            validate_email(email)
        except ValidationError:
            data['ef'] = True
            return HttpResponse(json.dumps(data))
        try:
            cu = Contact(name=name,
                         email=email,
                         subject=subject,
                         message=message)
            cu.save()
            data['sent'] = True
        except Exception as e:
            print(e)
            print("error")
            data['c'] = False
            return HttpResponse(json.dumps(data))

        msg = "<style>@import url('https://fonts.googleapis.com/css?family=Open+Sans&display=swap');</style>"
        msg = msg + "<div style=\"font-family:'Open Sans',Arial,sans-serif;\"><div style='min-height:4rem;width:100%;display:block;border-bottom:1px solid #c5c5c5;margin-bottom:10px;'><div style='width:fit-content;height:fit-content;margin:auto;display:flex;justify-content:center;align-content:center;'><a href='https://wasche-services.herokuapp.com' style='color:black;font-size:1.6rem;text-decoration:none;text-transform:uppercase;letter-spacing:2px;font-weight:bold;padding:0;margin:0;text-shadow:1px 1px 1px rgba(0,0,0,0.1);'>Wasche</a></div></div>"
        msg = msg + "<h2 style='margin-bottom:5px;padding:5px;margin-top:10px;'>Thank you for contacting us.</h2><h4> Your information has been sent to our professional workers.<br>You will soon here from us regarding your enquiry.</h4><br><br><p style='font-size:15px'>Than you, <b>Wasche Laundry Services.</b></p></div> "

        send_mail_to_client(
            email, "Contact Information",
            "Thank you for contacting us.\n\nYour information has been sent to our professional workers.\nYou will soon here from us regarding your enquiry.\n\nThank you, \nWasche Laundry Services.",
            msg)

    except:
        data['sent'] = False
    return HttpResponse(json.dumps(data))
Example #4
0
def new():
    form = NewContactForm()
    cities = Locations.query.all()
    for city in cities:
        form.city.choices.append([city.location_id, city.city])
    if form.validate_on_submit():
        Data = Contact(first_name = form.first_name.data, last_name = form.last_name.data, email_address = form.email_address.data, phone_number = form.phone_number.data, location_id = form.city.data)
        db.session.add(Data)
        db.session.commit()

        return redirect(url_for('home'))
    else:
        print(form.city.data)
        print(form.errors)
    
    return render_template('new_contact.html', form=form)
Example #5
0
    def data(self):
        with open("Tooling/office_location_data.csv", "r") as Data:
            for line in Data:
                DATASTREAM = line.split(',')
                print(DATASTREAM)
                Location_Data = Locations(
                    first_line=DATASTREAM[0],
                    second_line=DATASTREAM[1],
                    city=DATASTREAM[2],
                    post_code=DATASTREAM[3],
                )
                db.session.add(Location_Data)
                contact = Contact(first_name='John',
                                  last_name='Johnson',
                                  email_address='*****@*****.**',
                                  phone_number='+446251893271',
                                  location_id=1)
                db.session.add(contact)

        db.session.commit()
Example #6
0
 def setUp(self):
     """Setup the test driver and create test users"""
     print(
         "--------------------------NEXT-TEST----------------------------------------------"
     )
     chrome_options = Options()
     chrome_options.binary_location = "/usr/bin/chromium-browser"
     chrome_options.add_argument("--headless")
     self.driver = webdriver.Chrome(executable_path=os.getcwd() +
                                    '/chromedriver',
                                    chrome_options=chrome_options)
     self.driver.get("http://*****:*****@johnson.john',
                            phone_number='+446251893271',
                            location_id=1)
     db.session.commit()
     db.drop_all()
     db.create_all()
     self.data()