mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 08:36:32 +00:00
Removes unused connector fields and adds active boolean
This commit is contained in:
parent
9ea588b855
commit
e7c5b77b4c
4 changed files with 35 additions and 21 deletions
|
@ -102,13 +102,6 @@ class AbstractConnector(AbstractMinimalConnector):
|
|||
# title we handle separately.
|
||||
self.book_mappings = []
|
||||
|
||||
def is_available(self):
|
||||
"""check if you're allowed to use this connector"""
|
||||
if self.max_query_count is not None:
|
||||
if self.connector.query_count >= self.max_query_count:
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_or_create_book(self, remote_id):
|
||||
"""translate arbitrary json into an Activitypub dataclass"""
|
||||
# first, check if we have the origin_id saved
|
||||
|
|
34
bookwyrm/migrations/0074_auto_20210511_1651.py
Normal file
34
bookwyrm/migrations/0074_auto_20210511_1651.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
# Generated by Django 3.2 on 2021-05-11 16:51
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bookwyrm", "0073_sitesettings_footer_item"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name="connector",
|
||||
name="max_query_count",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="connector",
|
||||
name="politeness_delay",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="connector",
|
||||
name="query_count",
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="connector",
|
||||
name="query_count_expiry",
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="connector",
|
||||
name="active",
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
]
|
|
@ -17,6 +17,7 @@ class Connector(BookWyrmModel):
|
|||
local = models.BooleanField(default=False)
|
||||
connector_file = models.CharField(max_length=255, choices=ConnectorFiles.choices)
|
||||
api_key = models.CharField(max_length=255, null=True, blank=True)
|
||||
active = models.BooleanField(default=True)
|
||||
|
||||
base_url = models.CharField(max_length=255)
|
||||
books_url = models.CharField(max_length=255)
|
||||
|
@ -24,13 +25,6 @@ class Connector(BookWyrmModel):
|
|||
search_url = models.CharField(max_length=255, null=True, blank=True)
|
||||
isbn_search_url = models.CharField(max_length=255, null=True, blank=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, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return "{} ({})".format(
|
||||
self.identifier,
|
||||
|
|
|
@ -84,13 +84,6 @@ class AbstractConnector(TestCase):
|
|||
"""barebones connector for search with defaults"""
|
||||
self.assertIsInstance(self.connector.book_mappings, list)
|
||||
|
||||
def test_is_available(self):
|
||||
"""this isn't used...."""
|
||||
self.assertTrue(self.connector.is_available())
|
||||
self.connector.max_query_count = 1
|
||||
self.connector.connector.query_count = 2
|
||||
self.assertFalse(self.connector.is_available())
|
||||
|
||||
def test_get_or_create_book_existing(self):
|
||||
"""find an existing book by remote/origin id"""
|
||||
self.assertEqual(models.Book.objects.count(), 1)
|
||||
|
|
Loading…
Reference in a new issue