Add basic django-meta support to entries too
This commit is contained in:
parent
eaf84459ff
commit
0d520c0fd8
3 changed files with 38 additions and 3 deletions
|
|
@ -3,12 +3,14 @@ from django.db import models
|
|||
from django.urls import reverse
|
||||
from slugify import slugify
|
||||
|
||||
from meta.models import ModelMeta
|
||||
from users.models import Profile
|
||||
|
||||
from . import kinds
|
||||
ENTRY_KINDS = [(k.id, k.__name__) for k in kinds.all]
|
||||
|
||||
|
||||
class Entry(models.Model):
|
||||
class Entry(ModelMeta, models.Model):
|
||||
kind = models.CharField(
|
||||
max_length=30,
|
||||
choices=ENTRY_KINDS,
|
||||
|
|
@ -16,7 +18,6 @@ class Entry(models.Model):
|
|||
)
|
||||
|
||||
name = models.CharField(max_length=100, blank=True)
|
||||
summary = models.TextField(blank=True)
|
||||
content = models.TextField()
|
||||
|
||||
author = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
|
||||
|
|
@ -24,6 +25,20 @@ class Entry(models.Model):
|
|||
published = models.DateTimeField()
|
||||
updated = models.DateTimeField()
|
||||
|
||||
_metadata = {
|
||||
'description': 'content',
|
||||
'twitter_creator': 'twitter_creator',
|
||||
'og_profile_id': 'og_profile_id',
|
||||
}
|
||||
|
||||
@property
|
||||
def twitter_creator(self):
|
||||
return self.author.twitter_username
|
||||
|
||||
@property
|
||||
def og_profile_id(self):
|
||||
return self.author.facebook_id
|
||||
|
||||
def __str__(self):
|
||||
return '{kind} {id}: {content}'.format(
|
||||
kind=self.kind,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue