Length of URL fields, page listing
This commit is contained in:
parent
29e4d492c2
commit
34d973f14e
4 changed files with 37 additions and 9 deletions
|
@ -16,23 +16,23 @@ def parse(obj, raw, stream):
|
|||
obj.published = datetime.fromtimestamp(ts)
|
||||
|
||||
# Authorship and title
|
||||
obj.title = raw['title']
|
||||
obj.title = raw['title'][:250]
|
||||
if 'author' in raw['origin']:
|
||||
obj.author = raw['author']
|
||||
obj.author = raw['author'][:250]
|
||||
elif 'title' in raw['origin']:
|
||||
obj.author = raw['origin']['title']
|
||||
obj.author = raw['origin']['title'][:250]
|
||||
|
||||
# Parse links and references
|
||||
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 '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:
|
||||
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']:
|
||||
obj.visual = raw['visual']['url']
|
||||
obj.visual = raw['visual']['url'][:500]
|
||||
if obj.visual.lower().strip() == 'none':
|
||||
obj.visual = ''
|
||||
|
||||
|
|
25
feedler/migrations/0008_auto_20171117_1647.py
Normal file
25
feedler/migrations/0008_auto_20171117_1647.py
Normal file
|
@ -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)
|
||||
author = models.CharField(max_length=255, blank=True)
|
||||
link = models.URLField()
|
||||
visual = models.URLField(blank=True)
|
||||
link = models.URLField(max_length=500)
|
||||
visual = models.URLField(max_length=500, blank=True)
|
||||
lang = models.CharField(max_length=2, blank=True, default='', choices=LANGUAGE_CHOICES)
|
||||
content = models.TextField()
|
||||
tags = models.TextField(blank=True)
|
||||
|
@ -51,6 +51,8 @@ class Entry(models.Model):
|
|||
|
||||
class Meta:
|
||||
verbose_name_plural = 'Entries'
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class FeedPage(Page):
|
||||
intro = RichTextField(default='', blank=True)
|
||||
|
|
|
@ -14,6 +14,7 @@ class EntryModelAdmin(EntryModelAdminMixin, ModelAdmin):
|
|||
exclude_from_explorer = True
|
||||
list_filter = ('author', 'tags')
|
||||
list_display = ('published', 'title', 'with_image', 'lang')
|
||||
list_per_page = 10
|
||||
search_fields = ('title', 'author', 'content', 'tags')
|
||||
|
||||
modeladmin_register(EntryModelAdmin)
|
||||
|
|
Loading…
Add table
Reference in a new issue