Files
cetana-backend/apps/core/models.py
T
2026-09-24 12:32:59 +03:30

45 lines
1.3 KiB
Python

import uuid
from django.db import models
class UUIDModel(models.Model):
"""Abstract model with a UUID primary key."""
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
class Meta:
abstract = True
class TimeStampedModel(models.Model):
"""Abstract model with created/updated timestamps."""
created_at = models.DateTimeField(auto_now_add=True, db_index=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
abstract = True
class SystemSetting(UUIDModel, TimeStampedModel):
"""Generic, dynamic runtime configuration (Odoo, SMS, payment, ...).
Settings are keyed by dotted path (e.g. ``odoo.url``) and stored as JSON
values. The schema that drives the settings panel lives in
``apps.core.settings_registry`` — adding a provider only requires adding
entries there, not schema changes.
"""
key = models.CharField(max_length=200, unique=True)
value = models.JSONField(default=dict, blank=True)
category = models.CharField(max_length=100, db_index=True, blank=True)
is_secret = models.BooleanField(default=False)
description = models.CharField(max_length=255, blank=True)
class Meta:
ordering = ["key"]
def __str__(self) -> str:
return self.key