-
-
Notifications
You must be signed in to change notification settings - Fork 38.2k
Allow use of date_string in service call #13256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,26 @@ | ||
| # Describes the format for available calendar services | ||
|
|
||
| todoist: | ||
| new_task: | ||
| description: Create a new task and add it to a project. | ||
| fields: | ||
| content: | ||
| description: The name of the task (Required). | ||
| example: Pick up the mail | ||
| project: | ||
| description: The name of the project this task should belong to. Defaults to Inbox (Optional). | ||
| example: Errands | ||
| labels: | ||
| description: Any labels that you want to apply to this task, separated by a comma (Optional). | ||
| example: Chores,Deliveries | ||
| priority: | ||
| description: The priority of this task, from 1 (normal) to 4 (urgent) (Optional). | ||
| example: 2 | ||
| due_date: | ||
| description: The day this task is due, in format YYYY-MM-DD (Optional). | ||
| example: "2018-04-01" | ||
| todoist_new_task: | ||
| description: Create a new task and add it to a project. | ||
| fields: | ||
| content: | ||
| description: The name of the task (Required). | ||
| example: Pick up the mail | ||
| project: | ||
| description: The name of the project this task should belong to. Defaults to Inbox (Optional). | ||
| example: Errands | ||
| labels: | ||
| description: Any labels that you want to apply to this task, separated by a comma (Optional). | ||
| example: Chores,Deliveries | ||
| priority: | ||
| description: The priority of this task, from 1 (normal) to 4 (urgent) (Optional). | ||
| example: 2 | ||
| date_string: | ||
| description: The day this task is due, in natural language (Optional). | ||
| example: "tomorrow" | ||
| date_lang: | ||
| description: The langurage of date_string (Optional). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo |
||
| example: "en" | ||
| due_date: | ||
| description: The day this task is due, in format YYYY-MM-DD (Optional). | ||
| example: "2018-04-01" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,10 @@ | |
| DESCRIPTION = 'description' | ||
| # Calendar Platform: Used in the '_get_date()' method | ||
| DATETIME = 'dateTime' | ||
| # Service Call: When is this task due (in natural language)? | ||
| DATE_STRING = 'date_string' | ||
| # Service Call: The language of DATE_STRING | ||
| DATE_LANG = 'date_lang' | ||
| # Attribute: When is this task due? | ||
| # Service Call: When is this task due? | ||
| DUE_DATE = 'due_date' | ||
|
|
@@ -83,7 +87,9 @@ | |
| vol.Optional(PROJECT_NAME, default='inbox'): vol.All(cv.string, vol.Lower), | ||
| vol.Optional(LABELS): cv.ensure_list_csv, | ||
| vol.Optional(PRIORITY): vol.All(vol.Coerce(int), vol.Range(min=1, max=4)), | ||
| vol.Optional(DUE_DATE): cv.string, | ||
| vol.Optional(DATE_STRING): cv.string, | ||
| vol.Optional(DATE_LANG): vol.All(cv.string, vol.Length(min=2, max=2)), | ||
| vol.Optional(DUE_DATE): cv.string | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since specifying both a date string and a due date is not possible (see below), this should probably already be caught in validation? |
||
| }) | ||
|
|
||
| PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ | ||
|
|
@@ -186,7 +192,16 @@ def handle_new_task(call): | |
| if PRIORITY in call.data: | ||
| item.update(priority=call.data[PRIORITY]) | ||
|
|
||
| if DATE_STRING in call.data: | ||
| item.update(date_string=call.data[DATE_STRING]) | ||
|
|
||
| if DATE_LANG in call.data: | ||
| item.update(date_lang=call.data[DATE_LANG]) | ||
|
|
||
| if DUE_DATE in call.data: | ||
| # Make sure only DUE_DATE is set | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should at least issue a warning here, if it's not already caught by service validation (see above). |
||
| item.update(date_string='') | ||
|
|
||
| due_date = dt.parse_datetime(call.data[DUE_DATE]) | ||
| if due_date is None: | ||
| due = dt.parse_date(call.data[DUE_DATE]) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other due date parameter is called
due_date- so one might wonder whether this is another type of date? Perhaps a name likedue_date_stringwould make things clearer?