From 29e5ffefaf2ae25f8bd435d52b81ef31e45740ab Mon Sep 17 00:00:00 2001 From: Aditya Bharadwaj Date: Mon, 25 Jan 2021 08:06:19 -0800 Subject: [PATCH] Add orchestra api for todo templates and starting order (#736) * get todo templates * add todos from template * Implement api to get starting order * fix lint errors * allow passing additional data * Added tests for error cases * set todo status as declined if skipped * Test status field in todo * fix lint * remove print * fix tests * get todo templates * add todos from template * Implement api to get starting order * fix lint errors * allow passing additional data * Added tests for error cases * set todo status as declined if skipped * Test status field in todo * fix lint * remove print * fix tests * remove starting order api * Version bump. * Added Task Created column (#473) * Added Task Created column * Updated to comments * Added compiled js * Added datetime checking + fixes * Assignment lookup bugfix (#475) * Introduce the paused state to Project (#477) * Add paused status to project * Add project status to the serializer and task assignment * Send readable status to the frontend * Pause/unpause a project * Add a data migration * Add a Paused table to the dashboard * Show the project state toggler on project management * Fix whitespaces * Update tests * Add a test + slack messages * Fix a test * Update the tests * Update copy * Fix the pause button logic on the task page * Add a prefix for projectStatus * Show the pause toggle button instead of the dropdown * Update micro copy * Update copy * Remove an unneccesary chained function * Raise an error for a wrong abort call * Update tasks filter logic * Add a slack notification to announce project status changes * Update tests * Make collapsible table * Fix lint errors * Remove the unused previous_status parameter * Add a project status notification for aborted project and check that slack_group_id exists before sending a message * Expand the toggle to include most of the header row * Add a blank line * Update a test * Automatically archive slack channels of completed/aborted projects (#478) * Add completed status to the Project model * Add the completed project status * Mark project as completed and call a function to archive the project slack channel * Implement the archive function * Archive slack group for aborted projects * Update the migration script * Add completed project conditions * Use slack.channels * Add the channels attribute to OrchestraSlackService * Use the argument of correct type * Change completed_projects implementation * Remove an unused import * Use groups instead of channels * Add the archive function to MockSlack Group * Add a test * Fix a lint error * Update test * Count all_steps query instead of using length * Remove a todo * Notify projects status change when complete a project * Move the logic to set the project status to completed to the end of the function * Update the completed-project logic for a migration * Update project complete logic * Fix lint issues * Update an except * Create unarchive function * Add an unarchive button * Except SlackError * Shorten the functions * Remove an extra condition to show the slack-modal toggler * Exclude aborted tasks when look for incomplete tasks * Add a test for unarchive * Get rid of incomplete_projects * Remove incomplete_projects function * Remove incomplete_projects import * Fix under-indent issues * Fix minor whitespace issues * Version bump. * Added todolist_templates_to_apply with automatic application (#476) * Added todolist_templates with automatic application * Fixed linter errors * Fixed more linter errors * Fixed tests and comments * Fixed linter errors * Fixed linter errors * Fixed based on comments * Fixed tests * Lint fix * Fixed todo test * Fixed load test * Fixed lint * Lint fix * Add message_project_team endpoint (#479) * Add message_project_team api endpoint * Add message_project_team to orchestra_api * Reuse message_experts_slack_group * Version bump. * Add a column on to the list display (#480) * Add a column on to the list display * Make the request str description more useful * Add a tags column to dashboard (#481) * Add the tag column * Add tags to tasks of a worker * Add space between tags * Make the tags visible only to some specified workers * Only show the tag column to qualified users * Fix lint errors * Fix linter errors * Add the json schemas for tags * Remove the tags permission checking * Add the tags field * Add a migration * Use the correct field for sourcing * Fix linter errors * Fix a lint error * Validate the tags before saving * Fix a lint error * Add a test * Fix a lint error * Update a test * Version bump. * Add radio input support to the required field directive (#483) * Add radio input support to the required field directive * Add the radio error class * Version bump. * Add day to the team-info-card's time display (#484) * Version bump. * If assignment status is complete or failed return task (#485) * Version bump. * Extend get_project_information (#486) * Add get_projects_information function * Improve function output * Modify project_information endpoint to make it accept project_ids * Fix error message * Add project_ids to get_project_information signature * Add project_ids test * Handle two parameters passed at once * Accept project_ids only to aviod logic duplication * Fix get_project_information usage cases * Convert string key to int * Fix project_management_info cases * Fix ... property 'currentProject' of undefined * Optimize projects tasks fetching * Version bump. * Use unpacked steps (#487) * Version bump. * Open links in task details in new tabs (#488) * Open links in new tab * Add 'Created at' column to available tasks * Update compiled css * Rename column * Version bump. * Update README.md (#490) * Version bump. * Update README.md (#491) * Update README.md * Update node & yarn; Don't consider subset dependency changes to be topology changes (#492) * Don't consider subset dependency changes to be topology changes * Update yarn * Update node * Fix build * Address code review * Undo code review :) * Version bump. * Version bump. * Load vendor.js before other js files (#493) * Promisify signals.fireSignal (#494) * Adapt signals.fireSignal to handle Promise * Make fireSignal to handle both functions and promises * Rebuild * Consistently call promises * Version bump. * Revert "Load vendor.js before other js files (#493)" (#495) This reverts commit 949a45a8e147b6918c3ad49023c638252fa49fba. * Version bump. * Add raw_id_fields (#496) * Fix bugs and clarify the 5-minute getting started guide (#497) * Fix bugs and clarify the 5-minute getting started guide * Fix colon * Expand on the Google settings documentation (#498) * Expand on the Google settings documentation * Address comments * Use distinct email addresses for each of the sample accounts (#499) * Version bump. * Dashboard tmpl todos (#531) * Filter out the templated todo item from the dashboard * Make the datetime format intuitive * Fix typo in docs (#533) * Reduce Slack API usage (#532) * Update slacker to the latest version * Catch HTTPError except and fail silently if it is a 429 * Send batch unstaffed message grouped by step * Fix a lint error * Reraise exception correctly * Remove change on main.js * Version bump. * Fix the todos dashboard bugs (#535) * Make it possible to log time for pending tasks * Only mark a task as not new if there is non-templated task * Fix lint errors * Fix lint errors * Update compiled js (#536) * Version bump. * adding dependabot config * Adding deps-upgrade script (#576) * Adding deps-upgrade script * new line * fixing typo * fixing typo * addressing PR comments * Revert "Adding deps-upgrade script (#576)" (#579) This reverts commit 9166a1d7a521819dd03d380e6f0f3e7881e6f501. * Upgrading dependencies 2020 01 30 (#580) * [Security] Bump pillow from 4.2.1 to 6.2.0 Bumps [pillow](https://github.com/python-pillow/Pillow) from 4.2.1 to 6.2.0. **This update includes a security fix.** - [Release notes](https://github.com/python-pillow/Pillow/releases) - [Changelog](https://github.com/python-pillow/Pillow/blob/master/CHANGES.rst) - [Commits](https://github.com/python-pillow/Pillow/compare/4.2.1...6.2.0) Signed-off-by: dependabot-preview[bot] * [Security] Bump requests from 2.18.4 to 2.22.0 Bumps [requests](https://github.com/requests/requests) from 2.18.4 to 2.22.0. **This update includes security fixes.** - [Release notes](https://github.com/requests/requests/releases) - [Changelog](https://github.com/kennethreitz/requests/blob/master/HISTORY.md) - [Commits](https://github.com/requests/requests/compare/v2.18.4...v2.22.0) * [Security] Bump markdown2 from 2.3.5 to 2.3.6 Bumps [markdown2](https://github.com/trentm/python-markdown2) from 2.3.5 to 2.3.6. **This update includes security fixes.** - [Release notes](https://github.com/trentm/python-markdown2/releases) - [Changelog](https://github.com/trentm/python-markdown2/blob/master/CHANGES.md) - [Commits](https://github.com/trentm/python-markdown2/compare/2.3.5...2.3.6) * [Security] Bump fstream from 1.0.11 to 1.0.12 Bumps [fstream](https://github.com/npm/fstream) from 1.0.11 to 1.0.12. **This update includes a security fix.** - [Release notes](https://github.com/npm/fstream/releases) - [Commits](https://github.com/npm/fstream/compare/v1.0.11...v1.0.12) Signed-off-by: dependabot-preview[bot] * [Security] Bump lodash from 4.17.4 to 4.17.13 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.4 to 4.17.13. **This update includes security fixes.** - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.4...4.17.13) Signed-off-by: dependabot-preview[bot] * [Security] Bump lodash.mergewith from 4.6.0 to 4.6.2 Bumps [lodash.mergewith](https://github.com/lodash/lodash) from 4.6.0 to 4.6.2. **This update includes security fixes.** - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/commits) Signed-off-by: dependabot-preview[bot] * [Security] Bump lodash.merge from 4.6.0 to 4.6.2 Bumps [lodash.merge](https://github.com/lodash/lodash) from 4.6.0 to 4.6.2. **This update includes security fixes.** - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/commits) Signed-off-by: dependabot-preview[bot] * [Security] Bump tough-cookie from 2.3.2 to 2.3.4 Bumps [tough-cookie](https://github.com/salesforce/tough-cookie) from 2.3.2 to 2.3.4. **This update includes security fixes.** - [Release notes](https://github.com/salesforce/tough-cookie/releases) - [Commits](https://github.com/salesforce/tough-cookie/compare/v2.3.2...v2.3.4) * [Security] Bump stringstream from 0.0.5 to 0.0.6 Bumps [stringstream](https://github.com/mhart/StringStream) from 0.0.5 to 0.0.6. **This update includes security fixes.** - [Release notes](https://github.com/mhart/StringStream/releases) - [Commits](https://github.com/mhart/StringStream/compare/v0.0.5...v0.0.6) * [Security] Bump no-case from 2.3.1 to 2.3.2 Bumps [no-case](https://github.com/blakeembrey/no-case) from 2.3.1 to 2.3.2. **This update includes security fixes.** - [Release notes](https://github.com/blakeembrey/no-case/releases) - [Commits](https://github.com/blakeembrey/no-case/compare/v2.3.1...v2.3.2) * [Security] Bump moment from 2.18.1 to 2.24.0 Bumps [moment](https://github.com/moment/moment) from 2.18.1 to 2.24.0. **This update includes security fixes.** - [Release notes](https://github.com/moment/moment/releases) - [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) - [Commits](https://github.com/moment/moment/compare/2.18.1...2.24.0) * [Security] Bump macaddress from 0.2.8 to 0.2.9 Bumps [macaddress](https://github.com/scravy/node-macaddress) from 0.2.8 to 0.2.9. **This update includes security fixes.** - [Release notes](https://github.com/scravy/node-macaddress/releases) - [Commits](https://github.com/scravy/node-macaddress/compare/0.2.8...0.2.9) * [Security] Bump is-my-json-valid from 2.16.0 to 2.20.0 Bumps [is-my-json-valid](https://github.com/mafintosh/is-my-json-valid) from 2.16.0 to 2.20.0. **This update includes security fixes.** - [Release notes](https://github.com/mafintosh/is-my-json-valid/releases) - [Commits](https://github.com/mafintosh/is-my-json-valid/compare/v2.16.0...v2.20.0) * [Security] Bump extend from 3.0.1 to 3.0.2 Bumps [extend](https://github.com/justmoon/node-extend) from 3.0.1 to 3.0.2. **This update includes security fixes.** - [Release notes](https://github.com/justmoon/node-extend/releases) - [Changelog](https://github.com/justmoon/node-extend/blob/master/CHANGELOG.md) - [Commits](https://github.com/justmoon/node-extend/compare/v3.0.1...v3.0.2) * [Security] Bump debug from 2.6.6 to 2.6.9 Bumps [debug](https://github.com/visionmedia/debug) from 2.6.6 to 2.6.9. **This update includes security fixes.** - [Release notes](https://github.com/visionmedia/debug/releases) - [Changelog](https://github.com/visionmedia/debug/blob/2.6.9/CHANGELOG.md) - [Commits](https://github.com/visionmedia/debug/compare/2.6.6...2.6.9) * bumping pillow version to 7.0.0 Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Version bump. * Adding a staffbot button to task assignment (#594) * Add the staffbot API endpoint * Add dumb Staffbot buttons * Add the staffbot functionality to the button * Handle restaffing * Fix a lint error * Update orchestra/static/orchestra/project-management/assignments-vis.es6.js Co-Authored-By: Adam Marcus * Update orchestra/static/orchestra/project-management/assignments-vis.es6.js Co-Authored-By: Adam Marcus * Rename staffbot_task to staff_task * Set the button label to Restaff if there is a worker assign to the task. * Do not show the button for completed tasks and machine tasks * Raise bad requests on the backend * Handle the error on the frontend * Add a test * Update tests * Increase the coverage a little bit Co-authored-by: Adam Marcus * Version bump. * Update django version to 2.2.9 (#578) * Update django version to 2.2.9 * Replace django.core.urlresolvers with django.urls * Replace --exit with --check * Replace filter_class with filterset_class * Update django-filter and django-nose * Update error handler views to accept exception argument * Update django version in docs-requirements.txt * Update urls usage to work with django2.2 * Add app_name for orchestra * Replace MIDDLEWARE_CLASSES with MIDDLEWARE * Update migrations check * Add set atomic=False * Add renderer argument * Replace name with field_name in filters * Fix tests * Fix linting error * Add --dry-run to migrations check * Update django-bitfield to 2.0.1 * Update ajax-selects version * Version bump. * Move the code around a bit * Revert "Move the code around a bit" This reverts commit ffc4b1a5ad0b4ff6d24ef1f984560845732189a2. * Only allow one active staffbot request per task (#605) * Update the choices * mark staffbot replace as complete based on the responses * Add a model test * Close open requests when sending another staff request * Fix lint errors * Save wip * Change the save order * Add tests for staff and restaff * Fix lint errors * Fix a lint error * Fix tests * Fix tests * Count number of workers instead of inquiries * Remove some debugging convenience * Rename the request status enums * Set the request status to complete when there is a winner * Exclude COMPLETE request when we are marking a winner * Add a test showing that you can not win when the request is completed * Simply check_responses_complete function * Simplify a request complete logic * No need to mark other workers as non-winner * Change the label complete to closed * Update the migration * Move the request status update logic outside of mixin * Remove test for the removed mixin functions * Remove print statements * Remove unneeded won_responses check * Apply suggestions from code review Update comments Co-Authored-By: Adam Marcus * When there is a winner for a task. Make sure all the requests are closed * Leave a comment instead of save * Remove response creation for winner with no existing response Co-authored-by: Adam Marcus * Version bump. * Add function that runs when projects are aborted (#611) * Add abort_completion_function field * Load abort_completion_function * Add _call_abort_completion_function to end_project * Fix _call_abort_completion_function * Add EndProjectTestCase * Fix migrations conflict * Fix typo * Rename function * Do not warn about a missing abort_completion_function * Simplify test * Linting fix * Pass project id * Fix text * Pass object instance, not id * Version bump. * Version bump. * Reactify Frontend for orchestra (#606) Co-authored-by: Adam Marcus Co-authored-by: junusheva Co-authored-by: junusheva <34861122+junusheva@users.noreply.github.com> * Allows re-loading a workflow version with --force if it has new steps. (#621) Allows re-loading a workflow version with --force if it has new steps. Co-authored-by: Daniel Haas * Version bump. * Checks in build artifacts for the React frontend. (#624) * Checks in build artifacts for the React frontend. * Don't run jslint on the new build files. Co-authored-by: Daniel Haas * Version bump. * Fix email template (#552) Co-authored-by: Pavel Bastov * Upgrading dependencies 2020 07 06 (#646) * [Security] Bump django from 2.2.9 to 2.2.13 Bumps [django](https://github.com/django/django) from 2.2.9 to 2.2.13. **This update includes security fixes.** - [Release notes](https://github.com/django/django/releases) - [Commits](https://github.com/django/django/compare/2.2.9...2.2.13) Signed-off-by: dependabot-preview[bot] * Bump node-sass from 4.5.3 to 4.14.1 Bumps [node-sass](https://github.com/sass/node-sass) from 4.5.3 to 4.14.1. - [Release notes](https://github.com/sass/node-sass/releases) - [Changelog](https://github.com/sass/node-sass/blob/master/CHANGELOG.md) - [Commits](https://github.com/sass/node-sass/compare/v4.5.3...v4.14.1) Signed-off-by: dependabot-preview[bot] * Bump pikaday from 1.5.1 to 1.8.0 Bumps [pikaday](https://github.com/Pikaday/Pikaday) from 1.5.1 to 1.8.0. - [Release notes](https://github.com/Pikaday/Pikaday/releases) - [Changelog](https://github.com/Pikaday/Pikaday/blob/master/CHANGELOG.md) - [Commits](https://github.com/Pikaday/Pikaday/compare/1.5.1...1.8.0) Signed-off-by: dependabot-preview[bot] * Bump html-loader from 0.4.5 to 0.5.5 Bumps [html-loader](https://github.com/webpack-contrib/html-loader) from 0.4.5 to 0.5.5. - [Release notes](https://github.com/webpack-contrib/html-loader/releases) - [Changelog](https://github.com/webpack-contrib/html-loader/blob/master/CHANGELOG.md) - [Commits](https://github.com/webpack-contrib/html-loader/compare/v0.4.5...v0.5.5) Signed-off-by: dependabot-preview[bot] * Bump gulp-jsonlint from 1.2.0 to 1.3.2 Bumps [gulp-jsonlint](https://github.com/rogeriopvl/gulp-jsonlint) from 1.2.0 to 1.3.2. - [Release notes](https://github.com/rogeriopvl/gulp-jsonlint/releases) - [Commits](https://github.com/rogeriopvl/gulp-jsonlint/compare/v1.2.0...v1.3.2) Signed-off-by: dependabot-preview[bot] * Bump css-loader from 0.28.4 to 0.28.11 Bumps [css-loader](https://github.com/webpack-contrib/css-loader) from 0.28.4 to 0.28.11. - [Release notes](https://github.com/webpack-contrib/css-loader/releases) - [Changelog](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md) - [Commits](https://github.com/webpack-contrib/css-loader/compare/v0.28.4...v0.28.11) Signed-off-by: dependabot-preview[bot] * Bump gulp-rename from 1.2.2 to 2.0.0 Bumps [gulp-rename](https://github.com/hparra/gulp-rename) from 1.2.2 to 2.0.0. - [Release notes](https://github.com/hparra/gulp-rename/releases) - [Changelog](https://github.com/hparra/gulp-rename/blob/master/CHANGELOG.md) - [Commits](https://github.com/hparra/gulp-rename/commits) Signed-off-by: dependabot-preview[bot] * Bump yargs from 4.8.1 to 15.3.1 Bumps [yargs](https://github.com/yargs/yargs) from 4.8.1 to 15.3.1. - [Release notes](https://github.com/yargs/yargs/releases) - [Changelog](https://github.com/yargs/yargs/blob/master/CHANGELOG.md) - [Commits](https://github.com/yargs/yargs/compare/v4.8.1...v15.3.1) Signed-off-by: dependabot-preview[bot] * Bump babel-plugin-angularjs-annotate from 0.8.0 to 0.10.0 Bumps [babel-plugin-angularjs-annotate](https://github.com/schmod/babel-plugin-angularjs-annotate) from 0.8.0 to 0.10.0. - [Release notes](https://github.com/schmod/babel-plugin-angularjs-annotate/releases) - [Changelog](https://github.com/schmod/babel-plugin-angularjs-annotate/blob/master/CHANGES.md) - [Commits](https://github.com/schmod/babel-plugin-angularjs-annotate/compare/v0.8.0...v0.10.0) Signed-off-by: dependabot-preview[bot] * Bump gulp-print from 2.0.1 to 5.0.2 Bumps [gulp-print](https://github.com/alexgorbatchev/gulp-print) from 2.0.1 to 5.0.2. - [Release notes](https://github.com/alexgorbatchev/gulp-print/releases) - [Commits](https://github.com/alexgorbatchev/gulp-print/compare/v2.0.1...v5.0.2) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Fixing release script (#651) * Version bump. * Add autocomplete fields (#660) * Rename Todo.description to Todo.title (#661) * Rename Todo.description to Todo.title * Cleanup * Fix failing test * Revert json_schema modification * Revert css file * Task unification: add fields to todo (#663) * Make task optional field * Add fields to Todo * Add Status choices * Linting fixes * Set `on_delete=models.SET_NULL` to `task` Co-authored-by: Adam Marcus * Recreate migration Co-authored-by: Adam Marcus * Upgrading dependencies 2020 08 12 (#662) * Bump lodash from 4.17.15 to 4.17.19 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot-preview[bot] * Bump jsonschema from 2.6.0 to 3.2.0 Bumps [jsonschema](https://github.com/Julian/jsonschema) from 2.6.0 to 3.2.0. - [Release notes](https://github.com/Julian/jsonschema/releases) - [Changelog](https://github.com/Julian/jsonschema/blob/master/CHANGELOG.rst) - [Commits](https://github.com/Julian/jsonschema/compare/v2.6.0...v3.2.0) Signed-off-by: dependabot-preview[bot] * Bump flake8 from 3.5.0 to 3.8.3 Bumps [flake8](https://gitlab.com/pycqa/flake8) from 3.5.0 to 3.8.3. - [Release notes](https://gitlab.com/pycqa/flake8/tags) - [Commits](https://gitlab.com/pycqa/flake8/compare/3.5.0...3.8.3) Signed-off-by: dependabot-preview[bot] * Bump django-widget-tweaks from 1.4.1 to 1.4.8 Bumps [django-widget-tweaks](https://github.com/jazzband/django-widget-tweaks) from 1.4.1 to 1.4.8. - [Release notes](https://github.com/jazzband/django-widget-tweaks/releases) - [Changelog](https://github.com/jazzband/django-widget-tweaks/blob/master/CHANGES.rst) - [Commits](https://github.com/jazzband/django-widget-tweaks/compare/1.4.1...1.4.8) Signed-off-by: dependabot-preview[bot] * Bump boto from 2.48.0 to 2.49.0 Bumps [boto](https://github.com/boto/boto) from 2.48.0 to 2.49.0. - [Release notes](https://github.com/boto/boto/releases) - [Commits](https://github.com/boto/boto/compare/2.48.0...2.49.0) Signed-off-by: dependabot-preview[bot] * Bump django-jsonview from 1.1.0 to 2.0.0 Bumps [django-jsonview](https://github.com/jsocol/django-jsonview) from 1.1.0 to 2.0.0. - [Release notes](https://github.com/jsocol/django-jsonview/releases) - [Changelog](https://github.com/jsocol/django-jsonview/blob/main/CHANGELOG) - [Commits](https://github.com/jsocol/django-jsonview/compare/v1.1.0...v2.0.0) Signed-off-by: dependabot-preview[bot] * Bump django-phonenumber-field from 2.0.0 to 4.0.0 Bumps [django-phonenumber-field](https://github.com/stefanfoulis/django-phonenumber-field) from 2.0.0 to 4.0.0. - [Release notes](https://github.com/stefanfoulis/django-phonenumber-field/releases) - [Changelog](https://github.com/stefanfoulis/django-phonenumber-field/blob/master/CHANGELOG.rst) - [Commits](https://github.com/stefanfoulis/django-phonenumber-field/compare/2.0.0...4.0.0) Signed-off-by: dependabot-preview[bot] * Bump django-filter from 2.2.0 to 2.3.0 Bumps [django-filter](https://github.com/carltongibson/django-filter) from 2.2.0 to 2.3.0. - [Release notes](https://github.com/carltongibson/django-filter/releases) - [Changelog](https://github.com/carltongibson/django-filter/blob/master/CHANGES.rst) - [Commits](https://github.com/carltongibson/django-filter/compare/2.2.0...2.3.0) Signed-off-by: dependabot-preview[bot] * Bump sphinx from 1.6.3 to 3.1.2 Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 1.6.3 to 3.1.2. - [Release notes](https://github.com/sphinx-doc/sphinx/releases) - [Changelog](https://github.com/sphinx-doc/sphinx/blob/3.x/CHANGES) - [Commits](https://github.com/sphinx-doc/sphinx/compare/v1.6.3...v3.1.2) Signed-off-by: dependabot-preview[bot] * Bump yargs from 15.4.0 to 15.4.1 Bumps [yargs](https://github.com/yargs/yargs) from 15.4.0 to 15.4.1. - [Release notes](https://github.com/yargs/yargs/releases) - [Changelog](https://github.com/yargs/yargs/blob/master/CHANGELOG.md) - [Commits](https://github.com/yargs/yargs/commits) Signed-off-by: dependabot-preview[bot] * Revert "Bump flake8 from 3.5.0 to 3.8.3" This reverts commit c7c4273235efcb801ccec3de468ffffca5bab6c8. * Bump django-related-admin from 0.5.0 to 1.0.1 Bumps [django-related-admin](https://github.com/PetrDlouhy/django-related-admin) from 0.5.0 to 1.0.1. - [Release notes](https://github.com/PetrDlouhy/django-related-admin/releases) - [Commits](https://github.com/PetrDlouhy/django-related-admin/commits/v1.0.1) Signed-off-by: dependabot-preview[bot] * Syncing django-ajax-selects with version in docker-images repo Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Version bump. * Todo: viewset, serializer (#666) * Add Todos bulk creation serializer, viewset and tests * Add TODO * Add project field * Add step to serializer * Make it possible to get todo by pk * Add filter for retrieving todos * Implementand test update logic * Add partial_update, destroy and bulk_update functionality * Order by creation date * Rename url * Reduce amount of code * Make sure we have all the fields * Remove id validation logic * Simplify get_queryset * Move the viewset to project_api * Require step field on the serializer level * Reqiure step field on the serializer level * Add permission classes * Add create test-case * Add a testcase for permission check * Rename and move tests * Linting fixes * Remove old comment * Add project/ prefix * Fix bulk update * Supply non-existent project_id * Make it more readable * Task unification main branch (#683) * Task unification: reuse serializer (#672) * Add Todos bulk creation serializer, viewset and tests * Add TODO * Add project field * Add step to serializer * Make it possible to get todo by pk * Add filter for retrieving todos * Implementand test update logic * Add partial_update, destroy and bulk_update functionality * Order by creation date * Rename url * Remove id validation logic * Simplify get_queryset * Move the viewset to project_api * Require step field on the serializer level * Reqiure step field on the serializer level * Add permission classes * Add create test-case * Add a testcase for permission check * Rename and move tests * Linting fixes * Remove old comment * Reuse BulkTodoSerializer * Create a serializer based off of BulkTodoSerializer * Replace TodoSerializer with BulkTodoSerializer * Remove unused serializer * Clean up * Replace TodoWithQASerializer with inherited one * Linting fixes * Move some functionality to helpers * Notify about todo updates * Add change summary cases * Remove task * Nitpick * Move notification to helper * Safely compare two dicts * Patch slacker * Make viewset reusable * Patch slacker * Replace TodoDetail with generic * Check if notification func is called * Replace TodoList with TodoViewset * Rename viewset * Fix notifier * Rename tests * Linting fixes * Rename serializers * Add read_only_fields * Remove unused code * Remove notification fields * If changed_fields is empty, show another message * Remove redundant branch * Hide implementation details * Add comments * Fix import * Fix imports * Fix comments * Fix message formatting * Remove non-relevant fields from get_changed_fields * Linting fixes * Copy fixes * Task unification crud api (#681) * Add create_todos func * Text create_todos * Filter by step slug, not by step id * Add get_todos * Fix test name * Fix comments,var name * Add update_todos * Remove duplicative test * Linting fixes * Add bulk delete to the GenericTodoViewset * Add delete_todos * Linting fixes * Remove duplicate todos filtering tests * Rename * Return removed tests * Make project_id required * Remove unused code * Add partial bulk update * Improve test * Turn put into patch * Linting fix * Fix formatting * Improve comment * Make project_id required * Task unification todo task removal (#682) * Add todo.step and todo.project data migration * Remove task from add_todolist_template * Remove task from IsAssociatedWithProject * Fix update_todos_from_todolist_template and tests * Fix auth * Remove task from worker_task_recent_todo_qas * Fix auth * Fix worker_task_recent_todo_qas * Fix auth * Remove unused code * Remove unused code * Fix todos/auth * Remove task from serializer * Fix tests * Remove unused code * Step should be slug * Add delete/destroy view * Remove task, pass step slug as one of args * Add helper * Fix api * Linting fix * Remove console.log * Update compiled js * Fix add_todolist_template usage * Fix tests * Fix tests after rebase * Fix tests * Simplify * Make it possible to get related todos via Task * Linting fixes * Fix tests * Clean-up and add comment * Add comments to migration * Rename reverse lookup name * Remove unused code * Clean tests * Rename module * Fix comment * Clean urls * Filter properly * Remove task__project and task__step from todo admin * Fix js formatting issue * Limit mmethods * Add missing method * Version bump. * Todo list template export/import via Google Sheets (#665) * Squashed and rebased * New migration * Version bump. * Fix permission issue (#686) * Add autocomplete fields (#685) * Reset todo form after submission (#687) * Version bump. * Add a notion of completion_ends_project to Orchestra steps (#684) * add completion_ends_project field * Fix lint errors * Revert autoformatting * Revert autoformatting * Revert autoformatting * Fix lint error * moved end_project variable close to the loop * load completion_ends_project field from version.json * recreated migration * fix autoformating * fix autoformating * fix autoformating * show task assignments with project status completed in completed task list on dashboard * fixed lint errors Co-authored-by: Aditya Bharadwaj * Version bump. * Version bump. * Speed up todo lists loading time on task page (#688) * prefetch step and todoqa data * prevent duplicate http request from frontend * parallelized the api requests * stylistic change: fix assignment order * adding main.js file * adding main.css file * destructured response assignment from parallel promises Co-authored-by: Aditya Bharadwaj * Version bump. * Fix todolists and order steps on the project management page in the order in which they were created (#692) * Trigger angular scope apply when Promise.all resolves * Order the task creation by id Co-authored-by: Aditya Bharadwaj Co-authored-by: paopow * Version bump. * render children items if the parent is expanded (#694) Co-authored-by: Aditya Bharadwaj * Version bump. * Add restaff button to Team info card (#693) * Add restaff button * Add error handling * Resrt timer.css to original version * Add display logic * Rename status to task_status * Add isTaskStaffable helper * Rename status to taskStatus * Team info card: show unassigned (#695) * Hide show unassigned tasks * Simplify orchestra_api interfaces * Implement explicit assignment * Add reassignment logic * Implement reassignment * Fix Staff button * Display input and button in separate lines * Disabled btn after sending request * Show inputs by default * Do not show hide/show unassigned to non-admins * Do not show input if not staffable * Fixes * Add assignments sorting * Sort unassigned tasks * Clean up * Rename * Version bump. * orchestra_api fixes (#699) * Add content type * Serialize additional_data * Migrate Todo JSONField to builtin one * Fix serializer * Make it possible to filter todos * Convert None string into real None * Fix update_todos * Linting fixes * Fix serializer * Fix TodosEndpointTests * Fix validation * Linting fix * Fix serialization in TodoFilterBackend * Rename filter backend * Revert postgres json field * Fix filter queryset * Make things testable * Test QueryParamsFilterBackend * Add a test case to QueryParamsFilterBackendTests * Add tests with dangerous sql * Add comment * Improve QueryParamsFilterBackend * Remove filters.DjangoFilterBackend * Adjust get_todos to the filter's logic * Fix tests * Improve tests * Make comments more informative * Improve url encoding * Improve url params parsing * Fix encoding/decoding * Add id__in * Fix tests * fix auth * Use json encode/decode for passing filters * Fix QueryParamsFilterBackendTests * pop safely * Fix TestTodoApiViewsetTests * Add missing field * Add is_deleted field * JSONify only if filters is not empty * Mutate copy of QueryDict * Test filtering by non-existent id * Improve readablity * Split tests * Fix tests * Linkify urls in todo title (#715) Co-authored-by: Aditya Bharadwaj * Version bump. * use pip version 20.2.4 for circleci (#716) Co-authored-by: Aditya Bharadwaj * Use linky instead of linkify (#724) Co-authored-by: Aditya Bharadwaj * Version bump. * Filter staffing requests from completed projects (#726) * filter staffing requests from completed projects * exclude aborted projects Co-authored-by: Aditya Bharadwaj * Version bump. * Remove unused Kronos dependency (#734) (cherry picked from commit a9d03e6659a0a0633d3c3621730348ba67328217) Co-authored-by: Adam Marcus * Version bump. * get todo templates * add todos from template * Implement api to get starting order * fix lint errors * allow passing additional data * Added tests for error cases * set todo status as declined if skipped * Test status field in todo * fix lint * remove print * fix tests * Pin py-moneyed dependency (#737) * pin py-moneyed dependency * add hourly_rate_currency migration Co-authored-by: Aditya Bharadwaj * Version bump. * fix rebase conflicts * fix rebase conflicts * fix rebase conflicts * remove print * Fix rebase conflicts * return step id with project information api Co-authored-by: Aditya Bharadwaj Co-authored-by: ksiangliulue@gmail.com Co-authored-by: Noah Picard Co-authored-by: Adam Marcus Co-authored-by: paopow Co-authored-by: jumasheff Co-authored-by: katelyngray <40433276+katelyngray@users.noreply.github.com> Co-authored-by: dastanko Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Emir Amanbekov Co-authored-by: Elston Aw Co-authored-by: junusheva Co-authored-by: junusheva <34861122+junusheva@users.noreply.github.com> Co-authored-by: Daniel Haas Co-authored-by: Daniel Haas Co-authored-by: Pavel Bastov Co-authored-by: Pavel Bastov --- orchestra/api_urls.py | 8 + orchestra/orchestra_api.py | 18 ++ orchestra/project_api/api.py | 4 +- orchestra/project_api/views.py | 62 +++++++ orchestra/tests/test_project_api_client.py | 181 +++++++++++++++++++++ orchestra/tests/test_todos.py | 17 +- orchestra/todos/api.py | 25 ++- 7 files changed, 303 insertions(+), 12 deletions(-) diff --git a/orchestra/api_urls.py b/orchestra/api_urls.py index baf00ada5..a605c2d53 100644 --- a/orchestra/api_urls.py +++ b/orchestra/api_urls.py @@ -9,6 +9,8 @@ from orchestra.project_api.views import workflow_types from orchestra.project_api.views import message_project_team from orchestra.project_api.views import TodoApiViewset +from orchestra.project_api.views import TodoTemplatesList +from orchestra.project_api.views import create_todos_from_template from orchestra.views import TimeEntryDetail from orchestra.views import TimeEntryList from orchestra.views import dashboard_tasks @@ -87,6 +89,12 @@ url(r'^project/message_project_team', message_project_team, name='message_project_team'), + url(r'^project/todo_templates/$', + TodoTemplatesList.as_view(), + name='todo_templates'), + url(r'^project/create_todos_from_template/$', + create_todos_from_template, + name='create_todos_from_template'), ] router = routers.SimpleRouter() diff --git a/orchestra/orchestra_api.py b/orchestra/orchestra_api.py index 9c1266c26..f712665ff 100644 --- a/orchestra/orchestra_api.py +++ b/orchestra/orchestra_api.py @@ -151,3 +151,21 @@ def message_project_team(project_id, message): response = _make_api_request('post', 'message_project_team', data=json.dumps(data)) return json.loads(response.text) + + +def get_todo_templates(): + response = _make_api_request('get', 'todo_templates') + return json.loads(response.text) + + +def create_todos_from_template(todolist_template_slug, project_id, + step_slug, additional_data): + data = { + 'todolist_template_slug': todolist_template_slug, + 'project_id': project_id, + 'step_slug': step_slug, + 'additional_data': additional_data, + } + response = _make_api_request('post', 'create_todos_from_template', + data=json.dumps(data)) + return json.loads(response.text) diff --git a/orchestra/project_api/api.py b/orchestra/project_api/api.py index b718599bf..0daf3d6fe 100644 --- a/orchestra/project_api/api.py +++ b/orchestra/project_api/api.py @@ -110,7 +110,9 @@ def _traverse_step_graph(graph, workflow_version): current_step = Step.objects.get( workflow_version=workflow_version, slug=current_node) - steps.append({'slug': current_node, + steps.append({ + 'id': current_step.id, + 'slug': current_node, 'description': current_step.description, 'is_human': current_step.is_human, 'name': current_step.name}) diff --git a/orchestra/project_api/views.py b/orchestra/project_api/views.py index 8f4eaeefc..66cb193ab 100644 --- a/orchestra/project_api/views.py +++ b/orchestra/project_api/views.py @@ -4,12 +4,15 @@ from django.urls import reverse from jsonview.exceptions import BadRequest +from rest_framework import generics from orchestra.core.errors import TaskAssignmentError from orchestra.core.errors import WorkerCertificationError from orchestra.models import Project from orchestra.models import WorkerCertification from orchestra.models import Workflow +from orchestra.models import Todo +from orchestra.models import TodoListTemplate from orchestra.project import create_project_with_tasks from orchestra.project_api.api import get_project_information from orchestra.utils.decorators import api_endpoint @@ -19,6 +22,9 @@ from orchestra.project_api.auth import OrchestraProjectAPIAuthentication from orchestra.project_api.auth import IsSignedUser from orchestra.todos.views import GenericTodoViewset +from orchestra.todos.serializers import TodoListTemplateSerializer +from orchestra.todos.serializers import BulkTodoSerializerWithoutQA +from orchestra.todos.api import add_todolist_template logger = logging.getLogger(__name__) @@ -157,6 +163,54 @@ def message_project_team(request): return {'success': True} +@api_endpoint(methods=['POST'], + permissions=(IsSignedUser,), + logger=logger, + auths=(OrchestraProjectAPIAuthentication,)) +def create_todos_from_template(request): + """ + Endpoint for creating todos in a project. + Payload example: + { + 'todolist_template_slug': 'some-template-slug-123', + 'step_slug': 'some-step-slug-123', + 'project_id': 'some-project-id-123' + 'additional_data': { + 'some_key': 'some_value' + } + } + """ + data = load_encoded_json(request.body) + try: + todolist_template_slug = data.get('todolist_template_slug') + step_slug = data.get('step_slug') + project_id = data.get('project_id') + additional_data = data.get('additional_data') + if step_slug and project_id and todolist_template_slug: + add_todolist_template(todolist_template_slug, project_id, + step_slug, additional_data) + todos = Todo.objects.filter( + template__slug=todolist_template_slug, + project__id=project_id, + step__slug=step_slug).order_by('-created_at') + serializer = BulkTodoSerializerWithoutQA(todos, many=True) + return { + 'success': True, + 'todos': serializer.data + } + else: + text = ('An object with `template_slug`, `step_slug`,' + ' and `project_id` attributes should be supplied') + raise Exception(text) + except Exception as e: + return { + 'success': False, + 'errors': { + 'error': str(e) + } + } + + class TodoApiViewset(GenericTodoViewset): """ This viewset inherits from GenericTodoViewset and used by @@ -164,3 +218,11 @@ class TodoApiViewset(GenericTodoViewset): """ permission_classes = (IsSignedUser,) authentication_classes = (OrchestraProjectAPIAuthentication,) + + +class TodoTemplatesList(generics.ListAPIView): + permission_classes = (IsSignedUser,) + authentication_classes = (OrchestraProjectAPIAuthentication,) + + serializer_class = TodoListTemplateSerializer + queryset = TodoListTemplate.objects.all() diff --git a/orchestra/tests/test_project_api_client.py b/orchestra/tests/test_project_api_client.py index 041ef4f3b..04fc2a016 100644 --- a/orchestra/tests/test_project_api_client.py +++ b/orchestra/tests/test_project_api_client.py @@ -6,17 +6,198 @@ from orchestra.models import Todo from orchestra.tests.helpers.fixtures import TodoFactory +from orchestra.tests.helpers.fixtures import TodoListTemplateFactory from orchestra.tests.helpers.fixtures import StepFactory from orchestra.tests.helpers.fixtures import ProjectFactory from orchestra.tests.helpers.fixtures import WorkflowVersionFactory from orchestra.project_api.auth import SignedUser from orchestra.orchestra_api import create_todos from orchestra.orchestra_api import get_todos +from orchestra.orchestra_api import get_todo_templates +from orchestra.orchestra_api import create_todos_from_template from orchestra.orchestra_api import update_todos from orchestra.orchestra_api import delete_todos from orchestra.orchestra_api import OrchestraError +class TodoTemplatesAPITests(TestCase): + def setUp(self): + super().setUp() + self.request_client = APIClient(enforce_csrf_checks=True) + self.request_client.force_authenticate(user=SignedUser()) + + self.todolist_template_slug = 'test_todolist_template_slug' + self.todolist_template_name = 'test_todolist_template_name' + self.todolist_template_description = \ + 'test_todolist_template_description' + self.workflow_version = WorkflowVersionFactory() + self.step = StepFactory( + slug='step-slug', + workflow_version=self.workflow_version) + self.project = ProjectFactory( + workflow_version=self.workflow_version) + + @patch('orchestra.orchestra_api.requests') + def test_get_todo_templates(self, mock_request): + # This converts `requests.get` into DRF's `APIClient.get` + # To make it testable + def get(url, *args, **kwargs): + return_value = self.request_client.get(url, format='json') + return_value.text = json.dumps(return_value.data) + return return_value + + mock_request.get = get + + template1 = TodoListTemplateFactory() + template2 = TodoListTemplateFactory() + + # Get template1 and template2 + res = get_todo_templates() + self.assertEqual(len(res), 2) + expected_ids = [template1.id, template2.id] + for r in res: + self.assertIn(r['id'], expected_ids) + + # # Get newly created template3 + template3 = TodoListTemplateFactory() + res = get_todo_templates() + self.assertEqual(len(res), 3) + self.assertEqual(res[2]['id'], template3.id) + + @patch('orchestra.orchestra_api.requests') + def test_create_todos_from_template(self, mock_request): + # This converts `requests.post` into DRF's `APIClient.post` + # To make it testable + def post(url, *args, **kwargs): + kw = kwargs.get('data', '') + data = json.loads(kw) + return_value = self.request_client.post(url, data, format='json') + return_value.text = json.dumps(return_value.json()) + return return_value + + todolist_template = TodoListTemplateFactory( + slug=self.todolist_template_slug, + name=self.todolist_template_name, + description=self.todolist_template_description, + todos={'items': [{ + 'id': 1, + 'description': 'todo parent', + 'project': self.project.id, + 'step': self.step.slug, + 'items': [{ + 'id': 2, + 'project': self.project.id, + 'step': self.step.slug, + 'description': 'todo child', + 'items': [] + }] + }]}, + ) + + mock_request.post = post + additional_data = { + 'some_additional_data': 'value' + } + result = create_todos_from_template( + self.todolist_template_slug, + self.project.id, + self.step.slug, + additional_data) + self.assertEqual(result['success'], True) + self.assertEqual(len(result['todos']), 3) + for t in result['todos']: + self.assertEqual(t['template'], todolist_template.id) + self.assertEqual(t['section'], None) + self.assertEqual(t['additional_data'], additional_data) + + @patch('orchestra.orchestra_api.requests') + def test_create_todos_from_template_key_error(self, mock_request): + # This converts `requests.post` into DRF's `APIClient.post` + # To make it testable + def post(url, *args, **kwargs): + kw = kwargs.get('data', '') + data = json.loads(kw) + return_value = self.request_client.post(url, data, format='json') + return_value.text = json.dumps(return_value.json()) + return return_value + + TodoListTemplateFactory( + slug=self.todolist_template_slug, + name=self.todolist_template_name, + description=self.todolist_template_description, + todos={'items': [{ + 'id': 1, + 'description': 'todo parent', + 'project': self.project.id, + 'step': self.step.slug, + 'items': [{ + 'id': 2, + 'project': self.project.id, + 'step': self.step.slug, + 'description': 'todo child', + 'items': [] + }] + }]}, + ) + + mock_request.post = post + additional_data = { + 'some_additional_data': 'value' + } + result = create_todos_from_template( + self.todolist_template_slug, + self.project.id, + None, + additional_data) + err_msg = ('An object with `template_slug`, `step_slug`,' + ' and `project_id` attributes should be supplied') + self.assertEqual(result['success'], False) + self.assertEqual(len(result['errors']), 1) + self.assertEqual(result['errors']['error'], err_msg) + + @patch('orchestra.orchestra_api.requests') + def test_create_todos_from_template_unknown_step_slug(self, mock_request): + # This converts `requests.post` into DRF's `APIClient.post` + # To make it testable + def post(url, *args, **kwargs): + kw = kwargs.get('data', '') + data = json.loads(kw) + return_value = self.request_client.post(url, data, format='json') + return_value.text = json.dumps(return_value.json()) + return return_value + + TodoListTemplateFactory( + slug=self.todolist_template_slug, + name=self.todolist_template_name, + description=self.todolist_template_description, + todos={'items': [{ + 'id': 1, + 'description': 'todo parent', + 'project': self.project.id, + 'step': self.step.slug, + 'items': [{ + 'id': 2, + 'project': self.project.id, + 'step': self.step.slug, + 'description': 'todo child', + 'items': [] + }] + }]}, + ) + + mock_request.post = post + additional_data = { + 'some_additional_data': 'value' + } + result = create_todos_from_template( + self.todolist_template_slug, + self.project.id, + 'unknown-step-slug', + additional_data) + self.assertEqual(result['success'], False) + self.assertEqual(len(result['errors']), 1) + + class TodoAPITests(TestCase): def setUp(self): super().setUp() diff --git a/orchestra/tests/test_todos.py b/orchestra/tests/test_todos.py index c358f2615..dacded6c9 100644 --- a/orchestra/tests/test_todos.py +++ b/orchestra/tests/test_todos.py @@ -42,6 +42,12 @@ def _todo_data(title, completed, due=None, parent_todo=None, template=None, activity_log=str({'actions': []}), qa=None, project=None, step=None, details=None, is_deleted=False): + if skipped_datetime: + status = Todo.Status.DECLINED.value + elif completed: + status = Todo.Status.COMPLETED.value + else: + status = Todo.Status.PENDING.value return { 'completed': completed, 'title': title, @@ -56,7 +62,7 @@ def _todo_data(title, completed, 'order': None, 'project': project, 'section': None, - 'status': None, + 'status': status, 'step': step, 'details': details, 'is_deleted': is_deleted @@ -137,7 +143,8 @@ def _verify_todo_creation(self, success, project, step, mock_notify): resp = self.request_client.post(self.list_create_url, { 'project': project, 'step': step.slug, - 'title': self.todo_title}) + 'title': self.todo_title, + 'status': Todo.Status.PENDING.value}) if success: self.assertEqual(resp.status_code, 201) self.assertEqual(Todo.objects.all().count(), num_todos + 1) @@ -210,7 +217,8 @@ def test_create_todo_with_start_by_datetime(self): project=self.project, step=self.step, start_by_datetime=self.deadline, - title=START_TITLE) + title=START_TITLE, + status=Todo.Status.PENDING.value) self._verify_todos_list(start_by_todo.project.id, [ _todo_data( @@ -230,7 +238,8 @@ def test_create_todo_with_due_datetime(self): project=self.project, step=self.step, due_datetime=self.deadline, - title=DUE_TITLE) + title=DUE_TITLE, + status=Todo.Status.PENDING.value) self._verify_todos_list(due_todo.project.id, [ _todo_data( diff --git a/orchestra/todos/api.py b/orchestra/todos/api.py index 424695dfc..ac8f25d87 100644 --- a/orchestra/todos/api.py +++ b/orchestra/todos/api.py @@ -22,18 +22,22 @@ @transaction.atomic -def add_todolist_template(todolist_template_slug, project_id, step_slug): +def add_todolist_template(todolist_template_slug, project_id, + step_slug, additional_data=None): todolist_template = TodoListTemplate.objects.get( slug=todolist_template_slug) project = Project.objects.get(id=project_id) step = get_step_by_project_id_and_step_slug(project_id, step_slug) template_todos = todolist_template.todos.get('items', []) + additional_data = additional_data if additional_data else {} root_todo = Todo( project=project, step=step, title=todolist_template.name, - template=todolist_template + template=todolist_template, + additional_data=additional_data, + status=Todo.Status.PENDING.value ) root_todo.save() @@ -49,7 +53,7 @@ def add_todolist_template(todolist_template_slug, project_id, step_slug): for template_todo in template_todos: _add_template_todo( template_todo, todolist_template, - root_todo, project, step, cond_props) + root_todo, project, step, cond_props, additional_data) def _to_exclude(props, conditions): @@ -75,26 +79,33 @@ def _to_exclude(props, conditions): def _add_template_todo( template_todo, todolist_template, - parent_todo, project, step, conditional_props): + parent_todo, project, step, conditional_props, + additional_data): remove = _to_exclude(conditional_props, template_todo.get('remove_if', [])) if not remove: if parent_todo.skipped_datetime: skipped_datetime = parent_todo.skipped_datetime else: to_skip = _to_exclude( - conditional_props, template_todo.get('skip_if', [])) + conditional_props, template_todo.get('skip_if', [])) skipped_datetime = timezone.now() if to_skip else None + if skipped_datetime: + status = Todo.Status.DECLINED.value + else: + status = Todo.Status.PENDING.value todo = Todo( project=project, step=step, title=template_todo['description'], template=todolist_template, parent_todo=parent_todo, - skipped_datetime=skipped_datetime + skipped_datetime=skipped_datetime, + status=status, + 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) + project, step, conditional_props, additional_data)