コード例 #1
0
    def clean_price(self):
        price_value = self.cleaned_data.get('price')
        premium_type = self.cleaned_data.get('premium_type')
        if ((premium_type in amo.ADDON_PREMIUMS
                or premium_type == amo.ADDON_FREE_INAPP)
                and not price_value and not self.is_toggling()):
            raise_required()

        if not price_value and self.fields['price'].required is False:
            return None

        # Special case for a free app - in-app payments must be enabled.
        # Note: this isn't enforced for tier zero apps.
        if price_value == 'free':
            if self.cleaned_data.get('allow_inapp') != 'True':
                raise ValidationError(_('If app is Free, '
                                        'in-app payments must be enabled'))
            return price_value

        try:
            price = Price.objects.get(pk=price_value, active=True)
        except (ValueError, Price.DoesNotExist):
            raise ValidationError(_('Not a valid choice'))

        return price
コード例 #2
0
    def clean_price(self):
        if (self.cleaned_data.get('premium_type') in amo.ADDON_PREMIUMS
                and not self.cleaned_data['price']):

            raise_required()

        return self.cleaned_data['price']
コード例 #3
0
ファイル: forms_payments.py プロジェクト: KryDos/zamboni
    def clean_price(self):
        if (self.cleaned_data.get('premium_type') in amo.ADDON_PREMIUMS
            and not self.cleaned_data['price']):

            raise_required()

        return self.cleaned_data['price']
コード例 #4
0
ファイル: forms_payments.py プロジェクト: MaxMillion/zamboni
    def clean_price(self):
        price_value = self.cleaned_data.get('price')
        premium_type = self.cleaned_data.get('premium_type')
        if ((premium_type in amo.ADDON_PREMIUMS
                or premium_type == amo.ADDON_FREE_INAPP)
                and not price_value and not self.is_toggling()):
            raise_required()

        if not price_value and self.fields['price'].required is False:
            return None

        # Special case for a free app - in-app payments must be enabled.
        # Note: this isn't enforced for tier zero apps.
        if price_value == 'free':
            if self.cleaned_data.get('allow_inapp') != 'True':
                raise ValidationError(_('If app is Free, '
                                        'in-app payments must be enabled'))
            return price_value

        try:
            price = Price.objects.get(pk=price_value, active=True)
        except (ValueError, Price.DoesNotExist):
            raise ValidationError(_('Not a valid choice'))

        return price
コード例 #5
0
ファイル: forms.py プロジェクト: bebef1987/zamboni
 def clean_support_email(self):
     # Note: this can't be FREES, because Free + Premium should have
     # a support email.
     if (not self.cleaned_data.get('premium_type') == amo.ADDON_FREE
         and not self.cleaned_data['support_email']):
         raise_required()
     return self.cleaned_data['support_email']
コード例 #6
0
 def clean_comment(self):
     # Comment field needed for duplicate, flag, moreinfo, and other reject
     # reason.
     action = self.cleaned_data.get('action')
     reject_reason = self.cleaned_data.get('reject_reason')
     comment = self.cleaned_data.get('comment')
     if (not comment and
         (action == rvw.ACTION_FLAG or action == rvw.ACTION_MOREINFO or
          (action == rvw.ACTION_REJECT and reject_reason == 0))):
         raise_required()
     return comment
コード例 #7
0
ファイル: forms.py プロジェクト: kmaglione/olympia
 def clean_comment(self):
     # Comment field needed for duplicate, flag, moreinfo, and other reject
     # reason.
     action = self.cleaned_data.get('action')
     reject_reason = self.cleaned_data.get('reject_reason')
     comment = self.cleaned_data.get('comment')
     if (not comment and (action == rvw.ACTION_FLAG or
                          action == rvw.ACTION_MOREINFO or
                          (action == rvw.ACTION_REJECT and
                           reject_reason == 0))):
         raise_required()
     return comment
コード例 #8
0
ファイル: forms_payments.py プロジェクト: wraithan/zamboni
    def clean_price(self):

        price_id = self.cleaned_data['price']
        if (self.cleaned_data.get('premium_type') in amo.ADDON_PREMIUMS
                and not price_id and not self.is_toggling()):
            raise_required()

        if not price_id and self.fields['price'].required is False:
            return None

        try:
            price = Price.objects.get(pk=price_id, active=True)
        except (ValueError, Price.DoesNotExist):
            raise ValidationError(
                self.fields['price'].error_messages['invalid_choice'])

        if (price and price.price == Decimal('0.00')
                and self.cleaned_data.get('allow_inapp') != 'True'):
            raise ValidationError(_('If app is Free, '
                                    'in-app payments must be enabled'))

        return price
