class CarouselAdForm(ComponentForm):
    ad_account = AdAccountSelect()
    pageid = PageSelect()
    bid = BidComponent('bid', Campaign.Objective.link_clicks)

    name = forms.CharField(
        initial='Carousel Ads',
        widget=forms.TextInput(attrs={'placeholder': 'Campaign name'}))
    targeting_spec = TargetingSpec()
    site_link = forms.CharField(widget=forms.TextInput(
        attrs={'placeholder': 'Link to your site'}))
    caption = forms.CharField(initial='Caption')
    message = forms.CharField(initial='Message')
    call_to_action_type = CTASelect()
    title = forms.CharField(initial='Title 1')
    title2 = forms.CharField(initial='Title 2')
    title3 = forms.CharField(initial='Title 3')

    body = forms.CharField(initial='Body 1')
    body2 = forms.CharField(initial='Body 2')
    body3 = forms.CharField(initial='Body 3')

    url = forms.URLField(widget=forms.TextInput(
        attrs={'placeholder': 'Item 1 link'}))
    url2 = forms.URLField(widget=forms.TextInput(
        attrs={'placeholder': 'Item 2 link'}))
    url3 = forms.URLField(widget=forms.TextInput(
        attrs={'placeholder': 'Item 3 link'}))

    image = ImageInput()
    image2 = ImageInput(id='id_image2')
    image3 = ImageInput(id='id_image3')
Beispiel #2
0
class AdCreationForm(ComponentForm):

    ad_account = AdAccountSelect()
    page = PageSelect()
    name = forms.CharField(initial='Creative Testing')

    GENDERS_CHOICES = (
        ('0', 'All'),
        ('1', 'Male'),
        ('2', 'Female'),
    )

    bid = BidComponent('bid',
                       Campaign.Objective.link_clicks)

    targeting = TargetingSpec()

    TOMORROW = datetime.date.today() + datetime.timedelta(days=1)

    start_time = DatetimePicker(
        id='id_starttime',
        initial=TOMORROW,
        required=False,
    )
    end_time = DatetimePicker(id='id_endtime', required=False)

    url = forms.URLField(
        widget=forms.TextInput(attrs={'placeholder': 'Link'}))
    title = forms.CharField(initial='Title 1')
    title2 = forms.CharField(initial='Title 2')
    body = forms.CharField(initial='Body 1')
    body2 = forms.CharField(initial='Body 2')
    image = ImageInput()
    image2 = ImageInput(id="id_image2")
    image3 = ImageInput(id="id_image3")
class AppInstallAdForm(ComponentForm):
    """
    We need these parameters for the sample script:
        account_id: AdAccountSelect
        base_name: TextInput
        message: TextInput
        image_path: ImageInput
        daily_budget: DecimalField
        page_id: PageSelect
        app_id: AppSelect
        app_name: AppSelect
        app_store_link: AppSelect
        deferred_app_link: TextInput
        bid_info: BidComponent
        targeting: TargetingSpec
    """
    ad_account = AdAccountSelect()
    name = forms.CharField(
        label='Basename for your ad',
        widget=forms.TextInput(attrs={'placeholder': 'App Install'}),
        help_text='''We will generate campaign name, adset name and ad name
        with basename.''')

    page = PageSelect(help_text='Your ad will be published from this page.')
    app = AppSelect()
    image = ImageInput(allow_empty_file=False, required=True)
    message = forms.CharField(label='Ad Message',
                              initial='Try out this awesome app!')
    app_link = forms.CharField(
        label='Deferred app link to your app',
        min_length=4,
        required=False,
        widget=forms.TextInput(attrs={'placeholder': 'example://detail/1234'}))

    targeting = TargetingSpec(initial=targeting_info_initial)
    PLATFORMS = (
        ('Android', 'Android'),
        ('iOS', 'iOS'),
    )
    platform = forms.ChoiceField(
        widget=forms.RadioSelect,
        choices=PLATFORMS,
        initial='Android',
        help_text='Platform needs to match the platform in targeting above')

    bid_info = BidComponent('bid_info', Campaign.Objective.mobile_app_installs)
    daily_budget = forms.DecimalField(min_value=1, initial=1000)

    def clean(self):
        self.cleaned_data = super(AppInstallAdForm, self).clean()

        self.cleaned_data = \
            super(AppInstallAdForm, self).validate_mobile_platform_targeting()

        return self.cleaned_data
