mirror of
https://github.com/leon-ai/leon.git
synced 2024-09-20 14:27:40 +03:00
feat(package/calendar): rename a list in the To-Do List module
This commit is contained in:
parent
857be94779
commit
2041be14db
@ -7,6 +7,14 @@
|
||||
"Please provide me a list name.",
|
||||
"Please provide the name of the list you wish to create."
|
||||
],
|
||||
"new_or_old_list_name_not_provided": [
|
||||
"Please make sure you provide the list name to rename and its new list name.",
|
||||
"Please provide the list name to rename and its new list name."
|
||||
],
|
||||
"list_does_not_exists": [
|
||||
"Sorry I can't because the \"%list%\" does not exist.",
|
||||
"I cannot do that because the \"%list%\" does not exist."
|
||||
],
|
||||
"list_already_exists": [
|
||||
"You already have a list named \"%list%\"."
|
||||
],
|
||||
@ -21,9 +29,6 @@
|
||||
],
|
||||
"todo_completed": [
|
||||
"I completed \"%todo%\" from your \"%list%\" list, congrats!"
|
||||
],
|
||||
"todo_archived": [
|
||||
"I archived \"%todo%\" from your \"%list%\" list."
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,14 @@
|
||||
"Merci de me fournir un nom de liste.",
|
||||
"Merci de fournir le nom de la liste que vous souhaitez créer."
|
||||
],
|
||||
"new_or_old_list_name_not_provided": [
|
||||
"Merci de vous assurer d'avoir fourni le nom de la liste à renommer et son nouveau nom.",
|
||||
"Merci de fournir le nom de la liste à renommer ainsi que son nouveau nom."
|
||||
],
|
||||
"list_does_not_exists": [
|
||||
"Désolé je ne peux pas car la liste \"%list%\" n'éxiste pas.",
|
||||
"Je ne peux pas parce que la liste \"%list%\" n'éxiste pas."
|
||||
],
|
||||
"list_already_exists": [
|
||||
"Vous avez déjà une liste nommée \"%list%\"."
|
||||
],
|
||||
@ -21,9 +29,6 @@
|
||||
],
|
||||
"todo_completed": [
|
||||
"J'ai complété la tâche \"%todo%\" de votre liste \"%list%\", bravo !"
|
||||
],
|
||||
"todo_archived": [
|
||||
"J'ai archivé la tâche \"%todo%\" de votre liste \"%list%\"."
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,44 @@
|
||||
"expressions": [
|
||||
"Rename the list to list",
|
||||
"Rename my list to list"
|
||||
],
|
||||
"entities": [
|
||||
{
|
||||
"type": "trim",
|
||||
"name": "old_list",
|
||||
"conditions": [
|
||||
{
|
||||
"type": "between",
|
||||
"from": "the",
|
||||
"to": "list"
|
||||
},
|
||||
{
|
||||
"type": "between",
|
||||
"from": "a",
|
||||
"to": "list"
|
||||
},
|
||||
{
|
||||
"type": "between",
|
||||
"from": "an",
|
||||
"to": "list"
|
||||
},
|
||||
{
|
||||
"type": "between",
|
||||
"from": "my",
|
||||
"to": "list"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "trim",
|
||||
"name": "new_list",
|
||||
"conditions": [
|
||||
{
|
||||
"type": "after",
|
||||
"from": "to"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"delete_list": {
|
||||
|
@ -33,21 +33,59 @@ def create_list(string, entities):
|
||||
if lists.count(List.name == listname) > 0:
|
||||
return utils.output('end', 'list_already_exists', utils.translate('list_already_exists', { 'list': listname }))
|
||||
|
||||
timestamp = int(time())
|
||||
# Create the new to-do list
|
||||
lists.insert({
|
||||
'name': listname,
|
||||
'todos': [],
|
||||
'created_at': int(time())
|
||||
'created_at': timestamp,
|
||||
'updated_at': timestamp
|
||||
})
|
||||
|
||||
return utils.output('end', 'list_created', utils.translate('list_created', { 'list': listname }))
|
||||
|
||||
def view_lists(string, entities):
|
||||
"""View to-do lists"""
|
||||
|
||||
# TODO
|
||||
|
||||
def rename_list(string, entities):
|
||||
"""WIP"""
|
||||
"""Rename a to-do list"""
|
||||
|
||||
# Old list name
|
||||
old_listname = ''
|
||||
|
||||
# New list name
|
||||
new_listname = ''
|
||||
|
||||
# Find entities
|
||||
for item in entities:
|
||||
if item['entity'] == 'old_list':
|
||||
old_listname = item['sourceText']
|
||||
elif item['entity'] == 'new_list':
|
||||
new_listname = item['sourceText']
|
||||
|
||||
# Verify if an old and new list name have been provided
|
||||
if not old_listname or not new_listname:
|
||||
return utils.output('end', 'new_or_old_list_name_not_provided', utils.translate('new_or_old_list_name_not_provided'))
|
||||
|
||||
# Verify if the old list exists
|
||||
if lists.count(List.name == old_listname) == 0:
|
||||
return utils.output('end', 'list_does_not_exists', utils.translate('list_does_not_exists', { 'list': old_listname }))
|
||||
|
||||
# Verify if the new list name already exists
|
||||
if lists.count(List.name == new_listname) > 0:
|
||||
return utils.output('end', 'list_already_exists', utils.translate('list_already_exists', { 'list': new_listname }))
|
||||
|
||||
# Rename the to-do list
|
||||
lists.update({
|
||||
'name': new_listname,
|
||||
'updated_at': int(time())
|
||||
}, List.name == old_listname)
|
||||
|
||||
return utils.output('end', 'list_renamed', utils.translate('list_renamed', {
|
||||
'old_list': 'fake',
|
||||
'new_list': 'new'
|
||||
'old_list': old_listname,
|
||||
'new_list': new_listname
|
||||
}))
|
||||
|
||||
def delete_list(string, entities):
|
||||
@ -63,18 +101,19 @@ def add_todo(string, entities):
|
||||
'todo': 'todo 1'
|
||||
}))
|
||||
|
||||
def view_todos(string, entities):
|
||||
"""WIP"""
|
||||
|
||||
# TODO
|
||||
|
||||
def complete_todo(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
|
||||
|
||||
return utils.output('end', 'todo_completed', utils.translate('todo_completed', {
|
||||
'list': 'fake',
|
||||
'todo': 'todo 1'
|
||||
}))
|
||||
|
||||
def archive_todo(string, entities):
|
||||
"""WIP"""
|
||||
|
||||
return utils.output('end', 'todo_archived', utils.translate('todo_archived', {
|
||||
'list': 'fake',
|
||||
'todo': 'todo 1'
|
||||
}))
|
||||
|
Loading…
Reference in New Issue
Block a user