kopia lustrzana https://gitlab.com/marnanel/chapeau
trilby's Status and Person classes now descend from a common ancestor,
AcObject. This allows bowler to return objects it finds without having to require a particular type.status-serialisers
rodzic
4bf78f6c37
commit
e9d780d2a3
|
@ -0,0 +1,32 @@
|
|||
# Generated by Django 3.0.9 on 2020-08-15 17:49
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('contenttypes', '0002_remove_content_type_name'),
|
||||
('trilby_api', '0019_localperson_default_sensitive'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='localperson',
|
||||
options={},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='person',
|
||||
options={},
|
||||
),
|
||||
migrations.AlterModelOptions(
|
||||
name='remoteperson',
|
||||
options={},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='status',
|
||||
name='polymorphic_ctype',
|
||||
field=models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='polymorphic_trilby_api.status_set+', to='contenttypes.ContentType'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# acobject.py
|
||||
#
|
||||
# Part of kepi.
|
||||
# Copyright (c) 2018-2020 Marnanel Thurman.
|
||||
# Licensed under the GNU Public License v2.
|
||||
|
||||
import logging
|
||||
logger = logging.Logger("kepi")
|
||||
|
||||
from polymorphic.models import PolymorphicModel
|
||||
|
||||
class AcObject(PolymorphicModel):
|
||||
|
||||
"""
|
||||
AcObjects are the ancestors of classes we can
|
||||
receive over ActivityPub.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
|
@ -19,8 +19,9 @@ import kepi.bowler_pub.utils as bowler_utils
|
|||
from django.utils.timezone import now
|
||||
from django.core.exceptions import ValidationError
|
||||
from urllib.parse import urlparse
|
||||
from .acobject import AcObject
|
||||
|
||||
class Person(PolymorphicModel):
|
||||
class Person(AcObject):
|
||||
|
||||
@property
|
||||
def icon_or_default(self):
|
||||
|
|
|
@ -8,10 +8,11 @@ import kepi.trilby_api.utils as trilby_utils
|
|||
from django.utils.timezone import now
|
||||
from django.core.exceptions import ValidationError
|
||||
import logging
|
||||
from .acobject import AcObject
|
||||
|
||||
logger = logging.Logger('kepi')
|
||||
|
||||
class Status(models.Model):
|
||||
class Status(AcObject):
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = 'Statuses'
|
||||
|
|
Ładowanie…
Reference in New Issue