t-paliad-025 — Phase 1: backend rename.
Migrations 018+019 rewritten from scratch with English table/column
names throughout. Since v2 schema (018/019) has never been applied to
youpc prod DB, this is a clean replacement — not an ALTER RENAME chain.
Pre-existing German tables (parteien, fristen, termine, dokumente,
akten_events, notizen) are renamed inline in 018 via ALTER TABLE … RENAME
TO alongside the akte_id → project_id column rewrite.
Renames applied:
projekte → projects
projekt_teams → project_teams
projekt_events → project_events (via akten_events → project_events)
fristen → deadlines
termine → appointments
parteien → parties
notizen → notes
dezernate → departments
dezernat_mitglieder → department_members
dokumente → documents
can_see_projekt → can_see_project
notiz_is_visible → note_is_visible
akte_id / frist_id / termin_id / akten_event_id → project_id /
deadline_id / appointment_id / project_event_id
termin_type → appointment_type
Go types + services renamed:
Projekt / ProjektService / ProjektEvent / ProjektTeamMember
Frist / FristService / FristWithProjekt
Termin / TerminService / TerminWithProjekt / TerminType
Notiz / NotizService / ChecklistInstanceWithProjekt
Dezernat / DezernatService / DezernatMitglied
Partei / Parteien / ParteienService
Files renamed (git mv):
internal/services/{projekt,frist,termin,notiz,dezernat,parteien}_service.go
→ {project,deadline,appointment,note,department,party}_service.go
internal/handlers/{projekte,fristen,fristen_pages,termine,termine_pages,
notizen,dezernate,akten_pages,gerichte,glossar,checklisten}.go
→ {projects,deadlines,deadlines_pages,appointments,appointments_pages,
notes,departments,projects_pages,courts,glossary,checklists}.go
internal/checklisten/ → internal/checklists/
internal/db/migrations/018_projekte_v2.* → 018_projects_v2.*
internal/db/migrations/019_seed_dezernate_from_user_text.*
→ 019_seed_departments_from_user_text.*
User-facing i18n strings (DE/EN labels) stay untouched. Product names
Fristenrechner / Kostenrechner / Gebührentabellen stay German.
Build + vet + tests clean.
98 lines
3.1 KiB
Go
98 lines
3.1 KiB
Go
// Package checklists holds the static checklist templates that users
|
|
// instantiate on /checklists/{slug}. Template data lives in Go (not in
|
|
// the DB) because it's curated content, versioned with the code, and
|
|
// rarely changes. Per-user state lives in paliad.checklist_instances.
|
|
//
|
|
// Both the HTTP layer (internal/handlers) and the service layer
|
|
// (internal/services) import this package — handlers serve the template
|
|
// JSON to the frontend, services validate slugs on POST and count items
|
|
// for progress responses without needing handler types.
|
|
package checklists
|
|
|
|
// Item is a single checklist point.
|
|
type Item struct {
|
|
LabelDE string `json:"labelDE"`
|
|
LabelEN string `json:"labelEN"`
|
|
NoteDE string `json:"noteDE,omitempty"`
|
|
NoteEN string `json:"noteEN,omitempty"`
|
|
Rule string `json:"rule,omitempty"`
|
|
}
|
|
|
|
// Group bundles related items under a heading.
|
|
type Group struct {
|
|
TitleDE string `json:"titleDE"`
|
|
TitleEN string `json:"titleEN"`
|
|
Items []Item `json:"items"`
|
|
}
|
|
|
|
// Template is the full definition of one checklist (UPC Klageschrift,
|
|
// EPA Einspruch, etc.). Slugs are URL-safe; client state keys are
|
|
// "g{groupIdx}-i{itemIdx}" (positional).
|
|
type Template struct {
|
|
Slug string `json:"slug"`
|
|
TitleDE string `json:"titleDE"`
|
|
TitleEN string `json:"titleEN"`
|
|
DescriptionDE string `json:"descriptionDE"`
|
|
DescriptionEN string `json:"descriptionEN"`
|
|
Regime string `json:"regime"` // UPC | DE | EPA
|
|
CourtDE string `json:"courtDE"`
|
|
CourtEN string `json:"courtEN"`
|
|
DeadlineDE string `json:"deadlineDE,omitempty"`
|
|
DeadlineEN string `json:"deadlineEN,omitempty"`
|
|
ReferenceDE string `json:"referenceDE,omitempty"`
|
|
ReferenceEN string `json:"referenceEN,omitempty"`
|
|
Groups []Group `json:"groups"`
|
|
}
|
|
|
|
// Summary is the shape returned by the list endpoint — template metadata
|
|
// without the full item tree.
|
|
type Summary struct {
|
|
Slug string `json:"slug"`
|
|
TitleDE string `json:"titleDE"`
|
|
TitleEN string `json:"titleEN"`
|
|
DescriptionDE string `json:"descriptionDE"`
|
|
DescriptionEN string `json:"descriptionEN"`
|
|
Regime string `json:"regime"`
|
|
CourtDE string `json:"courtDE"`
|
|
CourtEN string `json:"courtEN"`
|
|
ItemCount int `json:"itemCount"`
|
|
}
|
|
|
|
// TotalItems counts the items across every group of a template.
|
|
func TotalItems(t Template) int {
|
|
n := 0
|
|
for _, g := range t.Groups {
|
|
n += len(g.Items)
|
|
}
|
|
return n
|
|
}
|
|
|
|
// Find returns the template for a slug, or ok=false if none match.
|
|
func Find(slug string) (Template, bool) {
|
|
for _, t := range Templates {
|
|
if t.Slug == slug {
|
|
return t, true
|
|
}
|
|
}
|
|
return Template{}, false
|
|
}
|
|
|
|
// Summaries returns a summary for every registered template.
|
|
func Summaries() []Summary {
|
|
out := make([]Summary, 0, len(Templates))
|
|
for _, t := range Templates {
|
|
out = append(out, Summary{
|
|
Slug: t.Slug,
|
|
TitleDE: t.TitleDE,
|
|
TitleEN: t.TitleEN,
|
|
DescriptionDE: t.DescriptionDE,
|
|
DescriptionEN: t.DescriptionEN,
|
|
Regime: t.Regime,
|
|
CourtDE: t.CourtDE,
|
|
CourtEN: t.CourtEN,
|
|
ItemCount: TotalItems(t),
|
|
})
|
|
}
|
|
return out
|
|
}
|