~daker/loco-team-portal/fix.839011-839014

« back to all changes in this revision

Viewing changes to loco_directory/articles/models.py

  • Committer: Tarmac
  • Author(s): Adnane Belmadiaf
  • Date: 2012-12-13 20:46:40 UTC
  • mfrom: (576.1.6 fix.feeds)
  • Revision ID: tarmac@geekpad-20121213204640-euqjzcvqinulv4pb
[r=] Change the feed importer to include the whole article with html

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
import urllib2
7
7
 
8
8
from django.db import models
9
 
from django.utils.html import strip_tags
10
9
from django.conf import settings
11
10
 
12
11
from teams.models import Team
62
61
        if not data or not hasattr(data, 'entries') or len(data.entries) == 0:
63
62
            # No new entries for this feed
64
63
            return
65
 
 
66
64
        now = datetime.datetime.now()
67
65
        existing_articles = set(list(Article.objects.filter(source=self).values_list('uid', flat=True)))
68
66
        returned_articles = set([])
86
84
                    imp_date = now
87
85
 
88
86
                if hasattr(entry, 'content'):
89
 
                    snippet = entry.content[0].value
 
87
                    content = entry.content[0].value
90
88
                else:
91
 
                    snippet = entry.get('description', '')
 
89
                    content = entry.get('description', '')
92
90
 
93
91
                article = Article(
94
92
                    source=self,
98
96
                    imported=imp_date,
99
97
                    title=entry.get('title', '')[:128],
100
98
                    link=entry.get('link', None),
101
 
                    snippet=strip_tags(snippet)[:512],
 
99
                    content=content,
102
100
                )
103
101
                article.save()
104
102
 
114
112
    imported = models.DateTimeField(null=True, blank=True)
115
113
    link = models.URLField(max_length=1024, null=True, blank=True)
116
114
    title = models.CharField(max_length=128, null=True, blank=True)
117
 
    snippet = models.CharField(max_length=512, null=True, blank=True)
 
115
    content = models.TextField(null=True, blank=True)
118
116
 
119
117
    class Meta:
120
118
        ordering = ['-imported', '-published', ]