forked from mirrors/bookwyrm
Use activity type mixin
This commit is contained in:
parent
7381536ad6
commit
2ef777f87e
4 changed files with 9 additions and 9 deletions
|
@ -446,9 +446,8 @@ class CollectionItemMixin(ActivitypubMixin):
|
||||||
).serialize()
|
).serialize()
|
||||||
|
|
||||||
|
|
||||||
class ActivitybMixin(ActivitypubMixin):
|
class ActivityMixin(ActivitypubMixin):
|
||||||
''' add this mixin for models that are AP serializable '''
|
''' add this mixin for models that are AP serializable '''
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
''' broadcast activity '''
|
''' broadcast activity '''
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
|
@ -3,11 +3,11 @@ from django.db import models
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
from bookwyrm import activitypub
|
from bookwyrm import activitypub
|
||||||
from .activitypub_mixin import ActivitypubMixin
|
from .activitypub_mixin import ActivityMixin
|
||||||
from .base_model import BookWyrmModel
|
from .base_model import BookWyrmModel
|
||||||
from . import fields
|
from . import fields
|
||||||
|
|
||||||
class Favorite(ActivitypubMixin, BookWyrmModel):
|
class Favorite(ActivityMixin, BookWyrmModel):
|
||||||
''' fav'ing a post '''
|
''' fav'ing a post '''
|
||||||
user = fields.ForeignKey(
|
user = fields.ForeignKey(
|
||||||
'User', on_delete=models.PROTECT, activitypub_field='actor')
|
'User', on_delete=models.PROTECT, activitypub_field='actor')
|
||||||
|
|
|
@ -4,12 +4,12 @@ from django.db.models import Q
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
|
|
||||||
from bookwyrm import activitypub
|
from bookwyrm import activitypub
|
||||||
from .activitypub_mixin import ActivitypubMixin
|
from .activitypub_mixin import ActivityMixin
|
||||||
from .base_model import BookWyrmModel
|
from .base_model import BookWyrmModel
|
||||||
from . import fields
|
from . import fields
|
||||||
|
|
||||||
|
|
||||||
class UserRelationship(ActivitypubMixin, BookWyrmModel):
|
class UserRelationship(ActivityMixin, BookWyrmModel):
|
||||||
''' many-to-many through table for followers '''
|
''' many-to-many through table for followers '''
|
||||||
user_subject = fields.ForeignKey(
|
user_subject = fields.ForeignKey(
|
||||||
'User',
|
'User',
|
||||||
|
|
|
@ -9,10 +9,11 @@ from django.utils import timezone
|
||||||
from model_utils.managers import InheritanceManager
|
from model_utils.managers import InheritanceManager
|
||||||
|
|
||||||
from bookwyrm import activitypub
|
from bookwyrm import activitypub
|
||||||
from .activitypub_mixin import ActivitypubMixin, OrderedCollectionPageMixin
|
from .activitypub_mixin import ActivitypubMixin, ActivityMixin
|
||||||
|
from .activitypub_mixin import OrderedCollectionPageMixin
|
||||||
from .base_model import BookWyrmModel
|
from .base_model import BookWyrmModel
|
||||||
from . import fields
|
|
||||||
from .fields import image_serializer
|
from .fields import image_serializer
|
||||||
|
from . import fields
|
||||||
|
|
||||||
class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
||||||
''' any post, like a reply to a review, etc '''
|
''' any post, like a reply to a review, etc '''
|
||||||
|
@ -223,7 +224,7 @@ class Review(Status):
|
||||||
pure_type = 'Article'
|
pure_type = 'Article'
|
||||||
|
|
||||||
|
|
||||||
class Boost(Status):
|
class Boost(ActivityMixin, Status):
|
||||||
''' boost'ing a post '''
|
''' boost'ing a post '''
|
||||||
boosted_status = fields.ForeignKey(
|
boosted_status = fields.ForeignKey(
|
||||||
'Status',
|
'Status',
|
||||||
|
|
Loading…
Reference in a new issue