2018-08-12 13:06:26 +00:00
|
|
|
from django.db import models
|
|
|
|
from django_kepi import register_type
|
2018-08-29 23:59:38 +00:00
|
|
|
from django_kepi import models as kepi_models
|
2018-08-12 13:06:26 +00:00
|
|
|
|
2018-08-29 23:59:38 +00:00
|
|
|
class ThingUser(kepi_models.YourPerson):
|
2018-08-12 13:06:26 +00:00
|
|
|
|
2018-08-29 23:59:38 +00:00
|
|
|
favourite_colour = models.CharField(
|
|
|
|
max_length=256,
|
|
|
|
default='chartreuse',
|
|
|
|
)
|
2018-08-24 17:13:57 +00:00
|
|
|
|
2018-08-29 19:21:39 +00:00
|
|
|
def serialize(self):
|
2018-08-12 13:06:26 +00:00
|
|
|
|
2018-08-29 23:59:38 +00:00
|
|
|
result = super().serialize()
|
|
|
|
result['favourite_colour'] = self.favourite_colour
|
|
|
|
|
|
|
|
return result
|
2018-08-19 20:47:54 +00:00
|
|
|
|
2018-08-24 17:13:57 +00:00
|
|
|
register_type('Person', ThingUser)
|
|
|
|
|
2018-08-19 20:47:54 +00:00
|
|
|
class ThingArticle(models.Model):
|
|
|
|
|
|
|
|
title = models.CharField(max_length=256)
|
2018-08-24 17:13:57 +00:00
|
|
|
ftype = 'Article'
|
2018-08-19 20:47:54 +00:00
|
|
|
|
|
|
|
def serialize(self):
|
|
|
|
return {
|
|
|
|
'id': self.url_identifier(),
|
|
|
|
'type': 'Article',
|
|
|
|
'title': self.title,
|
|
|
|
}
|
|
|
|
|
|
|
|
def url_identifier(self):
|
|
|
|
return 'https://articles.example.com/{}'.format(
|
|
|
|
self.title,
|
|
|
|
)
|
|
|
|
|
2018-08-24 17:13:57 +00:00
|
|
|
@classmethod
|
|
|
|
def activity_create(cls, type_name, actor, fields):
|
2018-08-27 18:13:30 +00:00
|
|
|
pass
|
2018-08-24 17:13:57 +00:00
|
|
|
|
2018-08-27 18:13:30 +00:00
|
|
|
@classmethod
|
|
|
|
def activity_update(cls, type_name, actor, fields, partial):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def activity_delete(cls, type_name, actor):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def activity_like(cls, type_name, actor, fobject):
|
|
|
|
pass
|
2018-08-19 20:47:54 +00:00
|
|
|
|
2018-08-24 17:13:57 +00:00
|
|
|
register_type('Article', ThingArticle)
|
2018-08-27 17:53:52 +00:00
|
|
|
|