from django.db import models class SiteSettings(models.Model): """Singleton row (pk=1, same pattern as accounts.SetupLock) holding instance-wide configuration an operator reasonably wants to change without touching the server or .env — editable via Django admin. Currently just the feed-poll interval, which used to be a per-feed field; it's site-wide now (see apps.feeds.tasks.poll_due_feeds). """ id = models.PositiveSmallIntegerField(primary_key=True, default=1) fetch_interval_minutes = models.PositiveIntegerField( default=60, help_text=( "How often, in minutes, every feed is polled for new articles. " "Can't be set lower than EVECTION_MIN_FETCH_INTERVAL_MINUTES (see .env)." ), ) class Meta: verbose_name = "Site settings" verbose_name_plural = "Site settings" def __str__(self): return "Site settings" @classmethod def load(cls): """Returns the singleton row, creating it with defaults on first use so callers never need to special-case "no row exists yet" (e.g. a fresh install whose first poll_due_feeds run hasn't created it, and whose admin hasn't visited the settings page).""" obj, _ = cls.objects.get_or_create(pk=1) return obj