2
0
Fork 0
bookwyrm/bookwyrm/models/connector.py

32 lines
1.2 KiB
Python
Raw Normal View History

2021-03-08 08:49:10 -08:00
""" manages interfaces with external sources of book data """
2020-09-17 13:09:11 -07:00
from django.db import models
from bookwyrm.connectors.settings import CONNECTORS
2020-09-17 13:09:11 -07:00
from .base_model import BookWyrmModel, DeactivationReason
2020-09-17 13:09:11 -07:00
2021-03-08 08:49:10 -08:00
ConnectorFiles = models.TextChoices("ConnectorFiles", CONNECTORS)
2020-09-21 08:16:34 -07:00
class Connector(BookWyrmModel):
2021-04-26 09:15:42 -07:00
"""book data source connectors"""
2021-03-08 08:49:10 -08:00
identifier = models.CharField(max_length=255, unique=True) # domain
2020-09-17 13:09:11 -07:00
priority = models.IntegerField(default=2)
name = models.CharField(max_length=255, null=True, blank=True)
2021-03-08 08:49:10 -08:00
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)
deactivation_reason = models.CharField(
max_length=255, choices=DeactivationReason, null=True, blank=True
)
2020-09-17 13:09:11 -07:00
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, blank=True)
2021-03-01 21:09:21 +01:00
isbn_search_url = models.CharField(max_length=255, null=True, blank=True)
2020-09-17 13:09:11 -07:00
def __str__(self):
2021-09-18 11:32:00 -07:00
return f"{self.identifier} ({self.id})"