File: //home/arjun/projects/buyercall_forms/buyercall/buyercall/blueprints/contacts/forms.py
import logging
from flask_wtf import FlaskForm
from collections import OrderedDict
from wtforms import StringField, TextAreaField, SelectField, HiddenField, BooleanField, IntegerField, DecimalField
from wtforms.validators import Length, Optional, DataRequired, NumberRange
from flask_babel import lazy_gettext as _
from buyercall.blueprints.contacts.models import Contact
from buyercall.lib.util_wtforms import choices_from_dict
try:
from instance import settings
LANGUAGES = settings.LANGUAGES
except ImportError:
logging.error('Ensure __init__.py and settings.py both exist in instance/')
exit(1)
except AttributeError:
from config import settings
LANGUAGES = settings.LANGUAGES
class SearchForm(FlaskForm):
q = StringField(_('Search terms'), [Optional(), Length(1, 128)])
# This field gets used through the lead_edit function to allow notes for contacts
class ContactForm(FlaskForm):
firstname = StringField(_('First Name'), validators=[Optional()])
lastname = StringField(_('Last Name'), validators=[Optional()])
email = StringField(_('Email'), validators=[Optional()])
status = SelectField(_('Status'), validators=[Optional()])
bdc_status = SelectField(_('BDC Status'), validators=[Optional()])
marketing_source = SelectField(_('Marketing Source'), validators=[Optional()])
campaign_id = HiddenField()
agent_assigned = SelectField(_('Agent Assigned'), validators=[Optional()])
address_1 = StringField(_('Address 1'), validators=[Optional()])
address_2 = StringField(_('Address 2'), validators=[Optional()])
city = StringField(_('City'), validators=[Optional()])
state = StringField(_('State'), validators=[Optional()])
zip = StringField(_('Zip'), validators=[Optional()])
birthday = StringField(_('Birthday'), validators=[Optional()])
country = StringField(_('Country'), validators=[Optional()])
is_do_not_call = BooleanField('Do not call')
is_unsubscribe = BooleanField('SMS Unsubscribed')
notes = TextAreaField(_('Add some notes here'), [Optional(), Length(1, 8192)])
edited_notes_str = HiddenField()
class ContactVehicleForm(FlaskForm):
current_vin = StringField(_('Current Vehicle VIN'), validators=[Optional(), Length(min=17,max=17)])
current_make = StringField(_('Current Vehicle Make'), validators=[Optional()])
current_model = StringField(_('Current Vehicle Model'), validators=[Optional()])
current_year = IntegerField(_('Current Vehicle Year'), validators=[Optional(),
NumberRange(min=1900, max=2100)])
current_value = DecimalField(_('Current Vehicle Value'), validators=[Optional()])
current_mileage = IntegerField(_('Current Vehicle Mileage'), validators=[Optional()])
current_condition = SelectField(_('Current Vehicle Condition'), validators=[Optional()])
interest_vin = StringField(_('Vehicle of Interest VIN'), validators=[Optional(),
Length(min=17, max=17)])
interest_make = StringField(_('Vehicle of Interest Make'), validators=[Optional()])
interest_model = StringField(_('Vehicle of Interest Model'), validators=[Optional()])
interest_year = IntegerField(_('Vehicle of Interest Year'), validators=[Optional(),
NumberRange(min=1900, max=2100)])
interest_trim = StringField(_('Vehicle of Interest Trim'), validators=[Optional()])
interest_stock = StringField(_('Vehicle of Interest Stock'), validators=[Optional()])
interest_price = DecimalField(_('Vehicle of Interest Price'), validators=[Optional()])
interest_status = SelectField(_('Vehicle of Interest Status'), validators=[Optional()])
interest_mileage = IntegerField(_('Vehicle of Interest Mileage'), validators=[Optional()])
interest_condition = SelectField(_('Vehicle of Interest Condition'), validators=[Optional()])
interest_listing_url = StringField(_('Vehicle of Interest Listing URL'), validators=[Optional()])
def __init__(self, *args, **kwargs):
kwargs['csrf_enabled'] = False
super(ContactForm, self).__init__(*args, **kwargs)
# This field gets used through the lead_edit function to allow notes for leads
class ContactNoteForm(FlaskForm):
notes = TextAreaField(_('Add some notes here'), [Optional(), Length(1, 8192)])
edited_notes_str = HiddenField()