Beispiel #4
0
class TieredLookalikeForm(ComponentForm):

    TOMORROW = datetime.date.today() + datetime.timedelta(days=1)

    ad_account = AdAccountSelect()

    CA_NAME_HELP_TEXT = 'This name will be used to create ' + \
        'the lookalike audiences.'
    CA_HELP_TEXT = 'Choose a existing custom audience id as the seed ' + \
        'for the lookalike audiences.'
    """
        Information for the uploaded custom audience
    """
    lookalike_audience_name = forms.CharField(
        max_length=50,
        help_text=CA_NAME_HELP_TEXT,
    )
    """
        Choose to create based on existing custom audience
    """
    seed_id = CustomAudienceSelect()

    NAME_HELP_TEXT = 'Name for the campaign and ads.'
    """
        Created lookalike campaign information
    """
    name = forms.CharField(
        initial='Tiered lookalikes',
        max_length=50,
        help_text=NAME_HELP_TEXT,
    )
    country = CountrySelect()
    bid_info = BidComponent('bid_info', Campaign.Objective.link_clicks)

    help_text = (
        '5 bid amounts will be generated between min and max bid. This will ' +
        'replace the bid amount you chose in the bid component above.')
    bid_min = forms.IntegerField(initial=100, help_text=help_text)
    bid_max = forms.IntegerField(initial=500, help_text=help_text)

    budget_type = BudgetTypeSelect()
    budget = forms.IntegerField(initial=1000)

    start_time = DatetimePicker(id='id_starttime', initial=TOMORROW)
    end_time = DatetimePicker(id='id_endtime', required=False)

    title = forms.CharField(initial='Ad title')
    body = forms.CharField(initial='Ad body.')
    url = forms.URLField()
    image = ImageInput()
Beispiel #5
0
class ComponentGalleryForm(ComponentForm):

    select_account = AdAccountSelect()
    select_account.JS_FILES = ['actselect.js']

    select_custom_audience = CustomAudienceSelect()
    select_custom_audience.JS_FILES = ['caselect.js']

    select_app = AppSelect()
    select_app.JS_FILES = ['app_select.js', 'app_info.jsx']

    targeting_setting = TargetingSpec()
    targeting_setting.JS_FILES = [
        'targeting_spec.js', 'targeting_composer.jsx'
    ]

    bid_setting = BidComponent('bid_setting')
    bid_setting.JS_FILES = ['bid_component.js', 'bid_composer.jsx']

    select_page = PageSelect()
    select_page.JS_FILES = ['page_select.js']

    select_lead_gen_form = LeadFormCreate()
    select_lead_gen_form.JS_FILES = ['lead_form.js', 'lead_form_select.jsx']

    select_business_manager = BusinessManagerSelect()
    select_business_manager.JS_FILES = ['business_select.js']

    select_product_catalog = ProductCatalogSelect()
    select_product_catalog.JS_FILES = ['product_catalog_select.js']

    select_product = ProductSelect()
    select_product.JS_FILES = ['product_select.js']

    def __init__(self):
        super(ComponentGalleryForm, self).__init__()

        for key, field in self.fields.items():
            field.desc = markdown.markdown(textwrap.dedent(field.__doc__))
            field.name = field.__class__.__name__
            js_modules = []
            if hasattr(field, 'JS_FILES'):
                for js_file in field.JS_FILES:
                    js_module_content = get_file_content(
                        './js_src/{0}'.format(js_file))
                    js_modules.append({
                        'name': js_file,
                        'content': js_module_content
                    })
            field.js_modules = js_modules
Beispiel #6
0
class LeadAdForm(ComponentForm):

    ad_account = AdAccountSelect()
    page = PageSelect()
    lead_form = LeadFormCreate()
    name = forms.CharField(initial='My First Lead Ad')
    targeting = TargetingSpec(initial=targeting_info_initial)
    bid_info = BidComponent('bid_info', Campaign.Objective.lead_generation)
    daily_budget = forms.DecimalField(
        min_value=1,
        initial='500',
    )
    image = ImageInput(
        allow_empty_file=False,
        required=True,
    )
    message = forms.CharField(initial='My First Lead Ad')
    link = forms.CharField()
    caption = forms.CharField()
    description = forms.CharField()
