Ejemplo n.º 1
0
 def do_text(self):
     caller_id = models.caller_id_if_valid(self.call_id())
     if models.caller_id_can_vote(caller_id):
         session_info = json.loads(web.data())['session']
         msg = session_info['initialText']
         m = re.match("^(v|V|vote|VOTE)\s+([0-9]{2})$", msg)
         if m:
             vote_code = m.groups()[1]
             candidate = models.find_candidate_by_code(vote_code)
             if candidate:
                 models.record_vote(caller_id, candidate['id'])
                 t = Tropo()
                 t.message(
                         "You have voted for %s as most disruptive startup. Thanks for voting! Tropo <3s you!" % candidate['name'],
                         to=caller_id, channel='TEXT')
                 return t.RenderJson()
             else:
                 return self.do_help_text("Sorry, there's no candidate %s. " % vote_code)
         else:
             return self.do_help_text("Sorry, we didn't understand your text message. ")
     elif not caller_id:
         return self.do_help_text("You need to have caller ID enabled to vote.")
     else:
         t = Tropo()
         t.message("Oops, it looks like you have voted already.", to=caller_id, channel='TEXT')
         return t.RenderJson()
Ejemplo n.º 2
0
 def do_confirm_ok(self, candidate_id):
     caller_id = models.caller_id_if_valid(self.call_id())
     models.record_vote(caller_id, candidate_id)
     t = Tropo()
     t.say("Great, your vote has been counted. Goodbye.")
     t.message("Thanks for voting! Tropo <3 you!", channel="TEXT", to=caller_id)
     return t.RenderJson()
Ejemplo n.º 3
0
    def do_voice(self):
        t = Tropo()
        t.say("Roses are red, violets are blue.")
        t.say("Please vote for the startup that most disrupts you.")

        caller_id = models.caller_id_if_valid(self.call_id())
        if models.caller_id_can_vote(caller_id):
            t.on(event="continue", next="/vote/menu")
        elif not caller_id:
            t.say("Oops, you need to have caller eye dee enabled to vote. Goodbye.")
            t.hangup()
        else:
            t.say("Oops, it looks like you have voted already. Goodbye.")
            t.hangup()

        return t.RenderJson()
Ejemplo n.º 4
0
 def do_help_text(self, msg=""):
     caller_id = models.caller_id_if_valid(self.call_id())
     t = Tropo()
     say = "%sPhone this number back to use the voice interface or visit disrupt.pitchlift.org for help." % msg
     t.message(say, to=caller_id, channel="TEXT")
     return t.RenderJson()