forked from 00dani/lemoncurry
Basic support for tracking entry syndication
This commit is contained in:
parent
5a4362b129
commit
9adbe012d6
4 changed files with 62 additions and 2 deletions
|
@ -1,5 +1,16 @@
|
||||||
from django.contrib import admin
|
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)
|
||||||
|
|
29
entries/migrations/0002_syndication.py
Normal file
29
entries/migrations/0002_syndication.py
Normal 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'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
|
@ -3,6 +3,7 @@ from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from slugify import slugify
|
from slugify import slugify
|
||||||
|
|
||||||
|
from users.models import Profile
|
||||||
from . import kinds
|
from . import kinds
|
||||||
ENTRY_KINDS = [(k.id, k.__name__) for k in kinds.all]
|
ENTRY_KINDS = [(k.id, k.__name__) for k in kinds.all]
|
||||||
|
|
||||||
|
@ -47,3 +48,16 @@ class Entry(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name_plural = 'entries'
|
verbose_name_plural = 'entries'
|
||||||
ordering = ['-published']
|
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']
|
||||||
|
|
|
@ -20,5 +20,11 @@
|
||||||
{{ entry.updated | naturaltime }}
|
{{ entry.updated | naturaltime }}
|
||||||
</time>
|
</time>
|
||||||
{% endif %}
|
{% 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>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
|
Loading…
Reference in a new issue