Length of URL fields, page listing
This commit is contained in:
parent
29e4d492c2
commit
34d973f14e
|
@ -16,23 +16,23 @@ def parse(obj, raw, stream):
|
||||||
obj.published = datetime.fromtimestamp(ts)
|
obj.published = datetime.fromtimestamp(ts)
|
||||||
|
|
||||||
# Authorship and title
|
# Authorship and title
|
||||||
obj.title = raw['title']
|
obj.title = raw['title'][:250]
|
||||||
if 'author' in raw['origin']:
|
if 'author' in raw['origin']:
|
||||||
obj.author = raw['author']
|
obj.author = raw['author'][:250]
|
||||||
elif 'title' in raw['origin']:
|
elif 'title' in raw['origin']:
|
||||||
obj.author = raw['origin']['title']
|
obj.author = raw['origin']['title'][:250]
|
||||||
|
|
||||||
# Parse links and references
|
# Parse links and references
|
||||||
if len(raw['alternate']) > 0:
|
if len(raw['alternate']) > 0:
|
||||||
obj.link = raw['alternate'][0]['href']
|
obj.link = raw['alternate'][0]['href'][:500]
|
||||||
if 'thumbnail' in raw and len(raw['thumbnail']) > 0:
|
if 'thumbnail' in raw and len(raw['thumbnail']) > 0:
|
||||||
if 'url' in raw['thumbnail'][0]:
|
if 'url' in raw['thumbnail'][0]:
|
||||||
obj.visual = raw['thumbnail'][0]['url']
|
obj.visual = raw['thumbnail'][0]['url'][:500]
|
||||||
elif 'enclosure' in raw and len(raw['enclosure']) > 0:
|
elif 'enclosure' in raw and len(raw['enclosure']) > 0:
|
||||||
if 'href' in raw['enclosure'][0]:
|
if 'href' in raw['enclosure'][0]:
|
||||||
obj.visual = raw['enclosure'][0]['href']
|
obj.visual = raw['enclosure'][0]['href'][:500]
|
||||||
elif 'visual' in raw and 'url' in raw['visual']:
|
elif 'visual' in raw and 'url' in raw['visual']:
|
||||||
obj.visual = raw['visual']['url']
|
obj.visual = raw['visual']['url'][:500]
|
||||||
if obj.visual.lower().strip() == 'none':
|
if obj.visual.lower().strip() == 'none':
|
||||||
obj.visual = ''
|
obj.visual = ''
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.7 on 2017-11-17 15:47
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('feedler', '0007_auto_20171016_1059'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='entry',
|
||||||
|
name='link',
|
||||||
|
field=models.URLField(max_length=500),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='entry',
|
||||||
|
name='visual',
|
||||||
|
field=models.URLField(blank=True, max_length=500),
|
||||||
|
),
|
||||||
|
]
|
|
@ -34,8 +34,8 @@ class Entry(models.Model):
|
||||||
|
|
||||||
title = models.CharField(max_length=255)
|
title = models.CharField(max_length=255)
|
||||||
author = models.CharField(max_length=255, blank=True)
|
author = models.CharField(max_length=255, blank=True)
|
||||||
link = models.URLField()
|
link = models.URLField(max_length=500)
|
||||||
visual = models.URLField(blank=True)
|
visual = models.URLField(max_length=500, blank=True)
|
||||||
lang = models.CharField(max_length=2, blank=True, default='', choices=LANGUAGE_CHOICES)
|
lang = models.CharField(max_length=2, blank=True, default='', choices=LANGUAGE_CHOICES)
|
||||||
content = models.TextField()
|
content = models.TextField()
|
||||||
tags = models.TextField(blank=True)
|
tags = models.TextField(blank=True)
|
||||||
|
@ -51,6 +51,8 @@ class Entry(models.Model):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name_plural = 'Entries'
|
verbose_name_plural = 'Entries'
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
class FeedPage(Page):
|
class FeedPage(Page):
|
||||||
intro = RichTextField(default='', blank=True)
|
intro = RichTextField(default='', blank=True)
|
||||||
|
|
|
@ -14,6 +14,7 @@ class EntryModelAdmin(EntryModelAdminMixin, ModelAdmin):
|
||||||
exclude_from_explorer = True
|
exclude_from_explorer = True
|
||||||
list_filter = ('author', 'tags')
|
list_filter = ('author', 'tags')
|
||||||
list_display = ('published', 'title', 'with_image', 'lang')
|
list_display = ('published', 'title', 'with_image', 'lang')
|
||||||
|
list_per_page = 10
|
||||||
search_fields = ('title', 'author', 'content', 'tags')
|
search_fields = ('title', 'author', 'content', 'tags')
|
||||||
|
|
||||||
modeladmin_register(EntryModelAdmin)
|
modeladmin_register(EntryModelAdmin)
|
||||||
|
|
Loading…
Reference in New Issue