<commit_before>import rapidsms
import datetime

from rapidsms.apps.base import AppBase
from .models import Poll
from django.db.models import Q

class App (AppBase):

    def handle (self, message):
        # see if this contact matches any of our polls
        if (message.connection.contact):
            try:
                poll = Poll.objects.filter(contacts=message.connection.contact).exclude(start_date=None).filter(Q(end_date=None) | (~Q(end_date=None) & Q(end_date__gt=datetime.datetime.now()))).latest('start_date')
                response = poll.process_response(message)    
                message.respond(response)
                return True
            except Poll.DoesNotExist:
                pass

        return False<commit_msg>polls should always through responses to other apps if they want to handle them, because poll content is always fairly free-form<commit_after>import rapidsms
import datetime

from rapidsms.apps.base import AppBase
from .models import Poll
from django.db.models import Q

class App (AppBase):

    def handle (self, message):
        # see if this contact matches any of our polls
        if (message.connection.contact):
            try:
                poll = Poll.objects.filter(contacts=message.connection.contact).exclude(start_date=None).filter(Q(end_date=None) | (~Q(end_date=None) & Q(end_date__gt=datetime.datetime.now()))).latest('start_date')
                response = poll.process_response(message)    
                message.respond(response)
                # play nice, let other things handle responses
                return False
            except Poll.DoesNotExist:
                pass

        return False
{'fraction_non_alphanumeric': 0.08457415128052412, 'fraction_numerical': 0.0, 'mean_word_length': 2.574468085106383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1096547', 'n_tokens_mistral': 451, 'n_tokens_neox': 431, 'n_words': 124}