first commit
This commit is contained in:
commit
b54624be96
226 files changed
+108840
No files matched your search
@@ -0,0 +1,47 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
|
||||
|
||||
class CitySite(models.Model):
|
||||
"""
|
||||
Registry of a city dashboard-cpsp deployment that HQ can mirror from.
|
||||
|
||||
Outbound API key is stored here for local/dev scaffolding. Prefer a secret
|
||||
manager or encrypted field before production.
|
||||
"""
|
||||
|
||||
city_site_id = models.BigAutoField(primary_key=True)
|
||||
code = models.SlugField(max_length=64, unique=True, help_text="Stable id, e.g. sukawarna")
|
||||
name = models.CharField(max_length=120)
|
||||
api_base_url = models.URLField(
|
||||
max_length=255,
|
||||
help_text="City API root including /api/v1, e.g. https://site.example/api/v1",
|
||||
)
|
||||
api_key = models.CharField(
|
||||
max_length=255,
|
||||
blank=True,
|
||||
help_text="X-API-Key for pulling from the city API (keep server-side only)",
|
||||
)
|
||||
registered_by = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
null=True,
|
||||
blank=True,
|
||||
on_delete=models.SET_NULL,
|
||||
related_name="registered_city_sites",
|
||||
help_text="GM / GM Admin who added this city dashboard URL",
|
||||
)
|
||||
is_active = models.BooleanField(default=True)
|
||||
last_synced_at = models.DateTimeField(null=True, blank=True)
|
||||
last_sync_status = models.CharField(max_length=32, blank=True, default="")
|
||||
last_sync_message = models.TextField(blank=True, default="")
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "city_sites"
|
||||
ordering = ["name"]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.name} ({self.code})"
|
||||
Reference in new issue
Block a user