-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement prototype UI for tasks (#1308)
* 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
- Loading branch information
1 parent
0595097
commit de2733c
Showing
25 changed files
with
872 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.forms import CheckboxSelectMultiple | ||
from django.urls import reverse_lazy | ||
from django_filters import ModelMultipleChoiceFilter | ||
|
||
from common.filters import TamatoFilter | ||
from tasks.models import ProgressState | ||
from tasks.models import Task | ||
|
||
|
||
class TaskFilter(TamatoFilter): | ||
|
||
search_fields = ( | ||
"id", | ||
"title", | ||
"description", | ||
) | ||
clear_url = reverse_lazy("workflow:task-ui-list") | ||
|
||
progress_state = ModelMultipleChoiceFilter( | ||
label="Status", | ||
help_text="Select all that apply", | ||
queryset=ProgressState.objects.all(), | ||
widget=CheckboxSelectMultiple, | ||
) | ||
|
||
class Meta: | ||
model = Task | ||
fields = ["search", "category", "progress_state"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from crispy_forms_gds.helper import FormHelper | ||
from crispy_forms_gds.layout import Layout | ||
from crispy_forms_gds.layout import Size | ||
from crispy_forms_gds.layout import Submit | ||
from django.forms import ModelForm | ||
|
||
from common.forms import delete_form_for | ||
from tasks.models import Task | ||
from workbaskets.models import WorkBasket | ||
|
||
|
||
class TaskBaseForm(ModelForm): | ||
class Meta: | ||
model = Task | ||
exclude = ["parent_task", "creator"] | ||
|
||
error_messages = { | ||
"title": { | ||
"required": "Enter a title", | ||
}, | ||
"description": { | ||
"required": "Enter a description", | ||
}, | ||
"progress_state": { | ||
"required": "Select a status", | ||
}, | ||
} | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.init_fields() | ||
self.init_layout() | ||
|
||
def init_fields(self): | ||
self.fields["progress_state"].label = "Status" | ||
self.fields["workbasket"].queryset = WorkBasket.objects.editable() | ||
|
||
def init_layout(self): | ||
self.helper = FormHelper(self) | ||
self.helper.label_size = Size.SMALL | ||
self.helper.legend_size = Size.SMALL | ||
self.helper.layout = Layout( | ||
"title", | ||
"description", | ||
"category", | ||
"progress_state", | ||
"workbasket", | ||
Submit( | ||
"submit", | ||
"Save", | ||
data_module="govuk-button", | ||
data_prevent_double_click="true", | ||
), | ||
) | ||
|
||
|
||
class TaskCreateForm(TaskBaseForm): | ||
def save(self, user, commit=True): | ||
instance = super().save(commit=False) | ||
instance.creator = user | ||
if commit: | ||
instance.save() | ||
return instance | ||
|
||
|
||
class TaskUpdateForm(TaskBaseForm): | ||
pass | ||
|
||
|
||
TaskDeleteForm = delete_form_for(Task) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{% extends "common/confirm_create.jinja" %} | ||
|
||
{% from "components/breadcrumbs/macro.njk" import govukBreadcrumbs %} | ||
{% from "components/panel/macro.njk" import govukPanel %} | ||
{% from "components/button/macro.njk" import govukButton %} | ||
|
||
{% set page_title = "Task created" %} | ||
|
||
{% block breadcrumb %} | ||
{{ govukBreadcrumbs({ | ||
"items": [ | ||
{"text": "Home", "href": url("home")}, | ||
{"text": "Create a new task", "href": url("workflow:task-ui-create") }, | ||
{"text": "Task created"} | ||
] | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block panel %} | ||
{{ govukPanel({ | ||
"titleText": "Task: " ~ object.title, | ||
"text": "You have created a new task", | ||
"classes": "govuk-!-margin-bottom-7" | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block button_group %} | ||
{{ govukButton({ | ||
"text": "View task", | ||
"href": url('workflow:task-ui-detail', kwargs={"pk": object.pk}), | ||
"classes": "govuk-button" | ||
}) }} | ||
{{ govukButton({ | ||
"text": "Return to homepage", | ||
"href": url("home"), | ||
"classes": "govuk-button--secondary" | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block actions %} | ||
<li><a href="{{ url("workflow:task-ui-list") }}">Find and view tasks</a></li> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{% extends "layouts/confirm.jinja" %} | ||
|
||
{% from "components/breadcrumbs/macro.njk" import govukBreadcrumbs %} | ||
{% from "components/panel/macro.njk" import govukPanel %} | ||
{% from "components/button/macro.njk" import govukButton %} | ||
|
||
{% set page_title = "Task deleted" %} | ||
|
||
{% block breadcrumb %} | ||
{{ govukBreadcrumbs({ | ||
"items": [ | ||
{"text": "Find and view tasks", "href": url("workflow:task-ui-list")}, | ||
{"text": page_title} | ||
] | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block panel %} | ||
{{ govukPanel({ | ||
"titleText": "Task ID: " ~ deleted_pk, | ||
"text": "Task has been deleted", | ||
"classes": "govuk-!-margin-bottom-7" | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block button_group %} | ||
{{ govukButton({ | ||
"text": "Find and view tasks", | ||
"href": url("workflow:task-ui-list"), | ||
"classes": "govuk-button" | ||
}) }} | ||
{{ govukButton({ | ||
"text": "Return to homepage", | ||
"href": url("home"), | ||
"classes": "govuk-button--secondary" | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block actions %} | ||
<li><a href="{{ url("workflow:task-ui-create") }}">Create a task</a></li> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{% extends "common/confirm_update.jinja" %} | ||
|
||
{% from "components/breadcrumbs/macro.njk" import govukBreadcrumbs %} | ||
{% from "components/panel/macro.njk" import govukPanel %} | ||
{% from "components/button/macro.njk" import govukButton %} | ||
|
||
{% set page_title = "Task updated" %} | ||
|
||
{% block breadcrumb %} | ||
{{ govukBreadcrumbs({ | ||
"items": [ | ||
{"text": "Task: " ~ object.title, "href": url("workflow:task-ui-detail", kwargs={"pk": object.pk})}, | ||
{"text": page_title} | ||
] | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block panel %} | ||
{{ govukPanel({ | ||
"titleText": "Task: " ~ object.title, | ||
"text": "Task has been updated", | ||
"classes": "govuk-!-margin-bottom-7" | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block button_group %} | ||
{{ govukButton({ | ||
"text": "View task", | ||
"href": url('workflow:task-ui-detail', kwargs={"pk": object.pk}), | ||
"classes": "govuk-button" | ||
}) }} | ||
{{ govukButton({ | ||
"text": "Return to homepage", | ||
"href": url("home"), | ||
"classes": "govuk-button--secondary" | ||
}) }} | ||
{% endblock %} | ||
|
||
{% block actions %} | ||
<li><a href="{{ url("workflow:task-ui-list") }}">Find and view tasks</a></li> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% extends "common/delete.jinja" %} | ||
|
||
{% from "components/breadcrumbs.jinja" import breadcrumbs %} | ||
{% from "components/warning-text/macro.njk" import govukWarningText %} | ||
{% from "components/button/macro.njk" import govukButton %} | ||
|
||
{% set page_title = "Delete Task:" ~ object.title %} | ||
|
||
{% block breadcrumb %} | ||
{{ breadcrumbs(request, [ | ||
{"text": "Find and view tasks", "href": url("workflow:task-ui-list")}, | ||
{"text": "Task: " ~ object.title, "href": url("workflow:task-ui-detail", kwargs={"pk": object.pk})}, | ||
{"text": page_title} | ||
]) | ||
}} | ||
{% endblock %} | ||
|
||
{% block form %} | ||
{{ govukWarningText({ | ||
"text": "Are you sure you want to delete this task?" | ||
}) }} | ||
|
||
{% call django_form(action=url("workflow:task-ui-delete", kwargs={"pk": object.pk})) %} | ||
{{ crispy(form) }} | ||
{% endcall %} | ||
{% endblock %} |
Oops, something went wrong.