Exemple #1
0
    def get_full_tweet(self):
        full_tweet = assemble_full_tweet(self.tweet_text\
                                        , self.tweet_short_url\
                                        , self.tweet_tag_text)
        if len(full_tweet) <= 140:
            return full_tweet

        full_tweet = assemble_full_tweet(self.tweet_text\
                                            , self.tweet_short_url\
                                    )
        if len(full_tweet) <= 140:
            return full_tweet

        if self.tweet_text <= 140:
            return self.tweet_text

        return self.tweet_text[:140]
Exemple #2
0
    def get_full_tweet(self):
        full_tweet = assemble_full_tweet(self.tweet_text\
                                        , self.tweet_short_url\
                                        , self.tweet_tag_text)
        if len(full_tweet) <= 140:
            return full_tweet
            
        full_tweet = assemble_full_tweet(self.tweet_text\
                                            , self.tweet_short_url\
                                    )
        if len(full_tweet) <= 140:
            return full_tweet

        if self.tweet_text <= 140:
            return self.tweet_text
        
        return self.tweet_text[:140]
Exemple #3
0
 def clean(self):
     tweet_text = self.cleaned_data.get('tweet_text', None)
     tweet_short_url = self.cleaned_data.get('tweet_short_url', None)
     tweet_tag_text = self.cleaned_data.get('tweet_tag_text', None)
     
     full_tweet = assemble_full_tweet(tweet_text, tweet_short_url, tweet_tag_text)
     if full_tweet is None:
         err_msg = 'This field is required'
         raise forms.ValidationError("Please enter Tweet Text.")
         
     if len(full_tweet) > 140:
         err_msg = 'Please reduce the length of your message, hashtag or link'
         
         self._errors['tweet_text'] = self.error_class([err_msg])
         self._errors['tweet_short_url'] = self.error_class([err_msg])
         self._errors['tweet_tag_text'] = self.error_class([err_msg])
         
         raise forms.ValidationError("Your full message is more than %s characters (including links and hashtags).  Please reduce it." % MAX_TWEET_SIZE)
         
     return self.cleaned_data
Exemple #4
0
    def clean(self):
        tweet_text = self.cleaned_data.get('tweet_text', None)
        tweet_short_url = self.cleaned_data.get('tweet_short_url', None)
        tweet_tag_text = self.cleaned_data.get('tweet_tag_text', None)

        full_tweet = assemble_full_tweet(tweet_text, tweet_short_url,
                                         tweet_tag_text)
        if full_tweet is None:
            err_msg = 'This field is required'
            raise forms.ValidationError("Please enter Tweet Text.")

        if len(full_tweet) > 140:
            err_msg = 'Please reduce the length of your message, hashtag or link'

            self._errors['tweet_text'] = self.error_class([err_msg])
            self._errors['tweet_short_url'] = self.error_class([err_msg])
            self._errors['tweet_tag_text'] = self.error_class([err_msg])

            raise forms.ValidationError(
                "Your full message is more than %s characters (including links and hashtags).  Please reduce it."
                % MAX_TWEET_SIZE)

        return self.cleaned_data