t-morisawa / responder-todo

0 stars 1 forks source link

チェックボックスの更新の煩わしさを考える #31

Closed t-morisawa closed 4 years ago

t-morisawa commented 4 years ago

スコープ

ユースケース update_all_from_checklist について

やること

アプリをいい感じにする方法を考える

メモ

アクション

t-morisawa commented 4 years ago

フォームでユーザの悪戯を防止する方法

t-morisawa commented 4 years ago

DBへのランダムアクセスのパフォーマンス

t-morisawa commented 4 years ago

input checkboxの扱い方

hiddenパラメータで送るか、JSでいじいじするかの2択っぽい

https://stackoverflow.com/questions/1809494/post-unchecked-html-checkboxes/8972025 https://stackoverflow.com/questions/11424037/do-checkbox-inputs-only-post-data-if-theyre-checked

t-morisawa commented 4 years ago

トランザクション

  @atomic
  async def update_all_from_checklist(self, checklist):
    """
    Todolistのチェック状態を一括更新する
    """
    todolist = await self.repository.get_all()
    new = []

    for index, item in enumerate(todolist.data):
        if index in checklist.data:
            checked = True
        else:
            checked = False
        new.append(Todo(checked, item.task))

    new_todolist = Todolist(new)
    await self.repository.update_all(new_todolist)
t-morisawa commented 4 years ago

どれも結構きついので、一旦見送り。 やるなら、idをhtmlに埋め込んでやっていく感じ。