Example #1
0
    def get_todos(cls, chan, user=None, patern="", limit=5):
        request = (Todo.chan == chan)
        if user:
            request = request & (Todo.user == user)
        if patern and patern.strip():
            request = request & (Todo.message.contains(patern))

        return (Todo.select()
                    .where(request)
                    .limit(limit))
Example #2
0
 def get_todo(cls, ident):
     try:
         int(ident)
     except ValueError:
         return None
     try:
         todo = Todo.get(id=ident)
     except Todo.DoesNotExist:
         return None
     return todo
Example #3
0
 def add_todo(cls, chan, value, user):
     Todo.create(chan=chan, user=user, message=value)