Esempio n. 1
0
class NewSubscriptionForm(forms.Form):
  email = lkforms.LKEmailField(required=False)
  my_email = lkforms.LKBooleanField(required=False)

  twitter_app_connection_id = lkforms.LKEncryptedIdReferenceField(TwitterAppConnection, required=False)
  app_id = lkforms.LKEncryptedIdReferenceField(AppStoreApp, required=False)

  slack_channel_name = forms.CharField(required=False, max_length=64)

  slack_url = forms.URLField(required=False)

  def clean_slack_url(self):
    slack_url = self.cleaned_data.get('slack_url')
    if slack_url:
      if urlparse.urlparse(slack_url).netloc != 'hooks.slack.com' or '/services/' not in slack_url:
        raise forms.ValidationError('Slack URL should be a hooks.slack.com URL and start with /services/.')
    return slack_url

  def clean(self):
    email = self.cleaned_data.get('email')
    slack_url = self.cleaned_data.get('slack_url')
    my_email = self.cleaned_data.get('my_email', False)
    slack_channel_name = self.cleaned_data.get('slack_channel_name', False)
    twitter_app_connection = self.cleaned_data.get('twitter_app_connection_id')
    app = self.cleaned_data.get('app_id')

    # the form is considered legit if it contains just one of the parameters for creating a review subsciption
    legit = len(filter(lambda x: x, [slack_url, email, my_email, slack_channel_name, twitter_app_connection, app])) == 1

    if not legit:
      raise forms.ValidationError(
          'Please provide `email` or `slack_url` or `my_email` or `slack_channel` or `twitter_app_connection_id` or `app_id`, but just one.')

    return self.cleaned_data
Esempio n. 2
0
class TopUsersForm(forms.Form):
    app_id = lkforms.LKEncryptedIdReferenceField(SDKApp, required=True)
    query = forms.CharField(required=False)
    sort_key = forms.ChoiceField(choices=[
        (k, k) for k in sessions.TOP_USER_SORTABLE_ATTRIBUTES
    ],
                                 required=False)
    start_sdk_user_id = lkforms.LKEncryptedIdReferenceField(SDKUser,
                                                            required=False)
    raw_labels = lkforms.LKBooleanField(required=False)
Esempio n. 3
0
class CreateUpdateShotForm(forms.Form):
  screenshot_image_id = lkforms.LKEncryptedIdReferenceField(Image, required=False)
  def clean_screenshot_image_id(self):
    image = self.cleaned_data.get('screenshot_image_id')
    if image and image.kind != 'screenshot':
      raise forms.ValidationError('Invalid image; not a screenshot.')
    return image

  background_image_id = lkforms.LKEncryptedIdReferenceField(Image, required=False)
  def clean_background_image_id(self):
    image = self.cleaned_data.get('background_image_id')
    if image and image.kind != 'background':
      raise forms.ValidationError('Invalid image; not a background.')
    return image

  label = forms.CharField(min_length=0, max_length=500, required=False)
  label_position = forms.ChoiceField(choices=[
    ('above', 'Cropped Device with Text Above',),
    ('below', 'Cropped Device with Text Below',),
    ('above_full_device', 'Full Device with Text Above',),
    ('below_full_device', 'Full Device with Text Below',),
    ('device', 'Full Device Only',),
    ('above_screenshot', 'Screenshot with Text Above',),
    ('below_screenshot', 'Screenshot with Text Below',),
    ('none', 'Screenshot Only'),
  ], required=False)

  font = forms.CharField(min_length=0, max_length=50, required=False)
  font_size = forms.IntegerField(required=False)
  font_weight = forms.IntegerField(required=False)
  font_color = lkforms.LKColorField(required=False)

  phone_color = forms.ChoiceField(choices=[
    ('white', 'White phone',),
    ('black', 'Black phone',),
    ('gold', 'Gold phone',),
    ('rose', 'Rose Gold phone',),
  ], required=False)
  background_color = lkforms.LKColorField(required=False)

  is_landscape = lkforms.LKBooleanField(required=False)
Esempio n. 4
0
class EditSDKAppForm(SDKProductForm):
    itunes_id = forms.CharField(required=False, max_length=128)
    itunes_country = forms.CharField(required=False, max_length=2)

    def clean_itunes_country(self):
        itunes_id = self.cleaned_data.get('itunes_id')
        itunes_country = self.cleaned_data.get('itunes_country')
        if bool(itunes_country) != bool(itunes_id):
            raise forms.ValidationError(
                'If providing `itunes_country`, please also provide `itunes_id`.'
            )
        return itunes_id

    display_name = forms.CharField(required=False, max_length=128)

    super_freq = forms.ChoiceField(required=False,
                                   choices=SessionFrequency.choices())
    super_time = forms.ChoiceField(required=False,
                                   choices=CumulativeTimeUsed.choices())

    def clean_super_time(self):
        super_freq = self.cleaned_data.get('super_freq')
        super_time = self.cleaned_data.get('super_time')
        if bool(super_freq) != bool(super_time):
            raise forms.ValidationError(
                'Please provide both `super_freq` and `super_time`.')
        return super_time

    config_parent_id = lkforms.LKEncryptedIdReferenceField(SDKApp,
                                                           required=False)

    def clean(self):
        cleaned_data = self.cleaned_data
        if not (cleaned_data.get('display_name')
                or cleaned_data.get('itunes_country')
                or cleaned_data.get('super_freq')
                or cleaned_data.get('config_parent_id') or any(
                    cleaned_data.get(p) is not None
                    for p in SDKProduct.kinds())):
            raise forms.ValidationError(
                'Please provide an app property to edit.')

        return cleaned_data
