2 Commits

Author SHA1 Message Date
231cefbcd4 claude version of first prompt 2026-11-01 19:00:54 -05:00
6546c86bcc updated task-brief with the first prompt and notes additions 2026-11-01 18:48:22 -05:00
3 changed files with 320 additions and 30 deletions

View File

@@ -0,0 +1,87 @@
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 existing `sprint_list` view, and never filter in the template. Superusers see all tasks.
- `user_level` is 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.
**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 by `task_status_sort_order`. More than one can be ticked. The parameter `status` holds the `task_status_id` and 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 `assignee` holds the user id.
- `0` means unassigned (`task_assigned_to__isnull=True`).
- **Project:** a dropdown with "All Projects", then the projects the user can access through their groups. The parameter `project` holds the `project_id`.
- **Date range:** two optional date inputs that work independently.
- `start_date` filters `task_start_date >= value`.
- `end_date` filters `task_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:
1. **Title:** the task's short description in bold, with `#T-{task_id}` in small muted text below it.
2. **Status:** a badge showing the status name.
3. **Priority:** a small colored dot plus the label from `get_task_priority_display`.
4. **Assignee:** the username, or `-` if there isn't one.
5. **Project:** the project name.
6. **Start Date**, 7. **End Date** and 8. **Created:** all formatted `YYYY-MM-DD`.
9. **Actions:** a "View" button linking to `task_information` for that task. When the table scrolls sideways, keep this column pinned to the right edge.
- **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=field` sorts ascending and shows ▲ in the header. `?sort=-field` sorts 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_description`
- `task_status__task_status_sort_order`
- `task_priority`
- `task_assigned_to__username`
- `project`: map this to the project lookup through `ObjectAssignment`
- `task_start_date`
- `task_end_date`
- `date_created`
- **Priority order:** `task_priority` is an `ObjectPriority` integer where 0 means Highest, so ascending puts Highest first.
**Pagination**
- **Page numbers:** use `Paginator.get_page()`, and `get_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, Backlog
- `normal`: In Progress, Test/Review
- `blocked`: Blocked
- `closed`: Closed
- **Priority dot:** `priority-high` for Highest and High, `priority-normal` for Normal, and `priority-low` for 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

View File

@@ -1,36 +1,101 @@
────────────────────────────────────────────────────────────────────────
### 1. Task Description
### 1. Task Description
NearBeach is a Django/Vue project management tool that currently has task detail views and task creation, but lacks a general task list view for users to see all their tasks across projects. Users must navigate through individual projects or kanban boards to find tasks, which is inefficient for project managers overseeing multiple projects. This task adds a dedicated `/tasks/` page with filtering (status, assignee, project, date range), sortable columns, and pagination.
│ NearBeach is a Django/Vue project management tool that currently has
│ task detail views and task creation, but lacks a general task list
│ view for users to see all their tasks across projects. Users must
│ navigate through individual projects or kanban boards to find tasks,
│ which is inefficient for project managers overseeing multiple
│ projects. This task adds a dedicated /tasks/ page with filtering
│ (status, assignee, project, date range), sortable columns, and
│ pagination.
---
### 2. How to Judge Completion
### 2. How to Judge Completion
│ Run the NearBeach setup commands (install, migrate, create superuser,
│ runserver), log in as admin/password, and navigate to /tasks/ — a
│ paginated table of tasks the user has permission to view should
│ appear. Test filtering by status, assignee, project, and date range;
│ verify column headers toggle ascending/descending sort; confirm page
│ size selector (10/25/50/100) and page navigation work. Run python3
│ manage.py test NearBeach.tests.tests_views.tests_task — 10+ new tests
│ covering filtering, sorting, pagination, and permissions should pass.
│ Create a second user without access to a project, log in as them, and
│ verify they cannot see tasks from that project.
Run the NearBeach setup commands (install, migrate, create superuser, runserver), log in as admin/password, and navigate to `/tasks/` — a paginated table of tasks the user has permission to view should appear. Test filtering by status, assignee, project, and date range; verify column headers toggle ascending/descending sort; confirm page size selector (10/25/50/100) and page navigation work. Run `python3 manage.py test NearBeach.tests.tests_views.tests_task` — 10+ new tests covering filtering, sorting, pagination, and permissions should pass. Create a second user without access to a project, log in as them, and verify they cannot see tasks from that project.
### 3. Other Notes for Reviewer
---
│ NearBeach uses a group-based permission system via ObjectAssignment —
│ users only see tasks from projects their groups are assigned to. The
│ implementation must filter the queryset at the database level (not in
│ templates) following the existing pattern in sprint_list view.
│ Superusers bypass all filters. The task touches Django views,
│ templates, URL routing, forms, and requires comprehensive tests to
│ ensure permission filtering works correctly across all
│ filter/sort/pagination combinations.
### 3. Other Notes for Reviewer
NearBeach uses a group-based permission system via ObjectAssignment — users only see tasks from projects their groups are assigned to. The implementation must filter the queryset at the database level (not in templates) following the existing pattern in `sprint_list` view. Superusers bypass all filters. The task touches Django views, templates, URL routing, forms, and requires comprehensive tests to ensure permission filtering works correctly across all filter/sort/pagination combinations.
---
### Implementation Essentials (for Model)
**View & Template:**
- Server-rendered Django template (no Vue component): `NearBeach/templates/NearBeach/tasks/task_list.html`
- URL: `path("tasks/", views.task_list, name="task_list")`
- Follows `sprint_list` pattern for permission filtering via `ObjectAssignment` → `UserGroup` → `Group`
- All state (filters, sort, page, page_size) lives in the query string; every link rebuilds it
**Filter Sidebar (GET form, `action="/tasks/"`):**
| Param | Control | Query |
|-------|---------|-------|
| `status` (repeatable) | Checkboxes; value = `task_status_id` | `task_status_id__in=[...]` |
| `assignee` | Select; value = user `id` (0 = Unassigned) | `task_assigned_to=<id>` / `task_assigned_to__isnull=True` |
| `project` | Select; value = `project_id` | Tasks linked via `ObjectAssignment` |
| `start_date` | `<input type="date">`, optional | `task_start_date__gte=value` |
| `end_date` | `<input type="date">`, optional | `task_end_date__lte=value` |
- Status options from `ListOfTaskStatus` ordered by `task_status_sort_order`
- Assignee options: "All", users with task access in accessible projects, "Unassigned" (0)
- Project options: "All", projects user can reach through their groups
- Clear Filters = link to `/tasks/` (drops all params); Apply = form submit
- Hidden `sort` input in form carries current sort; hidden `page_size` dropdown in form
**Table (9 columns):**
| Column | Sort Field | Rendering |
|--------|------------|-----------|
| Title | `task_short_description` | Bold description + `#T-{task_id}` small |
| Status | `task_status__task_status_sort_order` | Badge: `badge-{{ higher_order_status\|lower }}` |
| Priority | `task_priority` | 8px dot + `{{ get_task_priority_display }}` |
| Assignee | `task_assigned_to__username` | Username or `-` |
| Project | `first_project_name` (annotated) | Via `ObjectAssignment` subquery |
| Start Date | `task_start_date` | `Y-m-d` |
| End Date | `task_end_date` | `Y-m-d` |
| Created | `date_created` | `Y-m-d` (default sort: `-date_created`) |
| Actions | — | "View" → `{% url 'task_information' task.task_id %}` |
**Status Badges** (4 classes by `task_higher_order_status`):
- `badge-backlog` (New, Backlog) — yellow
- `badge-normal` (In Progress, Test/Review) — blue
- `badge-blocked` (Blocked) — red
- `badge-closed` (Closed) — green
**Priority** (3 color groups):
- `priority-high` (0=Highest, 1=High) — red
- `priority-normal` (2=Normal) — orange
- `priority-low` (3=Low, 4=Lowest) — blue
**Sorting:**
- `?sort=field` = ASC (▲), `?sort=-field` = DESC (▼)
- Click active column → toggle; click different column → ASC
- Allowed fields: the 8 above only; invalid falls back to default
- Header links keep all other params, reset `page=1`
- Hidden `sort` input in filter form persists current sort
**Pagination:**
- `page_size`: 10/25/50/100 (default 25); invalid → 25; dropdown in filter form, auto-submits
- `page`: `Paginator.get_page()` (safe); elided range: `on_each_side=2, on_ends=1`
- Prev/Next: disabled (`<span>`) on first/last page
- All page links preserve filters, sort, page_size; change only `page`
- Apply / sort click / page_size change / Clear Filters → reset to `page=1`
- Results: `Showing {{ page_obj.start_index }}–{{ page_obj.end_index }} of {{ paginator.count }} tasks`
**Actions Column:** Pinned right (`th:last-child, td:last-child { position: sticky; right: 0; }`); other columns scroll sideways inside container
**Empty State:** `{% empty %}` row with `colspan="9"`, centered "No tasks found"; count shows "0–0 of 0"
**Permissions (DB-level, not template):**
- Queryset limited to tasks from projects user's groups can reach via `ObjectAssignment`
- Superusers see all
- `user_level` = max task permission across groups
- "+ New Task" button: `user_level >= 3`
- "View" button: `user_level >= 1`
- Filter sidebar: always visible
**Styling:**
- New partial: `src/sass/components/_task_list.scss` → imported in `main.scss`
- Add `--nb-*` tokens for new colors in both `_light_theme.scss` and `_dark_theme.scss`
- Reuse: `btn btn-primary`, `btn btn-secondary`, `form-control`, `badge`, card/spacing styles
- Layout: desktop = sidebar (~280px) + table; <1024px = stacked
- Table cells: 12px 16px padding
- Badge text + background readable in both themes
**Tests:** 12 test methods in `NearBeach/tests/tests_views/tests_task/test_task_list.py`

