Merge branch 'main' into production

This commit is contained in:
Mouse Reeve 2021-04-02 10:09:33 -07:00
commit c50edc9d3f
4 changed files with 40 additions and 24 deletions

View file

@ -21,9 +21,9 @@ class Person(ActivityObject):
preferredUsername: str preferredUsername: str
inbox: str inbox: str
outbox: str
followers: str
publicKey: PublicKey publicKey: PublicKey
followers: str = None
outbox: str = None
endpoints: Dict = None endpoints: Dict = None
name: str = None name: str = None
summary: str = None summary: str = None

View file

@ -0,0 +1,24 @@
# Generated by Django 3.1.6 on 2021-04-02 14:35
import bookwyrm.models.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0060_siteinvite_invitees"),
]
operations = [
migrations.AlterField(
model_name="user",
name="outbox",
field=bookwyrm.models.fields.RemoteIdField(
max_length=255,
null=True,
unique=True,
validators=[bookwyrm.models.fields.validate_remote_id],
),
),
]

View file

@ -50,7 +50,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
null=True, null=True,
blank=True, blank=True,
) )
outbox = fields.RemoteIdField(unique=True) outbox = fields.RemoteIdField(unique=True, null=True)
summary = fields.HtmlField(null=True, blank=True) summary = fields.HtmlField(null=True, blank=True)
local = models.BooleanField(default=False) local = models.BooleanField(default=False)
bookwyrm_user = fields.BooleanField(default=True) bookwyrm_user = fields.BooleanField(default=True)
@ -182,10 +182,10 @@ class User(OrderedCollectionPageMixin, AbstractUser):
**kwargs **kwargs
) )
def to_activity(self): def to_activity(self, **kwargs):
"""override default AP serializer to add context object """override default AP serializer to add context object
idk if this is the best way to go about this""" idk if this is the best way to go about this"""
activity_object = super().to_activity() activity_object = super().to_activity(**kwargs)
activity_object["@context"] = [ activity_object["@context"] = [
"https://www.w3.org/ns/activitystreams", "https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1", "https://w3id.org/security/v1",
@ -293,10 +293,10 @@ class KeyPair(ActivitypubMixin, BookWyrmModel):
self.private_key, self.public_key = create_key_pair() self.private_key, self.public_key = create_key_pair()
return super().save(*args, **kwargs) return super().save(*args, **kwargs)
def to_activity(self): def to_activity(self, **kwargs):
"""override default AP serializer to add context object """override default AP serializer to add context object
idk if this is the best way to go about this""" idk if this is the best way to go about this"""
activity_object = super().to_activity() activity_object = super().to_activity(**kwargs)
del activity_object["@context"] del activity_object["@context"]
del activity_object["type"] del activity_object["type"]
return activity_object return activity_object
@ -360,7 +360,7 @@ def set_remote_server(user_id):
actor_parts = urlparse(user.remote_id) actor_parts = urlparse(user.remote_id)
user.federated_server = get_or_create_remote_server(actor_parts.netloc) user.federated_server = get_or_create_remote_server(actor_parts.netloc)
user.save(broadcast=False) user.save(broadcast=False)
if user.bookwyrm_user: if user.bookwyrm_user and user.outbox:
get_remote_reviews.delay(user.outbox) get_remote_reviews.delay(user.outbox)

View file

@ -1,20 +1,12 @@
{% load i18n %} {% load i18n %}
<nav class="pagination" aria-label="pagination"> <nav class="pagination" aria-label="pagination">
{% if page.has_previous %} <a class="pagination-previous" {% if page.has_previous %}href="{{ path }}?{% for k, v in request.GET.items %}{% if k != 'page' %}{{ k }}={{ v }}&{% endif %}{% endfor %}page={{ page.previous_page_number }}{{ anchor }}" {% else %}disabled{% endif %}>
<p class="pagination-previous"> <span class="icon icon-arrow-left"></span>
<a href="{{ path }}?{% for k, v in request.GET.items %}{% if k != 'page' %}{{ k }}={{ v }}&{% endif %}{% endfor %}page={{ page.previous_page_number }}{{ anchor }}"> {% trans "Previous" %}
<span class="icon icon-arrow-left"></span> </a>
{% trans "Previous" %}
</a>
</p>
{% endif %}
{% if page.has_next %} <a class="pagination-next" {% if page.has_next %}href="{{ path }}?{% for k, v in request.GET.items %}{% if k != 'page' %}{{ k }}={{ v }}&{% endif %}{% endfor %}page={{ page.next_page_number }}{{ anchor }}"{% else %} disabled{% endif %}>
<p class="pagination-next"> {% trans "Next" %}
<a href="{{ path }}?{% for k, v in request.GET.items %}{% if k != 'page' %}{{ k }}={{ v }}&{% endif %}{% endfor %}page={{ page.next_page_number }}{{ anchor }}"> <span class="icon icon-arrow-right"></span>
{% trans "Next" %} </a>
<span class="icon icon-arrow-right"></span>
</a>
</p>
{% endif %}
</nav> </nav>