Updates instance info endpoint

This commit is contained in:
Mouse Reeve 2021-09-10 11:44:01 -07:00
parent 9de6407e5f
commit 9413dacaf2
3 changed files with 26 additions and 4 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 3.2.4 on 2021-09-10 18:39
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0091_merge_0090_auto_20210908_2346_0090_emailblocklist"),
]
operations = [
migrations.AddField(
model_name="sitesettings",
name="instance_short_description",
field=models.TextField(blank=True, null=True),
),
]

View file

@ -20,6 +20,7 @@ class SiteSettings(models.Model):
max_length=150, default="Social Reading and Reviewing"
)
instance_description = models.TextField(default="This instance has no description.")
instance_short_description = models.TextField(blank=True, null=True)
# about page
registration_closed_text = models.TextField(

View file

@ -8,7 +8,7 @@ from django.utils import timezone
from django.views.decorators.http import require_GET
from bookwyrm import models
from bookwyrm.settings import DOMAIN, VERSION
from bookwyrm.settings import DOMAIN, VERSION, MEDIA_FULL_URL
@require_GET
@ -95,21 +95,24 @@ def instance_info(_):
status_count = models.Status.objects.filter(user__local=True).count()
site = models.SiteSettings.get()
logo_path = site.logo_small or "images/logo-small.png"
logo = f"{MEDIA_FULL_URL}{logo_path}"
return JsonResponse(
{
"uri": DOMAIN,
"title": site.name,
"short_description": "",
"short_description": site.instance_short_description,
"description": site.instance_description,
"version": "0.0.1",
"version": VERSION,
"stats": {
"user_count": user_count,
"status_count": status_count,
},
"thumbnail": "https://%s/static/images/logo.png" % DOMAIN,
"thumbnail": logo,
"languages": ["en"],
"registrations": site.allow_registration,
"approval_required": False,
"email": site.admin_email,
}
)