Skip to content

Commit

Permalink
Revert "Add an option to pass required field for todos created from a…
Browse files Browse the repository at this point in the history
… template (#797)" (#799)

This reverts commit 6b83381.
  • Loading branch information
adbharadwaj committed Jul 29, 2021
1 parent 6b83381 commit bcdbd5d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
3 changes: 1 addition & 2 deletions orchestra/orchestra_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,12 @@ def get_todo_templates():


def create_todos_from_template(todolist_template_slug, project_id,
step_slug, additional_data, required=False):
step_slug, additional_data):
data = {
'todolist_template_slug': todolist_template_slug,
'project_id': project_id,
'step_slug': step_slug,
'additional_data': additional_data,
'required': required
}
response = _make_api_request('post', 'create_todos_from_template',
data=json.dumps(data))
Expand Down
4 changes: 1 addition & 3 deletions orchestra/project_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ def create_todos_from_template(request):
'todolist_template_slug': 'some-template-slug-123',
'step_slug': 'some-step-slug-123',
'project_id': 'some-project-id-123'
'required: False,
'additional_data': {
'some_key': 'some_value'
}
Expand All @@ -187,10 +186,9 @@ def create_todos_from_template(request):
step_slug = data.get('step_slug')
project_id = data.get('project_id')
additional_data = data.get('additional_data')
required = data.get('required', False)
if step_slug and project_id and todolist_template_slug:
add_todolist_template(todolist_template_slug, project_id,
step_slug, additional_data, required)
step_slug, additional_data)
todos = Todo.objects.filter(
template__slug=todolist_template_slug,
project__id=project_id,
Expand Down
15 changes: 5 additions & 10 deletions orchestra/todos/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

@transaction.atomic
def add_todolist_template(todolist_template_slug, project_id,
step_slug, additional_data=None,
required=False):
step_slug, additional_data=None):
todolist_template = TodoListTemplate.objects.get(
slug=todolist_template_slug)

Expand All @@ -37,7 +36,6 @@ def add_todolist_template(todolist_template_slug, project_id,
title=todolist_template.name,
template=todolist_template,
additional_data=additional_data,
required=required,
status=Todo.Status.PENDING.value
)
root_todo.save()
Expand All @@ -54,8 +52,7 @@ def add_todolist_template(todolist_template_slug, project_id,
for template_todo in template_todos:
_add_template_todo(
template_todo, todolist_template,
root_todo, project, step, cond_props, additional_data,
required)
root_todo, project, step, cond_props, additional_data)


def _to_exclude(props, conditions):
Expand All @@ -82,7 +79,7 @@ def _to_exclude(props, conditions):
def _add_template_todo(
template_todo, todolist_template,
parent_todo, project, step, conditional_props,
additional_data, required=False):
additional_data):
remove = _to_exclude(conditional_props, template_todo.get('remove_if', []))
if not remove:
if parent_todo.status == Todo.Status.DECLINED.value:
Expand All @@ -103,12 +100,10 @@ def _add_template_todo(
template=todolist_template,
parent_todo=parent_todo,
status=status,
additional_data=additional_data,
required=required
additional_data=additional_data
)
todo.save()
for template_todo_item in template_todo.get('items', []):
_add_template_todo(
template_todo_item, todolist_template, todo,
project, step, conditional_props, additional_data,
required)
project, step, conditional_props, additional_data)

0 comments on commit bcdbd5d

Please sign in to comment.