Show federated servers and connectors in admin

This commit is contained in:
Mouse Reeve 2020-10-31 12:45:39 -07:00
parent 7f2f8c53d6
commit 02265b1e49
4 changed files with 58 additions and 10 deletions

View file

@ -4,3 +4,5 @@ from bookwyrm import models
admin.site.register(models.SiteSettings)
admin.site.register(models.User)
admin.site.register(models.FederatedServer)
admin.site.register(models.Connector)

View file

@ -0,0 +1,38 @@
# Generated by Django 3.0.7 on 2020-10-31 19:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('bookwyrm', '0061_auto_20201030_2157'),
]
operations = [
migrations.AlterField(
model_name='connector',
name='api_key',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='connector',
name='max_query_count',
field=models.IntegerField(blank=True, null=True),
),
migrations.AlterField(
model_name='connector',
name='name',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AlterField(
model_name='connector',
name='politeness_delay',
field=models.IntegerField(blank=True, null=True),
),
migrations.AlterField(
model_name='connector',
name='search_url',
field=models.CharField(blank=True, max_length=255, null=True),
),
]

View file

@ -10,25 +10,25 @@ class Connector(BookWyrmModel):
''' book data source connectors '''
identifier = models.CharField(max_length=255, unique=True)
priority = models.IntegerField(default=2)
name = models.CharField(max_length=255, null=True)
name = models.CharField(max_length=255, null=True, blank=True)
local = models.BooleanField(default=False)
connector_file = models.CharField(
max_length=255,
choices=ConnectorFiles.choices
)
api_key = models.CharField(max_length=255, null=True)
api_key = models.CharField(max_length=255, null=True, blank=True)
base_url = models.CharField(max_length=255)
books_url = models.CharField(max_length=255)
covers_url = models.CharField(max_length=255)
search_url = models.CharField(max_length=255, null=True)
search_url = models.CharField(max_length=255, null=True, blank=True)
politeness_delay = models.IntegerField(null=True) #seconds
max_query_count = models.IntegerField(null=True)
politeness_delay = models.IntegerField(null=True, blank=True) #seconds
max_query_count = models.IntegerField(null=True, blank=True)
# how many queries executed in a unit of time, like a day
query_count = models.IntegerField(default=0)
# when to reset the query count back to 0 (ie, after 1 day)
query_count_expiry = models.DateTimeField(auto_now_add=True)
query_count_expiry = models.DateTimeField(auto_now_add=True, blank=True)
class Meta:
''' check that there's code to actually use this connector '''
@ -38,3 +38,9 @@ class Connector(BookWyrmModel):
name='connector_file_valid'
)
]
def __str__(self):
return "{} ({})".format(
self.identifier,
self.id,
)

View file

@ -3,14 +3,16 @@
<div class="columns">
<div class="column block">
{% include 'snippets/about.html' with site_settings=site_settings %}
<blockquote>
{% include 'snippets/about.html' with site_settings=site_settings %}
</blockquote>
</div>
<div class="column block">
<h2 class="title">Code of Conduct</h2>
<p>
{{ site_settings.code_of_conduct }}
</p>
<blockquote>
{{ site_settings.code_of_conduct }}
</blockquote>
</div>
</div>
{% endblock %}