Beispiel #7
0
class AppEngagementForm(ComponentForm):

    IMAGE_MIN_WIDTH = 1200
    IMAGE_MIN_HEIGHT = 627

    ad_account = AdAccountSelect()
    name = forms.CharField(
        label='Basename for your ads',
        max_length=50, required=True,
        widget=forms.TextInput(attrs={'placeholder': 'My App Engagement'}),
        help_text='''We will generate campaign name, adset name and ad name
        with basename.'''
    )
    page = PageSelect()
    image = ImageInput(
        allow_empty_file=False, required=True,
        help_text='PNG or JPG file with width=1200px, height=627px'
    )
    message = forms.CharField(
        label='Ad Message',
        max_length=90, required=True,
        initial='Try out this feature in our app!'
    )

    app = AppSelect()
    deep_link = forms.CharField(
        label='Deep link to your app action', min_length=4, required=True,
        widget=forms.TextInput(attrs={'placeholder': 'example://detail/1234'})
    )
    pixel = forms.CharField(
        label='Facebook offsite pixel id of your app',
        min_length=1, required=True,
        initial='null',
        help_text='Fill `null` to skip.'
    )

    targeting = TargetingSpec(initial=targeting_info_initial)
    PLATFORMS = (
        ('Android', 'Android'),
        ('iOS', 'iOS'),
    )
    platform = forms.ChoiceField(
        widget=forms.RadioSelect,
        choices=PLATFORMS,
        help_text='Platform needs to match the platform in targeting above'
    )

    bid_info = BidComponent('bid_info', 'MOBILE_APP_ENGAGEMENT')
    daily_budget = forms.DecimalField(
        min_value=1,
        required=True,
        initial='500',
        help_text='to bid $5.00, set 500'
    )

    def clean_image(self):
        image = self.cleaned_data.get('image')
        if not image:
            raise forms.ValidationError('Not an image!')
        else:
            w, h = get_image_dimensions(image)
            if w < AppEngagementForm.IMAGE_MIN_WIDTH:
                raise forms.ValidationError(
                    "The image is %i pixel wide. It's supposed to be >= %i." %
                    (w, AppEngagementForm.IMAGE_MIN_WIDTH)
                )
            if h < AppEngagementForm.IMAGE_MIN_HEIGHT:
                raise forms.ValidationError(
                    "The image is %i pixel high. It's supposed to be >= %i." %
                    (h, AppEngagementForm.IMAGE_MIN_HEIGHT)
                )
        return image

    def clean(self):
        self.cleaned_data = super(AppEngagementForm, self).clean()

        self.cleaned_data = \
            super(AppEngagementForm, self).validate_mobile_platform_targeting()

        return self.cleaned_data
class CarouselAppAdForm(ComponentForm):

    ad_account = AdAccountSelect()
    name = forms.CharField(
        label='Basename for your ads',
        max_length=50,
        required=True,
        widget=forms.TextInput(
            attrs={'placeholder': 'Carousel App Install Ad'}),
        help_text='''We will generate campaign name, adset name and ad name
        with basename.''')
    message = forms.CharField(label='Ad Message',
                              max_length=90,
                              required=True,
                              initial='Try out this new app!')
    daily_budget = forms.DecimalField(min_value=1, required=True, initial=1000)
    bid_info = BidComponent('bid_info', Campaign.Objective.mobile_app_installs)
    targeting = TargetingSpec(
        initial=targeting_info_initial,
        help_text='You need to choose mobile platform and a placement type' +
        ' that has mobile, and the platform should match with below')

    PLATFORMS = (
        ('Android', 'Android'),
        ('iOS', 'iOS'),
    )
    platform = forms.ChoiceField(
        widget=forms.RadioSelect,
        choices=PLATFORMS,
        initial='Android',
        help_text='Platform needs to match the platform in targeting above')

    appinfo_fbpage_id = PageSelect(
        help_text='The page from which the ad is posted')

    app = AppSelect(help_text='Select your application in the pop up')

    # The carousel contains 3 images
    image_1 = ImageInput(
        label='Image 1',
        allow_empty_file=False,
        required=True,
        help_text='PNG or JPG file with width=1200px, height=627px')
    link_title_1 = forms.CharField(
        help_text='Title message for image 1',
        widget=forms.TextInput(attrs={'placeholder': 'My App Name'}))
    deep_link_1 = forms.CharField(
        help_text='Deep link for image 1',
        required=False,
        widget=forms.TextInput(attrs={'placeholder': 'example://product/123'}))
    image_2 = ImageInput(
        id='id_image_2',
        label='Image 2',
        allow_empty_file=False,
        required=True,
        help_text='PNG or JPG file with width=1200px, height=627px')
    link_title_2 = forms.CharField(
        help_text='Title message for image 2',
        widget=forms.TextInput(attrs={'placeholder': 'My App Name'}))
    deep_link_2 = forms.CharField(
        help_text='Deep link for image 2',
        required=False,
        widget=forms.TextInput(attrs={'placeholder': 'example://product/123'}))
    image_3 = ImageInput(
        id='id_image_3',
        label='Image 3',
        allow_empty_file=False,
        required=True,
        help_text='PNG or JPG file with width=1200px, height=627px')
    link_title_3 = forms.CharField(
        help_text='Title message for image 3',
        widget=forms.TextInput(attrs={'placeholder': 'My App Name'}))
    deep_link_3 = forms.CharField(
        help_text='Deep link for image 3',
        required=False,
        widget=forms.TextInput(attrs={'placeholder': 'example://product/123'}))

    def clean(self):
        self.cleaned_data = super(CarouselAppAdForm, self).clean()

        self.cleaned_data = \
            super(CarouselAppAdForm, self).validate_mobile_platform_targeting()

        return self.cleaned_data