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
Add orchestra api for todo templates and starting order #736
Conversation
orchestra/project_api/views.py
Outdated
permissions=(IsSignedUser,), | ||
logger=logger, | ||
auths=(OrchestraProjectAPIAuthentication,)) | ||
def todo_sections_starting_order(request): |
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.
@jumasheff is doing the code review, so i'll just focus on this one endpoint to make sure I understand its purpose.
I can't think of an experience in Orchestra or the B12 product that requires this order from Orchestra, as the product currently decides on the fixed section order on its end. Since Orchestra doesn't model sections deeply (maybe it should---right now they are just strings), it seems like the metadata for the section order doesn't have a great home in Orchestra without more data modelling.
Because of the lack of model, the implementation here orders sections by count, which is different from the behavior in the product. I'm open to ideas, but I can imagine two worlds
- Make it so sections are just strings in Orchestra. The caller (e.g., B12 product) can determine their display order.
- Push section metadata like section order into Orchestra's data model for to-do lists, and as a result, add that information to the existing to-do endpoints.
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.
Got rid of the API.
orchestra/tests/test_todos.py
Outdated
@@ -581,6 +587,7 @@ def test_update_todos_from_todolist_template_success(self): | |||
project=self.project.id, | |||
step=self.step.slug), | |||
] | |||
print(expected_todos) |
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.
Remove print
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.
Removed :)
orchestra/project_api/views.py
Outdated
} | ||
|
||
|
||
@api_endpoint(methods=['POST'], |
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.
Why POST
, and not GET
?
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.
Got rid of the API itself.
* Added Task Created column * Updated to comments * Added compiled js * Added datetime checking + fixes
Co-authored-by: Aditya Bharadwaj <aditya@b12.io>
Co-authored-by: Aditya Bharadwaj <aditya@b12.io>
* filter staffing requests from completed projects * exclude aborted projects Co-authored-by: Aditya Bharadwaj <aditya@b12.io>
(cherry picked from commit a9d03e6) Co-authored-by: Adam Marcus <marcua@marcua.net>
* pin py-moneyed dependency * add hourly_rate_currency migration Co-authored-by: Aditya Bharadwaj <aditya@b12.io>
authentication_classes = (OrchestraProjectAPIAuthentication,) | ||
|
||
serializer_class = TodoListTemplateSerializer | ||
queryset = TodoListTemplate.objects.all() |
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.
queryset = TodoListTemplate.objects.filter(is_deleted=False)
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.
I don't think we will need this because we are inheriting from BaseModel which inherits from BaseModelManager.
orchestra/orchestra/models/core/models.py
Line 597 in e2c9930
class TodoListTemplate(TodoListTemplateMixin, BaseModel): |
orchestra/orchestra/utils/models.py
Lines 53 to 64 in e2c9930
class BaseModel(DeleteMixin, models.Model): | |
""" | |
Abstract base class models which defines created_at and is_deleted fields. | |
Attributes: | |
created_at (datetime.datetime): | |
Datetime at which the model is created. | |
is_deleted (boolean): | |
If value is True, mdoel is deleted. Default is False. | |
""" | |
objects = BaseModelManager() | |
unsafe_objects = models.Manager() |
orchestra/orchestra/utils/models.py
Lines 42 to 50 in e2c9930
class BaseModelManager(models.Manager): | |
""" | |
Model manager intended to be used with models with an `is_deleted` field. | |
Overrides the initial QuerySet to filter for objects where `is_deleted` | |
is false. | |
""" | |
def get_queryset(self): | |
return super().get_queryset().filter(is_deleted=False) |
BaseModelManager sets the default query to is_deleted=False
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.
Just to be sure, I confirmed by deleting a todolist template and made sure that we don't need is_deleted=False
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.
Wow! Ignore my suggestion. A!
Added three orchestra API:
project id
,template slug
, andstep slug
success=True
andtodos=List of newly created todos