File: //home/arjun/projects/buyercall_new/buyercall/buyercall/blueprints/agents/forms.py
import logging
from flask_wtf import FlaskForm
from wtforms import StringField, HiddenField
from wtforms.validators import Length, Optional, DataRequired
from flask_babel import lazy_gettext as _
from wtforms_components import EmailField
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 agent_new and agent_edit
# function for creating and editing agent
class AgentForm(FlaskForm):
firstname = StringField(_('Agent first name'), [DataRequired(), Length(1, 128)])
lastname = StringField(_('Agent last name'), [DataRequired(), Length(1, 128)])
title = StringField(_('Agent title'), [Optional(), Length(1, 128)])
email = EmailField(_('Agent email'),
[DataRequired(), Length(3, 254)])
phonenumber = StringField(_('Agent phone number'),
[DataRequired(), Length(1, 128)])
extension = StringField(_('Extension'), [Optional()])
description = StringField(_('Description'), [Optional(), Length(1, 128)])
mobile = StringField(_('Agent mobile number'), [Optional(), Length(1, 20)])
timezone = HiddenField()
schedules_str = HiddenField()
allhours_str = HiddenField()
groups_str = HiddenField()
# These fields get used through the group_new and group_edit
# function for creating and editing groups
class GroupForm(FlaskForm):
name = StringField(_('Group name'), [DataRequired(), Length(1, 128)])
description = StringField(_('Description'), [Optional(), Length(1, 128)])
group_agents = HiddenField(_('Agents'), [Optional()])