Changeset - 0a597d38bf73
[Not reviewed]
0 1 0
Taavi Burns - 11 years ago 2013-05-17 13:31:55
taavi@taaviburns.ca
Provides a better error message when a sponsor benefit text field is longer than the allowed limit.

It tells you how many words you've written!
1 file changed with 5 insertions and 2 deletions:
0 comments (0 inline, 0 general)
symposion/sponsorship/models.py
Show inline comments
...
 
@@ -194,8 +194,11 @@ class SponsorBenefit(models.Model):
 
        return u"%s - %s" % (self.sponsor, self.benefit)
 
    
 
    def clean(self):
 
        if self.max_words and len(self.text.split()) > self.max_words:
 
            raise ValidationError("Sponsorship level only allows for %s words." % self.max_words)
 
        num_words = len(self.text.split())
 
        if self.max_words and num_words > self.max_words:
 
            raise ValidationError(
 
                "Sponsorship level only allows for %s words, you provided %d." % (
 
                    self.max_words, num_words))
 
    
 
    def data_fields(self):
 
        """
0 comments (0 inline, 0 general)