Vaihe 1/4: asiakastyöt (numerointi, tagit, linkit, jäsenet, muutoshistoria)

- Uusi jobs-moduuli: asiakastyön kentät ilman rahakenttiä, juokseva
  vuosinumero VVVV-NNNN (laskuririvi lukitaan), tagit, linkit dialogissa,
  jäsenet ja muutoshistoria nimiarvoineen.
- Tilojen oikeudet: lasku luotu / laskutettu johto tai työn laskuttaja,
  arkistointi vain johto; alihankkija näkee vain jäsenyystyönsä eikä muokkaa.
- Lista ja haku (numero, nimi, asiakas), suodattimet, omat työt oletuksena,
  arkistoidut piilossa, myöhässä tekstinä ja kuvakkeena.
- Asiakasvalitsin hakuineen ja pikalisäyksineen (myös pikavastaanottoa varten).
- Asiakkaan sivulle asiakastyöt-osio; valikkoon Asiakastyöt.
- Lukurajapinnat muihin moduuleihin: UserQueries.choices,
  CustomerQueries.summaries, CatalogQueries.service_units; jobs.*-oikeudet.
- Import-linter-sopimukset, käännökset, testit (domain, application,
  integraatio, selain) sekä määrittelyn ja CLAUDE.md:n päivitys.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-29 14:38:42 +02:00
co-authored by Claude Opus 5.5
parent 679bf57eb4
commit 1ca03137fd
72 changed files with 4907 additions and 44 deletions
+10
View File
@@ -50,6 +50,16 @@ class SupervisorChoice:
name: str
@dataclass(frozen=True, slots=True)
class UserChoice:
"""What other modules (jobs) see of a user when choosing or showing people."""
id: int
name: str
role: Role
is_active: bool
@dataclass(frozen=True, slots=True)
class PasswordLink:
url: str
+13 -2
View File
@@ -1,7 +1,7 @@
from collections.abc import Sequence
from collections.abc import Iterable, Sequence
from typing import Protocol
from apps.users.application.dto import SupervisorChoice, UserDetailsData, UserSummary
from apps.users.application.dto import SupervisorChoice, UserChoice, UserDetailsData, UserSummary
from apps.users.domain.enums import Role
@@ -17,3 +17,14 @@ class UserQueries(Protocol):
def supervisor_choices(self, *, exclude_id: int | None = None) -> Sequence[SupervisorChoice]:
"""Active management and employee users."""
...
def choices(
self,
ids: Iterable[int] | None = None,
*,
active_only: bool = False,
exclude_roles: Iterable[Role] = (),
) -> Sequence[UserChoice]:
"""Users by name; ``ids`` limits to those users (inactive ones included unless
``active_only``)."""
...
+6
View File
@@ -22,3 +22,9 @@ class Permission(StrEnum):
CUSTOMERS_PERSONAL_ID_VIEW = "customers.personal_id.view"
# Base data: service units, services, work types (later price list, products).
CATALOG_MANAGE = "catalog.manage"
# Customer jobs: everyone sees (subcontractors only jobs they are members of).
JOBS_VIEW = "jobs.view"
JOBS_EDIT = "jobs.edit"
JOBS_ARCHIVE = "jobs.archive"
# Set "invoice created" / "invoiced"; the job's biller may do it too (job rule).
JOBS_INVOICE_STATUS = "jobs.invoice_status"
+4
View File
@@ -9,6 +9,10 @@ _PERMISSIONS: dict[Permission, frozenset[Role]] = {
Permission.CUSTOMERS_USE: _ALL_EXCEPT_SUBCONTRACTOR,
Permission.CUSTOMERS_PERSONAL_ID_VIEW: frozenset({Role.ADMIN, Role.MANAGEMENT}),
Permission.CATALOG_MANAGE: frozenset({Role.ADMIN, Role.MANAGEMENT}),
Permission.JOBS_VIEW: frozenset(Role),
Permission.JOBS_EDIT: _ALL_EXCEPT_SUBCONTRACTOR,
Permission.JOBS_ARCHIVE: frozenset({Role.ADMIN, Role.MANAGEMENT}),
Permission.JOBS_INVOICE_STATUS: frozenset({Role.ADMIN, Role.MANAGEMENT}),
}
+22 -2
View File
@@ -1,8 +1,8 @@
from collections.abc import Sequence
from collections.abc import Iterable, Sequence
from django.db.models import Q
from apps.users.application.dto import SupervisorChoice, UserDetailsData, UserSummary
from apps.users.application.dto import SupervisorChoice, UserChoice, UserDetailsData, UserSummary
from apps.users.domain.enums import Role
from apps.users.infrastructure.orm import User
@@ -56,3 +56,23 @@ class DjangoUserQueries:
if exclude_id is not None:
qs = qs.exclude(pk=exclude_id)
return [SupervisorChoice(id=u.pk, name=u.name) for u in qs]
def choices(
self,
ids: Iterable[int] | None = None,
*,
active_only: bool = False,
exclude_roles: Iterable[Role] = (),
) -> Sequence[UserChoice]:
qs = User.objects.order_by("name", "pk")
if ids is not None:
qs = qs.filter(pk__in=list(ids))
if active_only:
qs = qs.filter(is_active=True)
excluded = [r.value for r in exclude_roles]
if excluded:
qs = qs.exclude(role__in=excluded)
return [
UserChoice(id=u.pk, name=u.name, role=Role(u.role), is_active=u.is_active)
for u in qs.only("id", "name", "role", "is_active")
]