mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
Fixes shelf remote ids
This commit is contained in:
parent
2d37d70606
commit
32bd426999
1 changed files with 9 additions and 4 deletions
|
@ -37,9 +37,13 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
|
||||||
""" set the identifier """
|
""" set the identifier """
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
if not self.identifier:
|
if not self.identifier:
|
||||||
|
self.identifier = self.get_identifier()
|
||||||
|
super().save(*args, **kwargs, broadcast=False)
|
||||||
|
|
||||||
|
def get_identifier(self):
|
||||||
|
""" custom-shelf-123 for the url """
|
||||||
slug = re.sub(r"[^\w]", "", self.name).lower()
|
slug = re.sub(r"[^\w]", "", self.name).lower()
|
||||||
self.identifier = "%s-%d" % (slug, self.id)
|
return "{:s}-{:d}".format(slug, self.id)
|
||||||
super().save(*args, **kwargs)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def collection_queryset(self):
|
def collection_queryset(self):
|
||||||
|
@ -49,7 +53,8 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
|
||||||
def get_remote_id(self):
|
def get_remote_id(self):
|
||||||
""" shelf identifier instead of id """
|
""" shelf identifier instead of id """
|
||||||
base_path = self.user.remote_id
|
base_path = self.user.remote_id
|
||||||
return "%s/books/%s" % (base_path, self.identifier)
|
identifier = self.identifier or self.get_identifier()
|
||||||
|
return "%s/books/%s" % (base_path, identifier)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
""" user/shelf unqiueness """
|
""" user/shelf unqiueness """
|
||||||
|
|
Loading…
Reference in a new issue