Commits

Gregory Petukhov committed 0323764

Fix too long tags string issue

Comments (0)

Files changed (2)

feedzilla/management/commands/feedzilla_update.py

 # -*- coding: utf-8 -*-
 import logging
 from datetime import datetime
+import re
 
 from django.core.management.base import BaseCommand
 from django.conf import settings
 from feedzilla.models import Feed, Post
 from feedzilla import settings
 
+REX_TAGS_TAIL = re.compile(',[^,]*')
 
 class Command(BaseCommand):
     help = u'Update feeds'
                         tags = entry['tags']
                         if settings.FEEDZILLA_TAGS_LOWERCASE:
                             tags = set(x.lower() for x in tags)
+
+                        # Strip tags to 255 chars string
+                        # because of TagField limitation
+                        tags = ', '.join(tags)
+                        tags = REX_TAGS_TAIL.sub('', tags)[:255]
+
                         post = Post(
                             feed=feed,
                             tags=', '.join(tags),
             data_files.append(os.path.join(prefix, f))
 
 setup(
-    version = '0.1.15',
+    version = '0.1.16',
     description = 'Django application for atom/rss feeds aggregation i.e. planet engine',
     author = 'Grigoriy Petukhov',
     author_email = 'lorien@lorien.name',