User generated local paths

This commit is contained in:
Mouse Reeve
2020-12-30 17:36:35 -08:00
parent d821a08cff
commit dc68fdd53e
14 changed files with 50 additions and 38 deletions

View File

@ -35,6 +35,11 @@ class BookWyrmModel(models.Model):
''' this is just here to provide default fields for other models '''
abstract = True
@property
def local_path(self):
''' how to link to this object in the local app '''
return self.get_remote_id().replace('https://%s' % DOMAIN, '')
@receiver(models.signals.post_save)
#pylint: disable=unused-argument

View File

@ -179,6 +179,11 @@ class User(OrderedCollectionPageMixin, AbstractUser):
return super().save(*args, **kwargs)
@property
def local_path(self):
''' this model doesn't inherit bookwyrm model, so here we are '''
return '/user/%s' % (self.localname or self.username)
class KeyPair(ActivitypubMixin, BookWyrmModel):
''' public and private keys for a user '''