mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-14 12:16:31 +00:00
Merge branch 'main' into production
This commit is contained in:
commit
2b75fd1f14
8 changed files with 67 additions and 16 deletions
|
@ -2,6 +2,8 @@
|
|||
from dataclasses import dataclass, fields, MISSING
|
||||
from json import JSONEncoder
|
||||
|
||||
from bookwyrm import books_manager, models
|
||||
|
||||
from django.db.models.fields.related_descriptors \
|
||||
import ForwardManyToOneDescriptor
|
||||
|
||||
|
@ -102,6 +104,9 @@ class ActivityObject:
|
|||
|
||||
def resolve_foreign_key(model, remote_id):
|
||||
''' look up the remote_id on an activity json field '''
|
||||
if model in [models.Edition, models.Work]:
|
||||
return books_manager.get_or_create_book(remote_id)
|
||||
|
||||
result = model.objects
|
||||
if hasattr(model.objects, 'select_subclasses'):
|
||||
result = result.select_subclasses()
|
||||
|
|
|
@ -16,7 +16,7 @@ class Person(ActivityObject):
|
|||
publicKey: PublicKey
|
||||
endpoints: Dict
|
||||
icon: Image = field(default=lambda: {})
|
||||
bookwyrmUser: str = False
|
||||
bookwyrmUser: bool = False
|
||||
manuallyApprovesFollowers: str = False
|
||||
discoverable: str = True
|
||||
type: str = 'Person'
|
||||
|
|
|
@ -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)
|
||||
|
|
38
bookwyrm/migrations/0062_auto_20201031_1936.py
Normal file
38
bookwyrm/migrations/0062_auto_20201031_1936.py
Normal 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),
|
||||
),
|
||||
]
|
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -82,12 +82,9 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
|||
''' send default icon if one isn't set '''
|
||||
if self.avatar:
|
||||
url = self.avatar.url
|
||||
# TODO not the right way to get the media type
|
||||
media_type = 'image/%s' % url.split('.')[-1]
|
||||
else:
|
||||
url = 'https://%s/static/images/default_avi.jpg' % DOMAIN
|
||||
media_type = 'image/jpeg'
|
||||
return activitypub.Image(media_type, url, 'Image')
|
||||
return activitypub.Image(url=url)
|
||||
|
||||
@property
|
||||
def ap_public_key(self):
|
||||
|
@ -106,6 +103,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
|||
activity_formatter=lambda x: x.split('@')[0]
|
||||
),
|
||||
ActivityMapping('name', 'name'),
|
||||
ActivityMapping('bookwyrmUser', 'bookwyrm_user'),
|
||||
ActivityMapping('inbox', 'inbox'),
|
||||
ActivityMapping('outbox', 'outbox'),
|
||||
ActivityMapping('followers', 'ap_followers'),
|
||||
|
|
|
@ -108,7 +108,7 @@ input.toggle-control:checked ~ .toggle-content {
|
|||
position: absolute;
|
||||
}
|
||||
.quote blockquote:before {
|
||||
content: "\e904";
|
||||
content: "\e905";
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
|
|
@ -3,14 +3,16 @@
|
|||
|
||||
<div class="columns">
|
||||
<div class="column block">
|
||||
<blockquote>
|
||||
{% include 'snippets/about.html' with site_settings=site_settings %}
|
||||
</blockquote>
|
||||
</div>
|
||||
|
||||
<div class="column block">
|
||||
<h2 class="title">Code of Conduct</h2>
|
||||
<p>
|
||||
<blockquote>
|
||||
{{ site_settings.code_of_conduct }}
|
||||
</p>
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue