53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
"""
|
|
Project: PARTS Website
|
|
Author: Edward Middleton-Smith
|
|
Precision And Research Technology Systems Limited
|
|
|
|
Technology: Backend
|
|
Feature: Contact Us Form
|
|
|
|
Description:
|
|
Defines Flask-WTF form for handling user input on Contact Us page.
|
|
"""
|
|
|
|
# IMPORTS
|
|
# internal
|
|
from business_objects.base import Base
|
|
from business_objects.project_hub.contact_form import Contact_Form
|
|
from forms.project_hub.contact import AltchaField, AltchaValidator
|
|
# from models.model_view_store import Model_View_Store # circular
|
|
from models.model_view_base import Model_View_Base
|
|
from forms.base import Form_Base
|
|
# external
|
|
from flask import Flask, render_template, request, flash, redirect, url_for, current_app
|
|
from flask_wtf import FlaskForm
|
|
from wtforms import StringField, TextAreaField, SubmitField, HiddenField, BooleanField, Field, EmailField
|
|
from wtforms.validators import DataRequired, Email, ValidationError, Optional
|
|
import markupsafe
|
|
from flask_wtf.recaptcha import RecaptchaField
|
|
from abc import ABCMeta, abstractmethod
|
|
import json
|
|
from altcha import verify_solution
|
|
import base64
|
|
|
|
|
|
class Form_Newsletter(FlaskForm):
|
|
email = EmailField(
|
|
'Email'
|
|
, validators = [DataRequired()]
|
|
)
|
|
altcha = AltchaField('Verify you are human')
|
|
submit = SubmitField('Subscribe Now')
|
|
|
|
def to_json(self):
|
|
return {
|
|
Base.FLAG_EMAIL: self.email.data
|
|
, Contact_Form.FLAG_NAME_CONTACT: 'No Contact Name'
|
|
, Contact_Form.FLAG_NAME_COMPANY: 'No Company Name'
|
|
, Contact_Form.FLAG_MESSAGE: 'No Message'
|
|
, Contact_Form.FLAG_RECEIVE_MARKETING_COMMUNICATIONS: True
|
|
, Contact_Form.FLAG_ALTCHA: self.altcha.data
|
|
, Base.FLAG_ACTIVE: True
|
|
, Base.FLAG_CREATED_ON: None
|
|
}
|