コード例 #9
0
ファイル: forms.py プロジェクト: AALEKH/zamboni
 def clean_body(self):
     body = self.cleaned_data.get('body', '')
     # Whitespace is not a review!
     if not body.strip():
         raise_required()
     return body
コード例 #10
0
ファイル: forms_payments.py プロジェクト: bearstech/zamboni
    def clean_price(self):
        if self.cleaned_data.get("premium_type") in amo.ADDON_PREMIUMS and not self.cleaned_data["price"]:

            raise_required()

        return self.cleaned_data["price"]
コード例 #11
0
ファイル: forms.py プロジェクト: atassumer/zamboni
 def clean_max_ver(self):
     if self.cleaned_data['enabled'] and not self.cleaned_data['max_ver']:
         raise_required()
     return self.cleaned_data['max_ver']
コード例 #12
0
ファイル: forms.py プロジェクト: rafrombrc/zamboni
 def clean_free(self):
     if self.cleaned_data["do_upsell"] and not self.cleaned_data["free"]:
         raise_required()
     return self.cleaned_data["free"]
コード例 #13
0
 def clean_max_ver(self):
     if self.cleaned_data['enabled'] and not self.cleaned_data['max_ver']:
         raise_required()
     return self.cleaned_data['max_ver']
コード例 #14
0
ファイル: forms.py プロジェクト: nearlyfreeapps/olympia
 def clean_max_ver(self):
     if self.cleaned_data["enabled"] and not self.cleaned_data["max_ver"]:
         raise_required()
     return self.cleaned_data["max_ver"]
コード例 #15
0
 def clean_free(self):
     if self.cleaned_data['do_upsell'] and not self.cleaned_data['free']:
         raise_required()
     return self.cleaned_data['free']
コード例 #16
0
 def clean_text(self):
     if self.cleaned_data['do_upsell'] and not self.cleaned_data['text']:
         raise_required()
     return self.cleaned_data['text']
コード例 #17
0
ファイル: forms.py プロジェクト: lauraxt/zamboni
 def clean_text(self):
     if (self.cleaned_data['do_upsell']
         and not self.cleaned_data['text']):
         raise_required()
     return self.cleaned_data['text']
コード例 #18
0
ファイル: forms.py プロジェクト: lauraxt/zamboni
 def clean_free(self):
     if (self.cleaned_data['do_upsell']
         and not self.cleaned_data['free']):
         raise_required()
     return self.cleaned_data['free']
コード例 #19
0
ファイル: forms.py プロジェクト: jlongster/zamboni
 def clean_reject_reason(self):
     reject_reason = self.cleaned_data.get("reject_reason", None)
     if self.cleaned_data.get("action") == rvw.ACTION_REJECT and reject_reason is None:
         raise_required()
     return reject_reason
コード例 #20
0
ファイル: forms.py プロジェクト: kmaglione/olympia
 def clean_reject_reason(self):
     reject_reason = self.cleaned_data.get('reject_reason', None)
     if (self.cleaned_data.get('action') == rvw.ACTION_REJECT
             and reject_reason is None):
         raise_required()
     return reject_reason
コード例 #21
0
ファイル: forms.py プロジェクト: rafrombrc/zamboni
 def clean_text(self):
     if self.cleaned_data["do_upsell"] and not self.cleaned_data["text"]:
         raise_required()
     return self.cleaned_data["text"]
コード例 #22
0
ファイル: forms.py プロジェクト: crdoconnor/olympia
 def clean_body(self):
     body = self.cleaned_data.get('body', '')
     # Whitespace is not a review!
     if not body.strip():
         raise_required()
     return body
コード例 #23
0
 def clean_reject_reason(self):
     reject_reason = self.cleaned_data.get('reject_reason', None)
     if (self.cleaned_data.get('action') == rvw.ACTION_REJECT
             and reject_reason is None):
         raise_required()
     return reject_reason