Skip to content
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

Tp2000 1471 task workflow #1298

Draft
wants to merge 47 commits into
base: master
Choose a base branch
from
Draft

Conversation

paulpepper-trade
Copy link
Collaborator

@paulpepper-trade paulpepper-trade commented Sep 20, 2024

TP2000-1471 Task workflows

Why

Discovery and business analysis work has uncovered a core, and probably reasonably stable, set of behaviours around TAP task and workflow integration. Implementing a kernel of that behaviour in software as a type of minimum viable product has advantages including:

  • Providing early feature validation and feedback to minimise waste and help identify / uncover value.
  • Help TAP users think critically about their existing processes.
  • Encourage TAP users to consider proposed workflow integrations and enhancements.
  • Validate technical approaches.
  • Lay down a foundational layer of software on which to build more advanced workflow management and notification features.

What

This PR implements:

  • Task-related models that capture project management-type info
  • Workflow-related models that allow tasks to be grouped and sequenced
  • Workflow templating to allow users to capture details of common workflows for repeated creation and use
  • A persistent Queue Django model, used by workflows and workflow templates for task sequencing
  • Django admin support
  • For each of the key entities of workflows, tasks and subtasks and their template equivalents, view support is added including:
  • List views with filtering and sorting
  • Create new views
  • Details views
  • Edit views
  • Delete views

image

TO DO

  • Squash migrations, ensuring custom migraitons are correctly retained.

Checklist

  • Requires migrations? Yes
  • Requires dependency updates? No

paulpepper-trade and others added 20 commits August 29, 2024 18:16
* Rename UserAssignment model to TaskAssignee

* Add TaskCategory and TaskProgressState models

* Add parent_task field to Task model

* Add creator field to Task model

* Add TaskLog model

* Don't require that tasks have a workbasket

* Make progress_state a required field on Task model

* Order task category by name and display progress state by value

* Remove Task prefix from Category and ProgressState models

* Remove workflow app
* Register Category model in admin site

* Register ProgressState in admin site

* Register TaskAssignee in admin site

* Register Task model in admin site
* Add initial TaskCreate view & form

* Add initial Task detail view

* Add initial Task edit form & view

* Add initial Task delete view & form

* Add initial Task list view

* Try pre_save signals for TaskLog creation

* Tidy templates

* Allow Task deletion

* Register TaskLog model in admin

* Add test for TaskLog creation

* Rename user group in conftest

* Set up pre_save signal for TaskAssignee to create TaskLog entries

* Persist TaskLog entries after Task deletion

* Add mixins to override Manager and QuerySet methods for pre_save signal handling

* Fix Task delete view

* Move WithSignalManagerMixin and WithSignalQuerysetMixin to common/models/mixins

* Set initial pagination limit for TaskListView
* create 'subtask create form' with predetermined parent

