Feat(UI): Blog with article page and Newsletter signup form.
This commit is contained in:
@@ -21,7 +21,7 @@ from forms.base import Form_Base
|
||||
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
|
||||
from wtforms.validators import DataRequired, Email, ValidationError, Optional
|
||||
import markupsafe
|
||||
from flask_wtf.recaptcha import RecaptchaField
|
||||
from abc import ABCMeta, abstractmethod
|
||||
@@ -77,11 +77,26 @@ class AltchaField(Field):
|
||||
|
||||
|
||||
class Form_Contact(FlaskForm):
|
||||
email = EmailField('Email')
|
||||
contact_name = StringField('Name')
|
||||
company_name = StringField('Company')
|
||||
message = TextAreaField('Message')
|
||||
receive_marketing = BooleanField('I would like to receive marketing emails.')
|
||||
email = EmailField(
|
||||
'Email'
|
||||
, validators = [DataRequired()]
|
||||
)
|
||||
contact_name = StringField(
|
||||
'Name'
|
||||
, validators = [DataRequired()]
|
||||
)
|
||||
company_name = StringField(
|
||||
'Company'
|
||||
, validators = [Optional()]
|
||||
)
|
||||
message = TextAreaField(
|
||||
'Message'
|
||||
, validators = [Optional()]
|
||||
)
|
||||
receive_marketing = BooleanField(
|
||||
'I would like to receive marketing emails.'
|
||||
, validators = [DataRequired()]
|
||||
)
|
||||
# recaptcha = RecaptchaField()
|
||||
# altcha = HiddenField('ALTCHA') # , validators=[validate_altcha]
|
||||
altcha = AltchaField('Verify you are human')
|
||||
|
||||
52
forms/project_hub/newsletter.py
Normal file
52
forms/project_hub/newsletter.py
Normal file
@@ -0,0 +1,52 @@
|
||||
"""
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user