diff --git a/entries/admin.py b/entries/admin.py index 3a48189..2afdbaa 100644 --- a/entries/admin.py +++ b/entries/admin.py @@ -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) diff --git a/entries/migrations/0002_syndication.py b/entries/migrations/0002_syndication.py new file mode 100644 index 0000000..415ceee --- /dev/null +++ b/entries/migrations/0002_syndication.py @@ -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'], + }, + ), + ] diff --git a/entries/models.py b/entries/models.py index b3c349f..fb0d648 100644 --- a/entries/models.py +++ b/entries/models.py @@ -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'] diff --git a/entries/templates/entries/h-entry.html b/entries/templates/entries/h-entry.html index 28f0ac0..d8224ac 100644 --- a/entries/templates/entries/h-entry.html +++ b/entries/templates/entries/h-entry.html @@ -20,5 +20,11 @@ {{ entry.updated | naturaltime }} {% endif %} + {% for s in entry.syndications.all %} + + + {{ s.profile.name }} + + {% endfor %}