Esempio n. 5
0
class CreateSDKAppForm(SDKProductForm):
    bundle_id = forms.RegexField(required=False, regex=BUNDLE_RE)
    display_name = forms.CharField(required=False, max_length=128)

    itunes_id = forms.CharField(required=False, max_length=128)
    itunes_country = forms.CharField(required=False, max_length=2)

    def clean_itunes_id(self):
        itunes_id = self.cleaned_data.get('itunes_id')
        bundle_id = self.cleaned_data.get('bundle_id')
        if itunes_id and bundle_id:
            raise forms.ValidationError(
                'Cannot supply `bundle_id` and `itunes_id` together')
        return itunes_id

    config_parent_id = lkforms.LKEncryptedIdReferenceField(SDKApp,
                                                           required=False)

    def clean_config_parent_id(self):
        config_parent = self.cleaned_data.get('config_parent_id')
        if config_parent and config_parent.config_parent_id:
            raise forms.ValidationError(
                'Invalid config parent: cannot nest config parents')
        return config_parent
Esempio n. 6
0
class AppWebsiteForm(lkforms.FieldsListForm):
    app_name = forms.CharField(min_length=0, max_length=256, required=False)
    tagline = forms.CharField(min_length=0, max_length=256, required=False)

    short_description = forms.CharField(min_length=0,
                                        max_length=500,
                                        required=False)
    long_description = forms.CharField(min_length=0,
                                       max_length=4000,
                                       required=False)
    keywords = forms.CharField(min_length=0, max_length=200, required=False)
    google_analytics_id = forms.RegexField(
        required=False, regex=re.compile(r'^UA-\d{6,12}-\d{1,3}$'))

    itunes_id = forms.RegexField(required=False, regex=re.compile(r'^[0-9]+$'))
    play_store_id = forms.RegexField(required=False,
                                     regex=re.compile(r'^[\w-]+(\.[\w-]+)*$'))
    waiting_list_link = forms.URLField(required=False)
    waiting_list_label = forms.CharField(min_length=0,
                                         max_length=100,
                                         required=False)

    itunes_campaign_token = forms.CharField(min_length=0,
                                            max_length=100,
                                            required=False)
    itunes_provider_token = forms.CharField(min_length=0,
                                            max_length=100,
                                            required=False)

    # TODO(keith) - might want better regex for support links...
    support_link = forms.RegexField(
        required=False, regex=re.compile(r'^(mailto:|https?://).+$'))
    blog_link = forms.URLField(required=False)
    login_link = forms.URLField(required=False)
    press_link = forms.URLField(required=False)
    terms_link = forms.URLField(required=False)
    privacy_link = forms.URLField(required=False)
    twitter_link = forms.URLField(required=False)
    facebook_link = forms.URLField(required=False)
    instagram_link = forms.URLField(required=False)
    custom_link = forms.URLField(required=False)
    custom_link_label = forms.CharField(min_length=0,
                                        max_length=100,
                                        required=False)

    disable_lk_branding = forms.BooleanField(required=False)
    mixpanel_badge = forms.BooleanField(required=False)

    domain = lkforms.LKDomainField(required=False)

    def clean_domain(self):
        domain = self.cleaned_data.get('domain')
        if domain and domain.endswith(settings.EMAIL_FROM_DOMAIN):
            raise forms.ValidationError('Invalid domain.')
        return domain

    primary_color = lkforms.LKColorField(required=False)
    font = forms.CharField(min_length=0, max_length=50, required=False)
    custom_css = lkforms.LKCSSField(required=False)

    frame_screenshots = forms.ChoiceField(choices=[
        (
            'no',
            'No',
        ),
        (
            'white',
            'White phone',
        ),
        (
            'black',
            'Black phone',
        ),
    ],
                                          required=False)

    icon_id = lkforms.LKEncryptedIdReferenceField(
        Image, required=False, filter_params={'kind': 'website-icon'})
    logo_id = lkforms.LKEncryptedIdReferenceField(
        Image, required=False, filter_params={'kind': 'website-logo'})
    background_id = lkforms.LKEncryptedIdReferenceField(
        Image, required=False, filter_params={'kind': 'website-background'})

    # "1", "2", "1color", "2color", "3", "4", "5", ...
    template = forms.CharField(min_length=1, max_length=7, required=True)
Esempio n. 7
0
class ReviewsFilter(forms.Form):
  start_review_id = lkforms.LKEncryptedIdReferenceField(AppStoreReview, required=False)
  app_id = lkforms.LKEncryptedIdReferenceField(AppStoreApp, required=False)
  country = forms.ChoiceField(choices=appstore.APPSTORE_COUNTRIES, required=False)
  rating = forms.IntegerField(required=False, min_value=1, max_value=5)
  limit = forms.IntegerField(required=False, min_value=1, max_value=200)
Esempio n. 8
0
class LatestVisitsForm(forms.Form):
    update_time = lkforms.LKDateTimeField(required=False)
    limit = forms.IntegerField(min_value=1, max_value=250, required=False)
    sdk_user_id = lkforms.LKEncryptedIdReferenceField(SDKUser, required=False)