2021-03-08 16:49:10 +00:00
|
|
|
""" manages interfaces with external sources of book data """
|
2020-09-17 20:09:11 +00:00
|
|
|
from django.db import models
|
2020-09-21 15:10:37 +00:00
|
|
|
from bookwyrm.connectors.settings import CONNECTORS
|
2020-09-17 20:09:11 +00:00
|
|
|
|
2021-05-11 18:31:02 +00:00
|
|
|
from .base_model import BookWyrmModel, DeactivationReason
|
2020-09-17 20:09:11 +00:00
|
|
|
|
|
|
|
|
2021-03-08 16:49:10 +00:00
|
|
|
ConnectorFiles = models.TextChoices("ConnectorFiles", CONNECTORS)
|
|
|
|
|
|
|
|
|
2020-09-21 15:16:34 +00:00
|
|
|
class Connector(BookWyrmModel):
|
2021-04-26 16:15:42 +00:00
|
|
|
"""book data source connectors"""
|
2021-03-08 16:49:10 +00:00
|
|
|
|
2020-09-17 20:09:11 +00:00
|
|
|
identifier = models.CharField(max_length=255, unique=True)
|
|
|
|
priority = models.IntegerField(default=2)
|
2020-10-31 19:45:39 +00:00
|
|
|
name = models.CharField(max_length=255, null=True, blank=True)
|
2020-09-17 20:09:11 +00:00
|
|
|
local = models.BooleanField(default=False)
|
2021-03-08 16:49:10 +00:00
|
|
|
connector_file = models.CharField(max_length=255, choices=ConnectorFiles.choices)
|
2020-10-31 19:45:39 +00:00
|
|
|
api_key = models.CharField(max_length=255, null=True, blank=True)
|
2021-05-11 16:54:04 +00:00
|
|
|
active = models.BooleanField(default=True)
|
2021-05-11 18:31:02 +00:00
|
|
|
deactivation_reason = models.CharField(
|
|
|
|
max_length=255, choices=DeactivationReason.choices, null=True, blank=True
|
|
|
|
)
|
2020-09-17 20:09:11 +00:00
|
|
|
|
|
|
|
base_url = models.CharField(max_length=255)
|
|
|
|
books_url = models.CharField(max_length=255)
|
|
|
|
covers_url = models.CharField(max_length=255)
|
2020-10-31 19:45:39 +00:00
|
|
|
search_url = models.CharField(max_length=255, null=True, blank=True)
|
2021-03-01 20:09:21 +00:00
|
|
|
isbn_search_url = models.CharField(max_length=255, null=True, blank=True)
|
2020-09-17 20:09:11 +00:00
|
|
|
|
2020-10-31 19:45:39 +00:00
|
|
|
def __str__(self):
|
|
|
|
return "{} ({})".format(
|
|
|
|
self.identifier,
|
|
|
|
self.id,
|
|
|
|
)
|