diff --git a/packages/calendar/data/answers/en.json b/packages/calendar/data/answers/en.json
index 380473b34..dfe415e27 100644
--- a/packages/calendar/data/answers/en.json
+++ b/packages/calendar/data/answers/en.json
@@ -48,11 +48,12 @@
"Good luck! The following have been added to your \"%list%\" list:
"
],
"todos_uncompleted": [
- "I uncompleted \"%todo%\" from your \"%list%\" list."
+ "I uncompleted the following from your \"%list%\" list:
",
+ "The following have been uncompleted from your \"%list%\" list:
"
],
"todos_completed": [
- "I completed \"%todo%\" from your \"%list%\" list, keep going!",
- "Well done! I completed \"%todo%\" from your \"%list%\" list."
+ "Keep going! I completed the following from your \"%list%\" list:
",
+ "Well done! The following have been completed from your \"%list%\" list:
"
]
}
}
diff --git a/packages/calendar/data/answers/fr.json b/packages/calendar/data/answers/fr.json
index c8b9cbca6..120767df1 100644
--- a/packages/calendar/data/answers/fr.json
+++ b/packages/calendar/data/answers/fr.json
@@ -48,11 +48,12 @@
"Bonne chance ! Ce qui suit vient d'être ajouté à votre liste \"%list%\" :
"
],
"todos_uncompleted": [
- "J'ai décompléter l'élément \"%todo%\" de votre liste \"%list%\"."
+ "J'ai décomplété ceci de votre liste \"%list%\" :
",
+ "Ce qui suit vient d'être décomplété de votre liste \"%list%\" :
"
],
"todos_completed": [
- "J'ai complété l'élément \"%todo%\" de votre liste \"%list%\", continue ainsi !",
- "Bien joué ! J'ai complété l'élément \"%todo%\" de votre liste \"%list%\"."
+ "Continue ainsi ! J'ai complété ceci de votre liste \"%list%\" :
",
+ "Bien joué ! Ce qui suit vient d'être complété de votre liste \"%list%\" :
"
]
}
}
diff --git a/packages/calendar/data/expressions/en.json b/packages/calendar/data/expressions/en.json
index be4da2a44..d789dee62 100644
--- a/packages/calendar/data/expressions/en.json
+++ b/packages/calendar/data/expressions/en.json
@@ -114,6 +114,16 @@
"type": "between",
"from": "add",
"to": "to"
+ },
+ {
+ "type": "between",
+ "from": "add",
+ "to": "and"
+ },
+ {
+ "type": "between",
+ "from": "and",
+ "to": "to"
}
]
},
diff --git a/packages/calendar/todolist.py b/packages/calendar/todolist.py
index 5173e53ae..7740d2347 100644
--- a/packages/calendar/todolist.py
+++ b/packages/calendar/todolist.py
@@ -153,10 +153,6 @@ def add_todos(string, entities):
if not listname:
return utils.output('end', 'list_not_provided', utils.translate('list_not_provided'))
- # Verify the list exists
- if lists.count(List.name == listname) == 0:
- return utils.output('end', 'list_does_not_exist', utils.translate('list_does_not_exist', { 'list': listname }))
-
# Verify todos have been provided
if len(todos) == 0:
return utils.output('end', 'todos_not_provided', utils.translate('todos_not_provided'))
@@ -171,21 +167,79 @@ def add_todos(string, entities):
todos[i] = todo
result += utils.translate('list_todo_element', { 'todo': todo['name'] })
- # Add todos to the to-do list
- lists.update({
- 'todos': todos + existing_todos,
- 'updated_at': int(time())
- }, List.name == listname)
+ # Verify the list exists
+ if lists.count(List.name == listname) == 0:
+ # Create the to-do list
+ lists.insert({
+ 'name': listname,
+ 'todos': todos,
+ 'created_at': timestamp,
+ 'updated_at': timestamp
+ })
+ else:
+ # Add todos to the to-do list
+ lists.update({
+ 'todos': todos + existing_todos,
+ 'updated_at': int(time())
+ }, List.name == listname)
return utils.output('end', 'todos_added', utils.translate('todos_added', {
'list': listname,
'result': result
}))
-def view_todos(string, entities):
- """WIP"""
+def complete_todos(string, entities):
+ """Complete todos"""
- # TODO
+ # List name
+ listname = ''
+
+ # Todos
+ todos = []
+
+ # Find entities
+ for item in entities:
+ if item['entity'] == 'list':
+ listname = item['sourceText'].lower()
+ elif item['entity'] == 'todos':
+ # Split todos into array and trim start/end-whitespaces
+ todos = [chunk.strip() for chunk in item['sourceText'].lower().split(',')]
+
+ # Verify if a list name has been provided
+ if not listname:
+ return utils.output('end', 'list_not_provided', utils.translate('list_not_provided'))
+
+ # Verify the list exists
+ if lists.count(List.name == listname) == 0:
+ return utils.output('end', 'list_does_not_exist', utils.translate('list_does_not_exist', { 'list': listname }))
+
+ # Verify todos have been provided
+ if len(todos) == 0:
+ return utils.output('end', 'todos_not_provided', utils.translate('todos_not_provided'))
+
+ result = ''
+ updated_todos = []
+ db_todos = lists.get(List.name == listname)['todos']
+
+ # # Verify same word in todo. Allow to not give the exact same todo (e.g. 1kg of rice = rice)
+ # if db_todo['name'].find(todo) != -1:
+
+ # result += utils.translate('list_todo_element', { 'todo': db_todo['name'] })
+
+ # Complete todos
+ # lists.update({
+ # 'todos': updated_todos,
+ # 'updated_at': int(time())
+ # }, List.name == listname)
+
+ # return utils.output('end', 'todos_completed', utils.translate('todos_completed', {
+ # 'list': listname,
+ # 'result': result
+ # }))
+
+ # Complete potatoes from my list
+ # TODO: look in all lists first, if several then ask to specify from which list
+ # Complete potatoes from the shopping list
def uncomplete_todos(string, entities):
"""WIP"""
@@ -199,14 +253,8 @@ def uncomplete_todos(string, entities):
'todo': 'todo 1'
}))
-def complete_todos(string, entities):
+def view_todos(string, entities):
"""WIP"""
- # Complete potatoes from my list
- # TODO: look in all lists first, if several then ask to specify from which list
- # Complete potatoes from the shopping list
+ # TODO
- return utils.output('end', 'todo_completed', utils.translate('todo_completed', {
- 'list': 'fake',
- 'todo': 'todo 1'
- }))