mirror of
https://github.com/zulip/zulip.git
synced 2025-10-29 19:13:53 +00:00
todo_widget: Allow task list title to be set and edited by author.
Users can now name task lists by providing the task list title in the `/todo` command on the same line. Example: `/todo School Work`. If no title is provided by the user, "Task list" (which is also the placeholder) is used as default. The author of a task list can later edit / update the task list title in the todo widget, just like the question in the poll widget. Fixes part of #20213.
This commit is contained in:
@@ -547,7 +547,7 @@ def validate_poll_data(poll_data: object, is_widget_author: bool) -> None:
|
||||
raise ValidationError(f"Unknown type for poll data: {poll_data['type']}")
|
||||
|
||||
|
||||
def validate_todo_data(todo_data: object) -> None:
|
||||
def validate_todo_data(todo_data: object, is_widget_author: bool) -> None:
|
||||
check_dict([("type", check_string)])("todo data", todo_data)
|
||||
|
||||
assert isinstance(todo_data, dict)
|
||||
@@ -575,6 +575,19 @@ def validate_todo_data(todo_data: object) -> None:
|
||||
checker("todo data", todo_data)
|
||||
return
|
||||
|
||||
if todo_data["type"] == "new_task_list_title":
|
||||
if not is_widget_author:
|
||||
raise ValidationError("You can't edit the task list title unless you are the author.")
|
||||
|
||||
checker = check_dict_only(
|
||||
[
|
||||
("type", check_string),
|
||||
("title", check_string),
|
||||
]
|
||||
)
|
||||
checker("todo data", todo_data)
|
||||
return
|
||||
|
||||
raise ValidationError(f"Unknown type for todo data: {todo_data['type']}")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user