Preserve remote_id syntax for authors and books

This commit is contained in:
Mouse Reeve
2020-11-28 17:29:03 -08:00
parent 7ed2e310c0
commit 72c7829bab
5 changed files with 72 additions and 89 deletions

View File

@ -1,7 +1,4 @@
''' database schema for info about authors '''
from uuid import uuid4
import re
from django.db import models
from django.utils import timezone
@ -37,18 +34,13 @@ class Author(ActivitypubMixin, BookWyrmModel):
self.remote_id = self.get_remote_id()
if not self.id:
# force set the remote id to a local version
self.origin_id = self.remote_id
self.remote_id = self.get_remote_id()
self.remote_id = None
return super().save(*args, **kwargs)
def get_remote_id(self):
''' editions and works both use "book" instead of model_name '''
uuid = str(uuid4())[:8]
# in Book, the title is used to make the url more readable, but
# since an author's name can change, I didn't want to lock in a
# potential deadname (or maiden name) in the urk.
return 'https://%s/author/%s' % (DOMAIN, uuid)
return 'https://%s/author/%s' % (DOMAIN, self.id)
@property
def display_name(self):