bookwyrm/fedireads/models/site.py
Adam Kelly 92a669ffaf Add instance settings.
Addresses: #58

Currently implemented:

* Instance name
* Instance description
* Code of conduct
* Allow registration

I decided to store this in the database so that settings can be easily
changed at runtime through the web interface. (This web interface does
not exist.)
2020-06-01 19:54:08 +01:00

19 lines
651 B
Python

from django.db import models
from fedireads.settings import DOMAIN
class SiteSettings(models.Model):
name = models.CharField(default=DOMAIN, max_length=100)
instance_description = models.TextField(
default="This instance has no description.")
code_of_conduct = models.TextField(
default="Add a code of conduct here.")
allow_registration = models.BooleanField(default=True)
@classmethod
def get(cls):
try:
return cls.objects.get(id=1)
except cls.DoesNotExist:
default_settings = SiteSettings(id=1)
default_settings.save()
return default_settings