Full event-driven deadline determination system ported from youpc.org:
Backend:
- DetermineService: walks proceeding event tree, calculates cascading
dates with holiday adjustment and conditional logic
- GET /api/proceeding-types/{code}/timeline — full event tree structure
- POST /api/deadlines/determine — calculate timeline with conditions
- POST /api/cases/{caseID}/deadlines/batch — batch-create deadlines
- DeadlineRule model: added is_spawn, spawn_label fields
- GetFullTimeline: recursive CTE following cross-type spawn branches
- Conditional deadlines: condition_rule_id toggles alt_duration/rule_code
(e.g. Reply changes from RoP.029b to RoP.029a when CCR is filed)
- Seed SQL with full UPC event trees (INF, REV, CCR, APM, APP, AMD)
Frontend:
- DeadlineWizard: interactive proceeding timeline with step-by-step flow
1. Select proceeding type (visual cards)
2. Enter trigger event date
3. Toggle conditional branches (CCR, Appeal, Amend)
4. See full calculated timeline with color-coded urgency
5. Batch-create all deadlines on a selected case
- Visual timeline tree with party icons, rule codes, duration badges
- Kept existing DeadlineCalculator as "Schnell" quick mode
Also resolved merge conflicts across 6 files (auth, router, handlers)
merging role-based permissions + audit trail features.
65 lines
1.5 KiB
Go
65 lines
1.5 KiB
Go
package auth
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type contextKey string
|
|
|
|
const (
|
|
userIDKey contextKey = "user_id"
|
|
tenantIDKey contextKey = "tenant_id"
|
|
ipKey contextKey = "ip_address"
|
|
userAgentKey contextKey = "user_agent"
|
|
userRoleKey contextKey = "user_role"
|
|
)
|
|
|
|
func ContextWithUserID(ctx context.Context, userID uuid.UUID) context.Context {
|
|
return context.WithValue(ctx, userIDKey, userID)
|
|
}
|
|
|
|
func ContextWithTenantID(ctx context.Context, tenantID uuid.UUID) context.Context {
|
|
return context.WithValue(ctx, tenantIDKey, tenantID)
|
|
}
|
|
|
|
func UserFromContext(ctx context.Context) (uuid.UUID, bool) {
|
|
id, ok := ctx.Value(userIDKey).(uuid.UUID)
|
|
return id, ok
|
|
}
|
|
|
|
func TenantFromContext(ctx context.Context) (uuid.UUID, bool) {
|
|
id, ok := ctx.Value(tenantIDKey).(uuid.UUID)
|
|
return id, ok
|
|
}
|
|
|
|
func ContextWithRequestInfo(ctx context.Context, ip, userAgent string) context.Context {
|
|
ctx = context.WithValue(ctx, ipKey, ip)
|
|
ctx = context.WithValue(ctx, userAgentKey, userAgent)
|
|
return ctx
|
|
}
|
|
|
|
func IPFromContext(ctx context.Context) *string {
|
|
if v, ok := ctx.Value(ipKey).(string); ok && v != "" {
|
|
return &v
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func UserAgentFromContext(ctx context.Context) *string {
|
|
if v, ok := ctx.Value(userAgentKey).(string); ok && v != "" {
|
|
return &v
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func ContextWithUserRole(ctx context.Context, role string) context.Context {
|
|
return context.WithValue(ctx, userRoleKey, role)
|
|
}
|
|
|
|
func UserRoleFromContext(ctx context.Context) string {
|
|
role, _ := ctx.Value(userRoleKey).(string)
|
|
return role
|
|
}
|