Skip to content

Latest commit

 

History

History
487 lines (374 loc) · 19.8 KB

File metadata and controls

487 lines (374 loc) · 19.8 KB

Models Reference

23 models found.

Organization

Tenant model for multi-tenancy.

Inherits: models.Model

Ordering: [name]

Field Type Constraints Description
id models.UUIDField unique, default: uuid.uuid4
name models.CharField max_length=255
slug models.SlugField unique, max_length=100
is_active models.BooleanField default: True
settings models.JSONField default: dict
created_at models.DateTimeField
updated_at models.DateTimeField

Membership

User membership in an organization.

Inherits: models.Model

Field Type Constraints Description
user models.ForeignKey
organization models.ForeignKey
role models.CharField default: Role.MEMBER, max_length=20, choices: Role.choices
is_active models.BooleanField default: True
created_at models.DateTimeField

TenantAwareModel

Abstract base model for tenant-aware models.

Inherits: models.Model

Field Type Constraints Description
org models.ForeignKey

Presentation

A PowerPoint presentation.

Inherits: TenantAwareModel

Ordering: [-created_at]

Field Type Constraints Description
id models.UUIDField unique, default: uuid.uuid4
title models.CharField max_length=255
description models.TextField
status models.CharField default: Status.UPLOADED, max_length=20, choices: Status.choices
source_language models.CharField max_length=10
target_language models.CharField max_length=10
slide_count models.PositiveIntegerField default: 0
word_count models.PositiveIntegerField default: 0
original_filename models.CharField max_length=255
metadata models.JSONField default: dict
created_at models.DateTimeField
updated_at models.DateTimeField
created_by models.ForeignKey nullable

PresentationFile

A file associated with a presentation.

Inherits: models.Model

Ordering: [-created_at]

Field Type Constraints Description
id models.UUIDField unique, default: uuid.uuid4
presentation models.ForeignKey
file_type models.CharField max_length=20, choices: FileType.choices
version models.PositiveSmallIntegerField default: 1
is_current models.BooleanField default: True
storage_backend models.CharField default: local, max_length=20
storage_path models.CharField max_length=500
original_filename models.CharField max_length=255
mime_type models.CharField default: application/octet-stream, max_length=100
file_size models.PositiveBigIntegerField nullable
checksum_sha256 models.CharField max_length=64
created_at models.DateTimeField

ProcessingJob

An async processing job.

Inherits: TenantAwareModel

Ordering: [-priority, created_at]

Field Type Constraints Description
id models.UUIDField unique, default: uuid.uuid4
job_type models.CharField max_length=20, choices: JobType.choices
presentation models.ForeignKey
status models.CharField default: Status.PENDING, max_length=20, choices: Status.choices
priority models.PositiveSmallIntegerField default: 5
progress models.PositiveSmallIntegerField default: 0
progress_message models.CharField max_length=255
input_snapshot models.JSONField default: dict
options models.JSONField default: dict
result_data models.JSONField default: dict
error_message models.TextField
attempt_count models.PositiveSmallIntegerField default: 0
max_attempts models.PositiveSmallIntegerField default: 3
task_id models.CharField indexed, max_length=100
created_at models.DateTimeField
updated_at models.DateTimeField
started_at models.DateTimeField nullable
completed_at models.DateTimeField nullable
created_by models.ForeignKey nullable

JobAttempt

A single execution attempt of a job.

Inherits: models.Model

Ordering: [job, attempt_number]

Field Type Constraints Description
job models.ForeignKey
attempt_number models.PositiveSmallIntegerField
status models.CharField max_length=20, choices: [..., ..., ...]
started_at models.DateTimeField
completed_at models.DateTimeField nullable
duration_ms models.PositiveIntegerField nullable
result_data models.JSONField default: dict
error_message models.TextField
error_traceback models.TextField

LookupDomain

Inherits: models.Model

Field Type Constraints Description
code models.CharField unique, max_length=50
name models.CharField max_length=100
name_de models.CharField max_length=100
description models.TextField
is_active models.BooleanField default: True
created_at models.DateTimeField
updated_at models.DateTimeField

LookupChoice

Inherits: models.Model

Field Type Constraints Description
domain models.ForeignKey
code models.CharField max_length=50
name models.CharField max_length=100
name_de models.CharField max_length=100
description models.TextField
sort_order models.IntegerField default: 0
color models.CharField max_length=7
icon models.CharField max_length=50
metadata models.JSONField default: dict
is_active models.BooleanField default: True
created_at models.DateTimeField
updated_at models.DateTimeField

