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.)
This commit is contained in:
Adam Kelly
2020-06-01 19:54:08 +01:00
parent 4d6ecafcf4
commit 92a669ffaf
6 changed files with 72 additions and 1 deletions

19
fedireads/models/site.py Normal file
View File

@ -0,0 +1,19 @@
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