forked from mirrors/bookwyrm
Don't let author and book remote ids get overridden
This commit is contained in:
parent
23cbeab4c1
commit
3597ca460c
2 changed files with 5 additions and 7 deletions
|
@ -28,11 +28,10 @@ class Author(ActivitypubMixin, BookWyrmModel):
|
||||||
bio = fields.HtmlField(null=True, blank=True)
|
bio = fields.HtmlField(null=True, blank=True)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
''' can't be abstract for query reasons, but you shouldn't USE it '''
|
''' handle remote vs origin ids '''
|
||||||
if self.id and not self.remote_id:
|
if self.id:
|
||||||
self.remote_id = self.get_remote_id()
|
self.remote_id = self.get_remote_id()
|
||||||
|
else:
|
||||||
if not self.id:
|
|
||||||
self.origin_id = self.remote_id
|
self.origin_id = self.remote_id
|
||||||
self.remote_id = None
|
self.remote_id = None
|
||||||
return super().save(*args, **kwargs)
|
return super().save(*args, **kwargs)
|
||||||
|
|
|
@ -83,10 +83,9 @@ class Book(ActivitypubMixin, BookWyrmModel):
|
||||||
if not isinstance(self, Edition) and not isinstance(self, Work):
|
if not isinstance(self, Edition) and not isinstance(self, Work):
|
||||||
raise ValueError('Books should be added as Editions or Works')
|
raise ValueError('Books should be added as Editions or Works')
|
||||||
|
|
||||||
if self.id and not self.remote_id:
|
if self.id:
|
||||||
self.remote_id = self.get_remote_id()
|
self.remote_id = self.get_remote_id()
|
||||||
|
else:
|
||||||
if not self.id:
|
|
||||||
self.origin_id = self.remote_id
|
self.origin_id = self.remote_id
|
||||||
self.remote_id = None
|
self.remote_id = None
|
||||||
return super().save(*args, **kwargs)
|
return super().save(*args, **kwargs)
|
||||||
|
|
Loading…
Reference in a new issue