5.5 KiB
5.5 KiB
Add a cross-project task list page at /tasks/ to NearBeach. Today users can only find tasks by going through individual projects or kanban boards. This page gives them one place to see every task they're allowed to see, with filtering, sorting and pagination.
Build it as a server-rendered Django page: a view in NearBeach/views/task_views.py, a URL route, a filter form and a template. All page state lives in the query string (GET), so every state of the list has its own URL.
Access
- Limit the queryset in the database to tasks from projects the user's groups can access through
ObjectAssignment. Follow the pattern in the existingsprint_listview, and never filter in the template. Superusers see all tasks. user_levelis the user's highest task permission across their groups.- Show "+ New Task" only when
user_level >= 3. - Show each row's "View" button only when
user_level >= 1. - The filters are always visible.
- Show "+ New Task" only when
Layout
- Header: the title "All Tasks" on the left, and a "+ New Task" button (linking to
new_task) on the right. - Below the header: a filter sidebar on the left (about 280px) and the results on the right. Below 1024px wide, stack them into a single column.
Filters All filters are in one GET form and are applied with an Apply button.
- Status: a checkbox for every
ListOfTaskStatus, ordered bytask_status_sort_order. More than one can be ticked. The parameterstatusholds thetask_status_idand can repeat. - Assignee: a dropdown with "All Assignees", then the users with task access in the current user's accessible projects, then "Unassigned".
- The parameter
assigneeholds the user id. 0means unassigned (task_assigned_to__isnull=True).
- The parameter
- Project: a dropdown with "All Projects", then the projects the user can access through their groups. The parameter
projectholds theproject_id. - Date range: two optional date inputs that work independently.
start_datefilterstask_start_date >= value.end_datefilterstask_end_date <= value.
- Buttons: "Clear Filters" is a link to
/tasks/, so it drops every parameter. "Apply" submits the form.
Results area
- Top row:
- Left: "Showing X–Y of Z tasks", using the paginator's numbers.
- Right: a page-size dropdown with 10, 25, 50 and 100 (default 25, parameter
page_size). - Page size is the only control that submits as soon as it changes. It keeps the active filters and sort.
- Table: nine columns, in this order:
- Title: the task's short description in bold, with
#T-{task_id}in small muted text below it. - Status: a badge showing the status name.
- Priority: a small colored dot plus the label from
get_task_priority_display. - Assignee: the username, or
-if there isn't one. - Project: the project name.
- Start Date, 7. End Date and 8. Created: all formatted
YYYY-MM-DD. - Actions: a "View" button linking to
task_informationfor that task. When the table scrolls sideways, keep this column pinned to the right edge.
- Title: the task's short description in bold, with
- Empty state: when the queryset is empty, show one row spanning all columns, with "No tasks found" centered.
Sorting
- Which columns: every column except Actions can be sorted.
- URL format:
?sort=fieldsorts ascending and shows ▲ in the header.?sort=-fieldsorts descending and shows ▼. - Clicking: clicking the active column flips the direction. Clicking a different column sorts it ascending.
- Default:
-date_created. - Allowed values: only these (anything else falls back to the default):
task_short_descriptiontask_status__task_status_sort_ordertask_prioritytask_assigned_to__usernameproject: map this to the project lookup throughObjectAssignmenttask_start_datetask_end_datedate_created
- Priority order:
task_priorityis anObjectPriorityinteger where 0 means Highest, so ascending puts Highest first.
Pagination
- Page numbers: use
Paginator.get_page(), andget_elided_page_range(on_each_side=2, on_ends=1)for the page links. - Prev and Next: "◀ Prev" is disabled on page 1 and "Next ▶" on the last page. Highlight the current page.
- Keeping parameters: every sort, page and page-size link keeps all the other active parameters.
- Returning to page 1: applying filters, changing the sort or changing the page size goes back to page 1.
- Invalid page size: any value other than 10, 25, 50 or 100 falls back to 25.
Badge and priority classes
- Status badge: the class comes from the status's higher-order status:
badge badge-{{ task_higher_order_status|lower }}.backlog: New, Backlognormal: In Progress, Test/Reviewblocked: Blockedclosed: Closed
- Priority dot:
priority-highfor Highest and High,priority-normalfor Normal, andpriority-lowfor Low and Lowest.
Styling
- Use the app's existing theme and Bootstrap classes, with no hard-coded colors.
- Add any new colors as
--nb-*tokens in both the light and dark theme files. Put the page's styles in a new SCSS partial. - Color intent:
- Badges: backlog beige, normal cyan, blocked pink, closed green.
- Priority dots: red for high, orange for normal, blue for low.
- We'll refine the look in later turns.
Tests
Add at least 10 tests under NearBeach/tests/tests_views/tests_task/. They should cover:
- each filter
- sorting, including an invalid sort value
- pagination and page size
- permissions: a user without access to a project must not see its tasks, and a superuser sees everything