BusinessCase

Inherits: models.Model

Ordering: [-created_at]

Field Type Constraints Description
code models.CharField unique, max_length=20
title models.CharField max_length=200
category models.ForeignKey
status models.ForeignKey
priority models.ForeignKey nullable
problem_statement models.TextField
target_audience models.TextField
expected_benefits models.JSONField default: list
scope models.TextField
out_of_scope models.JSONField default: list
success_criteria models.JSONField default: list
assumptions models.JSONField default: list
risks models.JSONField default: list
requires_adr models.BooleanField default: False
adr_reason models.TextField
owner_id models.IntegerField nullable
created_at models.DateTimeField
updated_at models.DateTimeField

UseCase

Inherits: models.Model

Ordering: [business_case, code]

Field Type Constraints Description
code models.CharField unique, max_length=20
title models.CharField max_length=200
business_case models.ForeignKey
status models.ForeignKey
priority models.ForeignKey nullable
actor models.CharField max_length=100
preconditions models.JSONField default: list
postconditions models.JSONField default: list
main_flow models.JSONField default: list
alternative_flows models.JSONField default: list
exception_flows models.JSONField default: list
complexity models.ForeignKey nullable
estimated_effort models.CharField max_length=50
created_at models.DateTimeField
updated_at models.DateTimeField

LLMProvider

Global LLM provider (shared across tenants).

Inherits: models.Model

Verbose name: LLM Provider Ordering: [name]

Field Type Constraints Description
name models.CharField unique, max_length=50 Provider-Identifier, z.B. "openai", "anthropic", "groq".
display_name models.CharField max_length=100
api_key_env_var models.CharField max_length=100 Env-Var Name, z.B. OPENAI_API_KEY. Wird via read_secret() aufgelöst (ADR-045).
base_url models.URLField Custom endpoint URL. Leer = Provider-Default.
is_active models.BooleanField indexed, default: True

LLMModel

Global LLM model (shared across tenants).

Inherits: models.Model

Verbose name: LLM Model Ordering: [provider__name, name]

Field Type Constraints Description
provider models.ForeignKey
name models.CharField max_length=100 Model-ID beim Provider, z.B. "gpt-4o", "claude-sonnet-4".
display_name models.CharField max_length=150
max_tokens models.IntegerField default: 4096
context_window models.IntegerField default: 128000 Max context window in tokens.
supports_vision models.BooleanField default: False
supports_tools models.BooleanField default: True
input_cost_per_million models.DecimalField default: 0 USD per 1M input tokens.
output_cost_per_million models.DecimalField default: 0 USD per 1M output tokens.
is_active models.BooleanField indexed, default: True
is_default models.BooleanField default: False Markierung für init_llm_config Seed-Daten. Wird NICHT als stiller Fallback genutzt.

AIActionType

Per-action LLM routing — tenant-specific (ADR-056).

Inherits: models.Model

Verbose name: AI Action Type

Field Type Constraints Description
tenant_id models.UUIDField indexed Tenant-ID (ADR-056). Pflicht für Multi-Tenancy.
code models.CharField max_length=50 Eindeutiger Action-Code pro Tenant, z.B. 'character_generation', 'hazard_analysis'.
name models.CharField max_length=100
description models.TextField
default_model models.ForeignKey nullable Pflicht für aktive Actions. Ohne Model → LLMConfigurationError.
fallback_model models.ForeignKey nullable Fallback wenn default_model fehlschlägt.
max_tokens models.IntegerField default: 2000
temperature models.FloatField default: 0.7
is_active models.BooleanField indexed, default: True

AIUsageLog

LLM usage tracking — tenant-specific (ADR-056).

Inherits: models.Model

Verbose name: AI Usage Log Ordering: [-created_at]

Field Type Constraints Description
tenant_id models.UUIDField indexed Tenant-ID für Cost-Zuordnung.
action_type models.ForeignKey nullable
model_used models.ForeignKey nullable
user models.ForeignKey nullable
input_tokens models.IntegerField default: 0
output_tokens models.IntegerField default: 0
total_tokens models.IntegerField default: 0
estimated_cost models.DecimalField default: 0
latency_ms models.IntegerField default: 0
success models.BooleanField default: True
error_message models.TextField
created_at models.DateTimeField

ContentItem

KI-generierter Inhalt — plattformweit, tenant-isoliert.

Inherits: models.Model

Verbose name: _(...) Ordering: [-created_at]

