HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/buyercall_new/buyercall/buyercall/blueprints/partnership/forms.py
from flask_babel import lazy_gettext as _
from flask_wtf import FlaskForm
from flask_wtf.file import FileField
from wtforms import HiddenField, StringField, PasswordField, SelectField, BooleanField
from wtforms.validators import DataRequired, Length, Optional

from buyercall.lib.util_wtforms import ModelForm, choices_from_dict
from buyercall.blueprints.partnership.models import BILLING_TYPE, BUSINESS_TYPE


class PartnershipForm(FlaskForm):
    name = StringField(_('Partnership Name'), [Optional(), Length(1, 128)])
    logo = FileField(_('Logo'), [Optional()])
    default_billing_type = SelectField(
        _('Default Billing'),
        [DataRequired()],
        choices=choices_from_dict(BILLING_TYPE, prepend_blank=False))
    business_type = SelectField(
        _('Business Type'),
        [DataRequired()],
        choices=choices_from_dict(BUSINESS_TYPE, prepend_blank=False))
    invited_emails = HiddenField()
    moved_accounts = HiddenField()


class PartnershipAccountForm(FlaskForm):
    name = StringField(_('Name'), [Optional(), Length(1, 128)])
    partner_account_code = StringField(_('Partner Account Code'), [Optional(), Length(1, 64)])
    billing_type = SelectField(
        _('Billing'),
        [DataRequired()],
        choices=choices_from_dict(BILLING_TYPE, prepend_blank=False))
    business_type = SelectField(
        _('Business Type'),
        [DataRequired()],
        choices=choices_from_dict(BUSINESS_TYPE, prepend_blank=False))
    # partnership_account_group_id = SelectField(_('Account Group'), [Optional()], coerce=int)


class ExternalApiServiceProvider(FlaskForm):
    external_api_service_provider_id = SelectField(_('External Service Provider'), [Optional()], choices=[], coerce=int)
    url = StringField(_('Data URL'), [Optional(), Length(1, 128)])
    token_url = StringField(_('Token URL'), [Optional(), Length(1, 128)])
    client_id = StringField(_('Client ID'), [Optional(), Length(1, 128)])
    username = StringField(_('Username'), [Optional(), Length(1, 128)])
    password = StringField(_('Password'), [Optional(), Length(1, 128)])
    secret = StringField(_('Secret'), [Optional(), Length(1, 128)])
    source = StringField(_('Source'), [Optional(), Length(1, 128)])
    app_source = StringField(_('App Source'), [Optional(), Length(1, 128)])


class PartnershipSignupForm(ModelForm):
    reset_token = HiddenField()
    password = PasswordField(_('Password'), [DataRequired(), Length(8, 128)])

    firstname = StringField(_('First name'), [DataRequired(), Length(1, 128)])
    lastname = StringField(_('Last name'), [DataRequired(), Length(1, 128)])
    # email = HiddenField(validators=[
    #     DataRequired(),
    #     Email()
    # ])
    password = PasswordField(_('Password'), [DataRequired(), Length(8, 128)])
    phonenumber = StringField(_('Phone number'), [DataRequired(), Length(8, 20)])
    tos_agreement = BooleanField(_(''), [DataRequired()])


class PartnershipTwilioApiForm(FlaskForm):
    cpaas_account_id = StringField(_('Twilio Account SID'), [DataRequired(), Length(1, 128)])
    cpaas_api_token = StringField(_('Twilio API Token'), [DataRequired(), Length(1, 128)])
    cpaas_caller_id = StringField(_('Twilio Test Phone Number'), [DataRequired(), Length(1, 12)])


class PartnershipBandwidthApiForm(FlaskForm):
    cpaas_user_id = StringField(_('Bandwidth User ID - API V1'), [DataRequired(), Length(1, 128)])
    cpaas_api_token = StringField(_('Bandwidth API Token - API V1'), [DataRequired(), Length(1, 128)])
    cpaas_api_secret = StringField(_('Bandwidth API Secret - API V1'), [DataRequired(), Length(1, 128)])
    cpaas_account_id = StringField(_('Bandwidth Account ID - API V2'), [DataRequired(), Length(1, 128)])
    cpaas_api_username = StringField(_('Bandwidth API Username - API V2'), [DataRequired(), Length(1, 128)])
    cpaas_api_password = StringField(_('Bandwidth API Password - API V2'), [DataRequired(), Length(1, 128)])
    cpaas_site_id = StringField(_('Bandwidth Site ID - API V2'), [DataRequired(), Length(1, 128)])
    cpaas_location_id = StringField(_('Bandwidth Location/Peer ID - API V2'), [DataRequired(), Length(1, 128)])
    cpaas_sms_application_id = StringField(_('Bandwidth SMS Application ID - API V2'), [DataRequired(), Length(1, 64)])
    cpaas_voice_application_id = StringField(_('Bandwidth Voice Application ID - API V2'), [DataRequired(), Length(1, 64)])
    cpaas_caller_id = StringField(_('Bandwidth Test Phone Number'), [DataRequired(), Length(1, 12)])
    cpaas_cnam_password = StringField(_('Bandwidth CNAM Password - API V2'), [Length(1, 64)])


class PartnerFinservPrequalifyForm(FlaskForm):
    active = BooleanField(_('Integration Enabled'))
    api_username = StringField(_('Finserv Client ID'), [DataRequired(), Length(1, 128)])
    api_password = StringField(_('Finserv Client Secret'), [DataRequired(), Length(1, 128)])
    api_account = StringField(_('Finserv Dealer Code'), [DataRequired(), Length(1, 128)])