Basic support for tracking entry syndication

This commit is contained in:
Danielle McLean 2017-10-25 13:45:33 +11:00
parent 5a4362b129
commit 9adbe012d6
Signed by untrusted user: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
4 changed files with 62 additions and 2 deletions

View file

@ -1,5 +1,16 @@
from django.contrib import admin
from .models import Entry
from .models import Entry, Syndication
admin.site.register(Entry)
class SyndicationInline(admin.TabularInline):
model = Syndication
extra = 1
class EntryAdmin(admin.ModelAdmin):
inlines = (
SyndicationInline,
)
admin.site.register(Entry, EntryAdmin)

View file

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-10-25 02:42
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('users', '0005_auto_20171023_0158'),
('entries', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Syndication',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('url', models.CharField(max_length=255)),
('entry', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='syndications', to='entries.Entry')),
('profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='users.Profile')),
],
options={
'ordering': ['profile'],
},
),
]

View file

@ -3,6 +3,7 @@ from django.db import models
from django.urls import reverse
from slugify import slugify
from users.models import Profile
from . import kinds
ENTRY_KINDS = [(k.id, k.__name__) for k in kinds.all]
@ -47,3 +48,16 @@ class Entry(models.Model):
class Meta:
verbose_name_plural = 'entries'
ordering = ['-published']
class Syndication(models.Model):
entry = models.ForeignKey(
Entry,
related_name='syndications',
on_delete=models.CASCADE
)
profile = models.ForeignKey(Profile, on_delete=models.CASCADE)
url = models.CharField(max_length=255)
class Meta:
ordering = ['profile']

View file

@ -20,5 +20,11 @@
{{ entry.updated | naturaltime }}
</time>
{% endif %}
{% for s in entry.syndications.all %}
<a class="u-syndication" href="{{ s.url }}">
<i class="{{ s.profile.site.icon }}"></i>
{{ s.profile.name }}
</a>
{% endfor %}
</div>
</article>