View File

@@ -0,0 +1,138 @@
# Task List Mockup — Implementation Notes
Companion to `task-list-mockup.html`. The mockup is the visual and structural target for the new `/tasks/` page; these notes cover the behavior and rules that the HTML can't show on its own.
---
## 1. Remove before building
These exist only so the mockup works as a standalone file:
- **Yellow "Mockup controls" bar**: simulates `user_level`, shows the empty state, and prints the GET URL the form would produce.
- **The entire `<script>` block**: client-side sorting, pagination, and the form/link interception. On the real page, all of this happens on the server through normal links and form submits.
- **Sample data**: the 10 rows, usernames, project names, task IDs, dates and "142 tasks" total are placeholders.
The Django template code lives in HTML comments throughout the mockup. Use those comments for the real template.
---
## 2. Rendering approach
- **Server-rendered:** a Django template with a plain GET form, as in the mockup.
- **URL as state:** all state (filters, sort, page, page size) lives in the query string.
- **Links:** every link rebuilds that query string.
---
## 3. Filters
All filters belong to one GET form (`action="/tasks/"`) and are applied with the **Apply** button.
| Param | Control | Query |
|---|---|---|
| `status` (repeatable) | Checkboxes; value = `task_status_id` | `task_status_id__in=[...]` |
| `assignee` | Select; value = user `id` | `task_assigned_to=<id>` |
| `assignee=0` | "Unassigned" option | `task_assigned_to__isnull=True` |
| `project` | Select; value = `project_id` | Tasks linked to that project via `ObjectAssignment` |
| `start_date` | `<input type="date">`, optional | `task_start_date >= value` |
| `end_date` | `<input type="date">`, optional | `task_end_date <= value` |
- **Empty values:** an empty field means no filter. Each date can be used without the other.
- **Assignee options:** "All Assignees", then the users with task access in the current user's accessible projects, then "Unassigned".
- **Project options:** "All Projects", then the projects the user can reach through their groups (`ObjectAssignment`).
- **Status options:** come from `ListOfTaskStatus`, ordered by `task_status_sort_order`.
- **Clear Filters:** a link to `/tasks/`, not a reset button. It drops every query parameter.
---
## 4. Sorting
| Column | `sort` value |
|---|---|
| Title | `task_short_description` |
| Status | `task_status__task_status_sort_order` (workflow order) |
| Priority | `task_priority` |
| Assignee | `task_assigned_to__username` |
| Project | `project` (alias; the view maps it to the project lookup via `ObjectAssignment`) |
| Start Date | `task_start_date` |
| End Date | `task_end_date` |
| Created | `date_created` |
- **Parameter format:** `?sort=field` sorts ascending (▲ on the header); `?sort=-field` sorts descending (▼).
- **Clicking headers:** clicking the active column flips its direction. Clicking a different column sorts it ascending.
- **Default:** `-date_created` (newest first).
- **Allowed values:** only the eight values above. Anything else falls back to the default; never pass raw input to `order_by`.
- **Priority:** ascending puts Highest (0) first, because lower numbers mean higher priority.
- **Header links:** keep all other active parameters and reset to page 1.
- **Current sort in the form:** a hidden `sort` input in the filter form carries the current sort, so Apply and page-size changes keep it.
---
## 5. Pagination
- **Page size:** `page_size` accepts 10, 25, 50 or 100, default 25. Any other value falls back to 25.
- The dropdown sits above the table but belongs to the filter form (`form="task-filter-form"`).
- It submits on change. This is the only control that submits automatically.
- **Page number:** use `Paginator.get_page()` so a bad or out-of-range `page` doesn't raise an error.
- **Page numbers shown:** `paginator.get_elided_page_range(page_obj.number, on_each_side=2, on_ends=1)`. With 6 or fewer pages, all are shown.
- **Prev / Next:** "◀ Prev" is disabled (a `<span>`, not a link) on page 1, and "Next ▶" on the last page.
- **Links:** every page link keeps all filters, sort and `page_size`, and changes only `page`.
- **Reset to page 1:** Apply, a page-size change, a sort click and Clear Filters all return to page 1.
- **Results count:** `Showing {{ page_obj.start_index }}–{{ page_obj.end_index }} of {{ page_obj.paginator.count }} tasks`.
---
## 6. Table rendering
- **Title:** `task_short_description` in bold, with `#T-{task_id}` in small muted text below it.
- **Status badge:** `badge badge-{{ task.task_status.task_higher_order_status|lower }}`.
| Class | Statuses |
|---|---|
| `badge-backlog` | New, Backlog |
| `badge-normal` | In Progress, Test/Review |
| `badge-blocked` | Blocked |
| `badge-closed` | Closed |
- **Priority:** an 8px dot plus the label from `{{ task.get_task_priority_display }}`. The class comes from the value.
| Class | Values |
|---|---|
| `priority-high` | 0 Highest, 1 High |
| `priority-normal` | 2 Normal |
| `priority-low` | 3 Low, 4 Lowest |
- **Assignee:** the username, or `-` if unassigned.
- **Dates:** formatted `Y-m-d`.
- **Actions:** a "View" button linking to `{% url 'task_information' task.task_id %}`.
- The Actions column (`col-actions`) is pinned to the table's right edge (`position: sticky`). The other columns scroll sideways inside the table container, so the page itself never scrolls sideways.
- **Empty state:** `{% empty %}` renders one row with `colspan="9"` and centered "No tasks found". The count reads "Showing 0–0 of 0 tasks".
---
## 7. Permissions
- **Database-level filtering:** the queryset is limited to tasks from projects the user's groups can reach through `ObjectAssignment`. Follow the existing `sprint_list` view, and never filter in the template.
- **Superusers:** they skip that filter and see every task and every UI element.
- **`user_level`:** the user's highest task permission across their groups.
| Element | Shown when |
|---|---|
| "+ New Task" (`{% url 'new_task' %}`) | `user_level >= 3` |
| "View" button | `user_level >= 1` |
| Filter sidebar | Always |
---
## 8. Styling and theme
- **Colors:** use the app's theme colors, not the hex values in the mockup. Those hex values only show what's intended: neutral surfaces, a blue primary, and the badge and priority color groups.
- Add a `--nb-*` token for each new color to **both** `src/sass/themes/_light_theme.scss` and `_dark_theme.scss`, and reference it with `var(--nb-...)`.
- The page must look right in both light and dark themes.
- Badge text and its background must stay readable in both themes.
- **Where new styles go:** a new partial `src/sass/components/_task_list.scss`, imported in `src/sass/main.scss`.
- **Existing classes to reuse:** `btn btn-primary`, `btn btn-secondary`, `form-control` and `badge`, plus the app's existing card and spacing styles.
- **Layout:**
- On desktop, a fixed-width sidebar (about 280px) sits beside the table.
- Below 1024px, the layout stacks into one column.
- Table cells use 12px 16px padding.