* add test to check that SubtaskCreateForm.save adds correct parent task when creating subtask
… and workflow task items (#1321)

* Split models file and add stubbed queue support.

* Removed queue from base class; Create TaskItem using TaskItemTemplate position

* Amend TaskItem.position exception error message

* Override QueueItem metaclass to enforce queue field on conrete subclasses

* Export queue-related models from tasks

* Implement Queue instance methods using new get_related_objects util method

* Implement QueueItem instance methods

* Add Queue.get_items() and add return type annotations

* Add concrete test-only models for Queue and QueueItem

* Add queue tests

* Add queue and item tests

* Refactor TableLock into a decorator and context manager

* Override QueueItem's model manager create method to set queue positions on behalf of subclasses

* Amend Queue and QueueItem tests

* Docstring updates.

* Support only a single reverse FK relationship to QueueItem for queue instances

* Support default State instance on ProgressState and Task.progress_state

* Remove redundant model manager. Add task and task template util methods.

* Add workflow unit tests.

* Rely on Task.progress_state default in WB assign users view

---------

Co-authored-by: Dale Cannon <[email protected]>
* Implement prototype TaskWorkflowTemplate detail view

* Rename workflow template jinja template

* Add TaskWorkflowTemplateDetailView test
…ate detail view (#1323)

* Add task template reordering capability to workflow template detail view

* Catch race condition exception

* Add workflow template reorder items view test

* Ensure item being moved belongs to workflow template

* Add task queue template resembling packaging queue design

* Order get_task_templates() and get_tasks() querysets by item position

* Add promote_to_first/last form action handling
* Fix misaligned actions. Add links.

* Add __str__() method

* Task template creation UI support

* Add missing trailing slash

* Add tasktemplate perms to conftest

* Move factories and fixtures to their own modules

* Fixture for single item workflow template

* Unit tests for create and detail views for task templates

* Correct fixture name

* Add link to task template detail view
* Fix misaligned actions. Add links.

* Add __str__() method

* Task template creation UI support

* Add missing trailing slash

* Add tasktemplate perms to conftest

* Move factories and fixtures to their own modules

* Fixture for single item workflow template

* Unit tests for create and detail views for task templates

* Correct fixture name

* Add link to task template detail view

* Add get_url() method support

* Implement forms and views for task template udpate

* Add unit test for update view
* shared success template for tasks and subtasks

* modified subtask confirmcreate success url to include ID of newly created subtask

* added 'create subtask' button to task details page

* conditional rendering of 'create subtask' button only for tasks without parent

* Remove redirect from get context function, and fix task details button test

* Add validation to prevent subtasks being created from subtasks

* Add parent name to subtask title

* Add test to check for form error

---------

Co-authored-by: marya <[email protected]>
* Don't show actions for a single item in queue list

* Filter queue items by their own queue when reordering

* Support task workflow template creation

* Support workflow template editing
@codecov-commenter
Copy link

codecov-commenter commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 92.56149% with 124 lines in your changes missing coverage. Please review.

Project coverage is 93.42%. Comparing base (a661050) to head (4540d83).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
tasks/views.py 81.07% 71 Missing and 3 partials ⚠️
tasks/admin.py 69.23% 16 Missing ⚠️
tasks/forms.py 94.28% 5 Missing and 1 partial ⚠️
tasks/models/logs.py 86.48% 2 Missing and 3 partials ⚠️
tasks/models/task.py 95.28% 4 Missing and 1 partial ⚠️
common/util.py 83.33% 2 Missing and 2 partials ⚠️
tasks/models/queue.py 96.00% 2 Missing and 2 partials ⚠️
tasks/tests/conftest.py 94.44% 3 Missing ⚠️
tasks/tests/test_queue_models.py 96.51% 3 Missing ⚠️
tasks/models/workflow.py 97.14% 1 Missing and 1 partial ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1298      +/-   ##
==========================================
+ Coverage   93.18%   93.42%   +0.24%     
==========================================
  Files         652      699      +47     
  Lines       49768    54786    +5018     
  Branches     5317     5794     +477     
==========================================
+ Hits        46375    51184    +4809     
- Misses       2734     2872     +138     
- Partials      659      730      +71     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

LaurenMullally and others added 8 commits November 18, 2024 14:58
* Support workflow template deletion

* Add TaskWorkflowTemplateDeleteView unit test

* Delete task templates together with workflow templates
* wip

* add subtask delete and deleteconfirm view

* fixed deletesubtask view by adding in get_form_kwargs

* Update tasks/jinja2/tasks/delete.jinja

Co-authored-by: Paul Pepper <[email protected]>

---------

Co-authored-by: Paul Pepper <[email protected]>
* Clean up urls and add update and confirm update urls

* Add Update views and templates

* amend update link in template to accomodate subtasks

* Refactor update link test

* Add is_subtask property and amend tests

* Merge in megabranch - might be wonky

---------

Co-authored-by: Paul Pepper <[email protected]>
* added navigation tile to homepage to link to workflow list views

* fixed indentation on lines 153 and 154
* Add TaskWorkflow.summary_task ForeignKey

* Refactor, remoging base class

* Add factories and fixtures for TaskWorkflow and TaskItem

* Add queryset function filter_top_level() with unit test

* Add non_workflow() and workflow_summary() queryset filter functions and tests

* Remove leftover comment.

* Correct variable name
dalecannon and others added 19 commits November 28, 2024 12:40
…st (#1339)

* Save Workflow instance in forward op to fix migration application

* Have TaskWorkflowTemplate.create_task_workflow() create summary task from data param

* Make explicit create_task_workflow() params
* Save Workflow instance in forward op to fix migration application

* Have TaskWorkflowTemplate.create_task_workflow() create summary task from data param

* Override TaskWorkflowTemplate.__str__ to display instance title

* Add UI capability to create workflows with or without workflow templates

* Make confirm_create template usable for workflow and worklow template models

* Add workflow creation confirmation view

* Add workflow create view & form unit tests

* Simplify TaskWorkflowCreateView.form_valid()

* Change factory faker provider of CategoryFactory.name to avoid recurrent duplicate key errors

* Simplify workflow_create_form_valid_data test assertion

* Make explicit create_task_workflow() params

* Remove commented out get_url() conditionals
* Add workflow detail view

* Add workflow detail view unit tests

* Add detail get_url action to Workflow model
* Add workflow delete view

* Add workflow delete view unit test

* Set workflows/confirm_delete context variables in view
* added workflow templates list view with basic search functionality

* added unit test to check that fields are being correctly displayed as columns on an html table and fixed link in homepage tile to list views

* added workflow template list view with search functionality across title, description, and template creator

* resolved PR comments and created new migration file to prevent files clashing

* added 'list_url' context data for TaskWorkflowTemplateCreate View

* fixed typo
…ses (#1343)

* Amend Queue model docstring

* Enable customisable queue field name of QueueItem concrete subclasses

* Add QueueItem metaclass validation tests

* Add type hint to QueueItem.queue_field and update its docstring

* Get field_name post-init to include inherited attributes from parent class

* Rename queue field on TaskItem and TaskItemTemplate models

* Update references to named queue

* Recommend QueueItem subclasses redefine model Meta class following queue field renaming
* Add TaskWorkflowUpdateForm

* Refactor confirm_update and edit templates for Workflow and WorkflowTemplate reuse

* Add TaskWorkflow update view

* Add edit action to TaskWorkflow.get_url()

* Add workflow update view & form tests
* Support for task workflow list view

* Incorrect code delete fix.

* Queryset filters, tests and views for tasks and workflows

* Add link to create new workflow

* Add is_summary_task property and test

* Filter support for tasks and workflows list view

* Add type column

* Correct content

* Add valid href values

* Add view_task perm

* Unit test list views

* Add list support to get_url()

* Add missing return

* Correct indentation

* Correct indent

* Remove unnecessary queryset filter

* Add return type annotation

* Completed writing test
* Avoid dereferencing null

* Avoid dereferencing null

* Remove spurious operations attribute

* Avoid dereferencing null

* Avoid dereferencing null

* Add default ordering

* Inherit model Meta and apply ordering where needed

* Do the TODOs in hrefs
* added 'created_at' and 'updated_at' fields to TaskWorkflowTemplateModel and sorting by date functionality for list view

* fixed mixin inheritance order for TaskWorkflowTemplateListView, ordering by dates works correctly now

* fixed inconsistency in datetime string formatting

* fixed datetime format inconsistencies by passing in settings.DATETIME_FORMAT as context variable
* Correctly return context

* Fix and simplify test
* Remove redundant assignment

* Set missing context variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants