Пример #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
    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
    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
 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
 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
    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
 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
    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
 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
 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
 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
 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
 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
 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
 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
 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
 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