Field Type Constraints Description
tenant_id models.BigIntegerField indexed _(...)
source models.CharField max_length=30, choices: ContentSource.choices
type models.CharField max_length=30, choices: ContentType.choices
ref_id models.CharField max_length=255 _(...)
content models.TextField
sha256 models.CharField max_length=64 _(...)
version models.PositiveIntegerField default: 1
meta models.JSONField default: dict
model_used models.CharField max_length=100 _(...)
prompt_key models.CharField max_length=200
created_at models.DateTimeField
updated_at models.DateTimeField

ContentRelation

Beziehung zwischen zwei ContentItems.

Inherits: models.Model

Verbose name: _(...)

Field Type Constraints Description
source_item models.ForeignKey
target_item models.ForeignKey
relation_type models.CharField max_length=50 _(...)
created_at models.DateTimeField

AdrCompliance

ADR Drift-Detector Compliance-Ergebnis — tenant-isoliert.

Inherits: models.Model

Verbose name: _(...) Ordering: [-checked_at]

Field Type Constraints Description
tenant_id models.BigIntegerField indexed
adr_id models.CharField max_length=20
checked_at models.DateTimeField
drift_score models.FloatField
status models.CharField max_length=20, choices: ComplianceStatus.choices
details models.JSONField default: dict

Organization

Tenant organization with lifecycle management.

Inherits: models.Model

Field Type Constraints Description
id models.UUIDField unique, default: uuid.uuid4
tenant_id models.UUIDField unique, indexed, default: uuid.uuid4
slug models.SlugField unique, max_length=63
name models.CharField max_length=200
status models.CharField default: Status.TRIAL, max_length=20, choices: Status.choices
plan_code models.CharField default: free, max_length=50
trial_ends_at models.DateTimeField nullable
suspended_at models.DateTimeField nullable
suspended_reason models.TextField
deleted_at models.DateTimeField nullable
settings models.JSONField default: dict
created_at models.DateTimeField
updated_at models.DateTimeField

Membership

Maps a user to an organization with a role.

Inherits: models.Model

Field Type Constraints Description
id models.UUIDField unique, default: uuid.uuid4
tenant_id models.UUIDField indexed
organization models.ForeignKey
user models.ForeignKey
role models.CharField default: Role.MEMBER, max_length=20, choices: Role.choices
invited_by models.ForeignKey nullable
invited_at models.DateTimeField nullable
accepted_at models.DateTimeField nullable
created_at models.DateTimeField
updated_at models.DateTimeField

DocumentTemplate

Wiederverwendbare Dokumentvorlage (modulübergreifend).

Inherits: models.Model

Verbose name: Dokumentvorlage Ordering: [-updated_at]

Field Type Constraints Description
uuid models.UUIDField unique, default: uuid.uuid4
tenant_id models.UUIDField indexed
name models.CharField max_length=255
description models.TextField
scope models.CharField max_length=50 Fachbereich, z.B. explosionsschutz, brandschutz, gbu, risk
structure_json models.TextField default: {"sections": []} Template-Struktur als JSON
status models.CharField default: Status.DRAFT, max_length=20, choices: Status.choices
source_filename models.CharField max_length=255
source_text models.TextField
created_at models.DateTimeField
updated_at models.DateTimeField

DocumentInstance

Ausgefülltes Dokument basierend auf einem Template.

Inherits: models.Model

Verbose name: Dokument Ordering: [-updated_at]

Field Type Constraints Description
uuid models.UUIDField unique, default: uuid.uuid4
tenant_id models.UUIDField indexed
template models.ForeignKey
name models.CharField max_length=255
values_json models.TextField default: {} Ausgefüllte Werte als JSON
status models.CharField default: Status.DRAFT, max_length=20, choices: Status.choices
source_filename models.CharField max_length=255 Dateiname des importierten Dokuments
created_at models.DateTimeField
updated_at models.DateTimeField

NotificationLog

Audit log for all notifications.

Inherits: models.Model

Ordering: [-created_at]

Field Type Constraints Description
tenant_id models.CharField indexed, max_length=64
channel models.CharField max_length=50
recipient models.CharField max_length=255
subject models.CharField max_length=255
body models.TextField
source_app models.CharField max_length=50
source_event models.CharField max_length=100
metadata models.JSONField default: dict
status models.CharField default: Status.PENDING, max_length=20, choices: Status.choices
retry_count models.PositiveIntegerField default: 0
error_message models.TextField
created_at models.DateTimeField
updated_at models.DateTimeField
sent_at models.DateTimeField nullable