Initial public commit
Daybook: a self-hosted, multi-user Django + DRF app where agents, scripts, or people publish artifacts and each logged-in user browses their own time-ordered, label-filterable feed. This squashes prior local development history (kept privately on a separate branch) into a single clean starting point for the public repository. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
commit
940a703cd7
62 changed files with 5755 additions and 0 deletions
43
artifacts/migrations/0010_backfill_sizes_and_profiles.py
Normal file
43
artifacts/migrations/0010_backfill_sizes_and_profiles.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
from pathlib import Path
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def backfill(apps, schema_editor):
|
||||
Artifact = apps.get_model("artifacts", "Artifact")
|
||||
User = apps.get_model("auth", "User")
|
||||
UserProfile = apps.get_model("artifacts", "UserProfile")
|
||||
|
||||
root = Path(settings.ARTIFACTS_ROOT)
|
||||
for artifact in Artifact.objects.all():
|
||||
total = 0
|
||||
primary = root / artifact.path
|
||||
if primary.exists():
|
||||
total += primary.stat().st_size
|
||||
if artifact.kind == "markdown":
|
||||
sidecar = primary.with_suffix(".md")
|
||||
if sidecar.exists():
|
||||
total += sidecar.stat().st_size
|
||||
if artifact.size_bytes != total:
|
||||
artifact.size_bytes = total
|
||||
artifact.save(update_fields=["size_bytes"])
|
||||
|
||||
default_quota = 1024 * 1024 * 1024 # 1 GB
|
||||
for user in User.objects.all():
|
||||
UserProfile.objects.get_or_create(user=user, defaults={"quota_bytes": default_quota})
|
||||
|
||||
|
||||
def noop_reverse(apps, schema_editor):
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("artifacts", "0009_quota_and_keep"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(backfill, noop_reverse),
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue