2 from datetime import date, datetime
4 from django.conf import settings
5 from django.conf.urls.defaults import url, patterns, include
6 from django.db import models
7 from django.http import Http404, HttpResponse
8 from taggit.managers import TaggableManager
9 from taggit.models import Tag, TaggedItem
11 from philo.contrib.winer.models import FeedView
12 from philo.exceptions import ViewCanNotProvideSubpath
13 from philo.models import Entity, Page, register_value_model
14 from philo.models.fields import TemplateField
15 from philo.utils import paginate
19 """Represents a blog which can be posted to."""
20 #: The name of the :class:`Blog`, currently called 'title' for historical reasons.
21 title = models.CharField(max_length=255)
23 #: A slug used to identify the :class:`Blog`.
24 slug = models.SlugField(max_length=255)
26 def __unicode__(self):
31 """Returns a :class:`QuerySet` of :class:`.Tag`\ s that are used on any entries in this blog."""
32 entry_pks = list(self.entries.values_list('pk', flat=True))
34 '%s__object_id__in' % TaggedItem.tag_relname(): entry_pks
36 return TaggedItem.tags_for(BlogEntry).filter(**kwargs)
39 def entry_dates(self):
40 """Returns a dictionary of date :class:`QuerySet`\ s for years, months, and days for which there are entries."""
41 dates = {'year': self.entries.dates('date', 'year', order='DESC'), 'month': self.entries.dates('date', 'month', order='DESC'), 'day': self.entries.dates('date', 'day', order='DESC')}
45 register_value_model(Blog)
48 class BlogEntry(Entity):
49 """Represents an entry in a :class:`Blog`."""
50 #: The title of the :class:`BlogEntry`.
51 title = models.CharField(max_length=255)
53 #: A slug which identifies the :class:`BlogEntry`.
54 slug = models.SlugField(max_length=255)
56 #: The :class:`Blog` which this entry has been posted to. Can be left blank to represent a "draft" status.
57 blog = models.ForeignKey(Blog, related_name='entries', blank=True, null=True)
59 #: A :class:`ForeignKey` to the author. The model is either :setting:`PHILO_PERSON_MODULE` or :class:`auth.User`.
60 author = models.ForeignKey(getattr(settings, 'PHILO_PERSON_MODULE', 'auth.User'), related_name='blogentries')
62 #: The date and time which the :class:`BlogEntry` is considered posted at.
63 date = models.DateTimeField(default=None)
65 #: The content of the :class:`BlogEntry`.
66 content = TemplateField()
68 #: An optional brief excerpt from the :class:`BlogEntry`.
69 excerpt = TemplateField(blank=True, null=True)
71 #: A ``django-taggit`` :class:`TaggableManager`.
72 tags = TaggableManager()
74 def save(self, *args, **kwargs):
76 self.date = datetime.now()
77 super(BlogEntry, self).save(*args, **kwargs)
79 def __unicode__(self):
84 verbose_name_plural = "blog entries"
85 get_latest_by = "date"
88 register_value_model(BlogEntry)
91 class BlogView(FeedView):
93 A subclass of :class:`.FeedView` which handles patterns and feeds for a :class:`Blog` and its related :class:`entries <BlogEntry>`.
96 ENTRY_PERMALINK_STYLE_CHOICES = (
97 ('D', 'Year, month, and day'),
98 ('M', 'Year and month'),
100 ('B', 'Custom base'),
104 #: The :class:`Blog` whose entries should be managed by this :class:`BlogView`
105 blog = models.ForeignKey(Blog, related_name='blogviews')
107 #: The main page of the :class:`Blog` will be rendered with this :class:`.Page`.
108 index_page = models.ForeignKey(Page, related_name='blog_index_related')
109 #: The detail view of a :class:`BlogEntry` will be rendered with this :class:`Page`.
110 entry_page = models.ForeignKey(Page, related_name='blog_entry_related')
111 # TODO: entry_archive is misleading. Rename to ymd_page or timespan_page.
112 #: Views of :class:`BlogEntry` archives will be rendered with this :class:`Page` (optional).
113 entry_archive_page = models.ForeignKey(Page, related_name='blog_entry_archive_related', null=True, blank=True)
114 #: Views of :class:`BlogEntry` archives according to their :class:`.Tag`\ s will be rendered with this :class:`Page`.
115 tag_page = models.ForeignKey(Page, related_name='blog_tag_related')
116 #: The archive of all available tags will be rendered with this :class:`Page` (optional).
117 tag_archive_page = models.ForeignKey(Page, related_name='blog_tag_archive_related', null=True, blank=True)
118 #: This number will be passed directly into pagination for :class:`BlogEntry` list pages. Pagination will be disabled if this is left blank.
119 entries_per_page = models.IntegerField(blank=True, null=True)
121 #: Depending on the needs of the site, different permalink styles may be appropriate. Example subpaths are provided for a :class:`BlogEntry` posted on May 2nd, 2011 with a slug of "hello". The choices are:
123 #: * Year, month, and day - ``2011/05/02/hello``
124 #: * Year and month - ``2011/05/hello``
125 #: * Year - ``2011/hello``
126 #: * Custom base - :attr:`entry_permalink_base`\ ``/hello``
127 #: * No base - ``hello``
128 entry_permalink_style = models.CharField(max_length=1, choices=ENTRY_PERMALINK_STYLE_CHOICES)
129 #: If the :attr:`entry_permalink_style` is set to "Custom base" then the value of this field will be used as the base subpath for year/month/day entry archive pages and entry detail pages. Default: "entries"
130 entry_permalink_base = models.CharField(max_length=255, blank=False, default='entries')
131 #: This will be used as the base for the views of :attr:`tag_page` and :attr:`tag_archive_page`. Default: "tags"
132 tag_permalink_base = models.CharField(max_length=255, blank=False, default='tags')
134 item_context_var = 'entries'
136 def __unicode__(self):
137 return u'BlogView for %s' % self.blog.title
139 def get_reverse_params(self, obj):
140 if isinstance(obj, BlogEntry):
141 if obj.blog_id == self.blog_id:
142 kwargs = {'slug': obj.slug}
143 if self.entry_permalink_style in 'DMY':
144 kwargs.update({'year': str(obj.date.year).zfill(4)})
145 if self.entry_permalink_style in 'DM':
146 kwargs.update({'month': str(obj.date.month).zfill(2)})
147 if self.entry_permalink_style == 'D':
148 kwargs.update({'day': str(obj.date.day).zfill(2)})
149 return self.entry_view, [], kwargs
150 elif isinstance(obj, Tag) or (isinstance(obj, models.query.QuerySet) and obj.model == Tag and obj):
151 if isinstance(obj, Tag):
153 slugs = [tag.slug for tag in obj if tag in self.get_tag_queryset(self.blog)]
155 return 'entries_by_tag', [], {'tag_slugs': "/".join(slugs)}
156 elif isinstance(obj, (date, datetime)):
158 'year': str(obj.year).zfill(4),
159 'month': str(obj.month).zfill(2),
160 'day': str(obj.day).zfill(2)
162 return 'entries_by_day', [], kwargs
163 raise ViewCanNotProvideSubpath
166 def urlpatterns(self):
167 urlpatterns = self.feed_patterns(r'^', 'get_entries', 'index_page', 'index') +\
168 self.feed_patterns(r'^%s/(?P<tag_slugs>[-\w]+[-+/\w]*)' % self.tag_permalink_base, 'get_entries', 'tag_page', 'entries_by_tag')
170 if self.tag_archive_page_id:
171 urlpatterns += patterns('',
172 url((r'^%s$' % self.tag_permalink_base), self.tag_archive_view, name='tag_archive')
175 if self.entry_archive_page_id:
176 if self.entry_permalink_style in 'DMY':
177 urlpatterns += self.feed_patterns(r'^(?P<year>\d{4})', 'get_entries', 'entry_archive_page', 'entries_by_year')
178 if self.entry_permalink_style in 'DM':
179 urlpatterns += self.feed_patterns(r'^(?P<year>\d{4})/(?P<month>\d{2})', 'get_entries', 'entry_archive_page', 'entries_by_month')
180 if self.entry_permalink_style == 'D':
181 urlpatterns += self.feed_patterns(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})', 'get_entries', 'entry_archive_page', 'entries_by_day')
183 if self.entry_permalink_style == 'D':
184 urlpatterns += patterns('',
185 url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[-\w]+)$', self.entry_view)
187 elif self.entry_permalink_style == 'M':
188 urlpatterns += patterns('',
189 url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[-\w]+)$', self.entry_view)
191 elif self.entry_permalink_style == 'Y':
192 urlpatterns += patterns('',
193 url(r'^(?P<year>\d{4})/(?P<slug>[-\w]+)$', self.entry_view)
195 elif self.entry_permalink_style == 'B':
196 urlpatterns += patterns('',
197 url((r'^%s/(?P<slug>[-\w]+)$' % self.entry_permalink_base), self.entry_view)
200 urlpatterns += patterns('',
201 url(r'^(?P<slug>[-\w]+)$', self.entry_view)
205 def get_entry_queryset(self, obj):
206 """Returns the default :class:`QuerySet` of :class:`BlogEntry` instances for the :class:`BlogView` - all entries that are considered posted in the past. This allows for scheduled posting of entries."""
207 return obj.entries.filter(date__lte=datetime.now())
209 def get_tag_queryset(self, obj):
210 """Returns the default :class:`QuerySet` of :class:`.Tag`\ s for the :class:`BlogView`'s :meth:`get_entries_by_tag` and :meth:`tag_archive_view`."""
211 return obj.entry_tags
213 def get_object(self, request, year=None, month=None, day=None, tag_slugs=None):
214 """Returns a dictionary representing the parameters for a feed which will be exposed."""
215 if tag_slugs is None:
218 tag_slugs = tag_slugs.replace('+', '/').split('/')
219 tags = self.get_tag_queryset(self.blog).filter(slug__in=tag_slugs)
223 # Raise a 404 on an incorrect slug.
224 found_slugs = set([tag.slug for tag in tags])
225 for slug in tag_slugs:
226 if slug and slug not in found_slugs:
230 if year and month and day:
231 context_date = date(int(year), int(month), int(day))
233 context_date = date(int(year), int(month), 1)
235 context_date = date(int(year), 1, 1)
238 except TypeError, ValueError:
250 def get_entries(self, obj, request, year=None, month=None, day=None, tag_slugs=None, extra_context=None):
251 """Returns the :class:`BlogEntry` objects which will be exposed for the given object, as returned from :meth:`get_object`."""
252 entries = self.get_entry_queryset(obj['blog'])
254 if obj['tags'] is not None:
257 entries = entries.filter(tags=tag)
259 if obj['date'] is not None:
261 entries = entries.filter(date__year=year)
263 entries = entries.filter(date__month=month)
265 entries = entries.filter(date__day=day)
267 context = extra_context or {}
270 return entries, context
272 def entry_view(self, request, slug, year=None, month=None, day=None, extra_context=None):
273 """Renders :attr:`entry_page` with the entry specified by the given parameters."""
274 entries = self.get_entry_queryset(self.blog)
276 entries = entries.filter(date__year=year)
278 entries = entries.filter(date__month=month)
280 entries = entries.filter(date__day=day)
282 entry = entries.get(slug=slug)
285 context = self.get_context()
286 context.update(extra_context or {})
287 context.update({'entry': entry})
288 return self.entry_page.render_to_response(request, extra_context=context)
290 def tag_archive_view(self, request, extra_context=None):
291 """Renders :attr:`tag_archive_page` with the result of :meth:`get_tag_queryset` added to the context."""
292 if not self.tag_archive_page:
294 context = self.get_context()
295 context.update(extra_context or {})
297 'tags': self.get_tag_queryset(self.blog)
299 return self.tag_archive_page.render_to_response(request, extra_context=context)
301 def process_page_items(self, request, items):
302 """Overrides :meth:`.FeedView.process_page_items` to add pagination."""
303 if self.entries_per_page:
304 page_num = request.GET.get('page', 1)
305 paginator, paginated_page, items = paginate(items, self.entries_per_page, page_num)
307 'paginator': paginator,
308 'paginated_page': paginated_page,
309 self.item_context_var: items
313 self.item_context_var: items
315 return items, item_context
317 def title(self, obj):
318 title = obj['blog'].title
320 title += u" – %s" % u", ".join((tag.name for tag in obj['tags']))
324 datestr = date.strftime("%F %j, %Y")
326 datestr = date.strftime("%F, %Y")
328 datestr = date.strftime("%Y")
329 title += u" – %s" % datestr
332 def categories(self, obj):
335 return (tag.name for tag in tags)
338 def item_title(self, item):
341 def item_description(self, item):
344 def item_author_name(self, item):
345 return item.author.get_full_name()
347 def item_pubdate(self, item):
350 def item_categories(self, item):
351 return [tag.name for tag in item.tags.all()]
354 class Newsletter(Entity):
355 """Represents a newsletter which will contain :class:`articles <NewsletterArticle>` organized into :class:`issues <NewsletterIssue>`."""
356 #: The name of the :class:`Newsletter`, currently callse 'title' for historical reasons.
357 title = models.CharField(max_length=255)
358 #: A slug used to identify the :class:`Newsletter`.
359 slug = models.SlugField(max_length=255)
361 def __unicode__(self):
365 register_value_model(Newsletter)
368 class NewsletterArticle(Entity):
369 """Represents an article in a :class:`Newsletter`"""
370 #: The title of the :class:`NewsletterArticle`.
371 title = models.CharField(max_length=255)
372 #: A slug which identifies the :class:`NewsletterArticle`.
373 slug = models.SlugField(max_length=255)
374 #: A :class:`ForeignKey` to :class:`Newsletter` representing the newsletter which this article was written for.
375 newsletter = models.ForeignKey(Newsletter, related_name='articles')
376 #: A :class:`ManyToManyField` to the author(s) of the :class:`NewsletterArticle`. The model is either :setting:`PHILO_PERSON_MODULE` or :class:`auth.User`.
377 authors = models.ManyToManyField(getattr(settings, 'PHILO_PERSON_MODULE', 'auth.User'), related_name='newsletterarticles')
378 #: The date and time which the :class:`NewsletterArticle` is considered published at.
379 date = models.DateTimeField(default=None)
380 #: A :class:`.TemplateField` containing an optional short summary of the article, meant to grab a reader's attention and draw them in.
381 lede = TemplateField(null=True, blank=True, verbose_name='Summary')
382 #: A :class:`.TemplateField` containing the full text of the article.
383 full_text = TemplateField(db_index=True)
384 #: A ``django-taggit`` :class:`TaggableManager`.
385 tags = TaggableManager()
387 def save(self, *args, **kwargs):
388 if self.date is None:
389 self.date = datetime.now()
390 super(NewsletterArticle, self).save(*args, **kwargs)
392 def __unicode__(self):
396 get_latest_by = 'date'
398 unique_together = (('newsletter', 'slug'),)
401 register_value_model(NewsletterArticle)
404 class NewsletterIssue(Entity):
405 """Represents an issue of the newsletter."""
406 #: The title of the :class:`NewsletterIssue`.
407 title = models.CharField(max_length=255)
408 #: A slug which identifies the :class:`NewsletterIssue`.
409 slug = models.SlugField(max_length=255)
410 #: A :class:`ForeignKey` to the :class:`Newsletter` which this issue belongs to.
411 newsletter = models.ForeignKey(Newsletter, related_name='issues')
412 #: The numbering of the issue - for example, 04.02 for volume 4, issue 2. This is an instance of :class:`CharField` to allow any arbitrary numbering system.
413 numbering = models.CharField(max_length=50, help_text='For example, 04.02 for volume 4, issue 2.')
414 #: A :class:`ManyToManyField` to articles belonging to this issue.
415 articles = models.ManyToManyField(NewsletterArticle, related_name='issues')
417 def __unicode__(self):
421 ordering = ['-numbering']
422 unique_together = (('newsletter', 'numbering'),)
425 register_value_model(NewsletterIssue)
428 class NewsletterView(FeedView):
429 """A subclass of :class:`.FeedView` which handles patterns and feeds for a :class:`Newsletter` and its related :class:`articles <NewsletterArticle>`."""
430 ARTICLE_PERMALINK_STYLE_CHOICES = (
431 ('D', 'Year, month, and day'),
432 ('M', 'Year and month'),
437 #: A :class:`ForeignKey` to the :class:`Newsletter` managed by this :class:`NewsletterView`.
438 newsletter = models.ForeignKey(Newsletter, related_name='newsletterviews')
440 #: A :class:`ForeignKey` to the :class:`Page` used to render the main page of this :class:`NewsletterView`.
441 index_page = models.ForeignKey(Page, related_name='newsletter_index_related')
442 #: A :class:`ForeignKey` to the :class:`Page` used to render the detail view of a :class:`NewsletterArticle` for this :class:`NewsletterView`.
443 article_page = models.ForeignKey(Page, related_name='newsletter_article_related')
444 #: A :class:`ForeignKey` to the :class:`Page` used to render the :class:`NewsletterArticle` archive pages for this :class:`NewsletterView`.
445 article_archive_page = models.ForeignKey(Page, related_name='newsletter_article_archive_related', null=True, blank=True)
446 #: A :class:`ForeignKey` to the :class:`Page` used to render the detail view of a :class:`NewsletterIssue` for this :class:`NewsletterView`.
447 issue_page = models.ForeignKey(Page, related_name='newsletter_issue_related')
448 #: A :class:`ForeignKey` to the :class:`Page` used to render the :class:`NewsletterIssue` archive pages for this :class:`NewsletterView`.
449 issue_archive_page = models.ForeignKey(Page, related_name='newsletter_issue_archive_related', null=True, blank=True)
451 #: Depending on the needs of the site, different permalink styles may be appropriate. Example subpaths are provided for a :class:`NewsletterArticle` posted on May 2nd, 2011 with a slug of "hello". The choices are:
453 #: * Year, month, and day - :attr:`article_permalink_base`\ ``/2011/05/02/hello``
454 #: * Year and month - :attr:`article_permalink_base`\ ``/2011/05/hello``
455 #: * Year - :attr:`article_permalink_base`\ ``/2011/hello``
456 #: * Slug only - :attr:`article_permalink_base`\ ``/hello``
457 article_permalink_style = models.CharField(max_length=1, choices=ARTICLE_PERMALINK_STYLE_CHOICES)
458 #: This will be used as the base subpath for year/month/day article archive pages and article detail pages. Default: "articles"
459 article_permalink_base = models.CharField(max_length=255, blank=False, default='articles')
460 #: This will be used as the base subpath for issue detail pages and the issue archive page.
461 issue_permalink_base = models.CharField(max_length=255, blank=False, default='issues')
463 item_context_var = 'articles'
464 object_attr = 'newsletter'
466 def __unicode__(self):
467 return "NewsletterView for %s" % self.newsletter.__unicode__()
469 def get_reverse_params(self, obj):
470 if isinstance(obj, NewsletterArticle):
471 if obj.newsletter_id == self.newsletter_id:
472 kwargs = {'slug': obj.slug}
473 if self.article_permalink_style in 'DMY':
474 kwargs.update({'year': str(obj.date.year).zfill(4)})
475 if self.article_permalink_style in 'DM':
476 kwargs.update({'month': str(obj.date.month).zfill(2)})
477 if self.article_permalink_style == 'D':
478 kwargs.update({'day': str(obj.date.day).zfill(2)})
479 return self.article_view, [], kwargs
480 elif isinstance(obj, NewsletterIssue):
481 if obj.newsletter_id == self.newsletter_id:
482 return 'issue', [], {'numbering': obj.numbering}
483 elif isinstance(obj, (date, datetime)):
485 'year': str(obj.year).zfill(4),
486 'month': str(obj.month).zfill(2),
487 'day': str(obj.day).zfill(2)
489 return 'articles_by_day', [], kwargs
490 raise ViewCanNotProvideSubpath
493 def urlpatterns(self):
494 urlpatterns = self.feed_patterns(r'^', 'get_all_articles', 'index_page', 'index') + patterns('',
495 url(r'^%s/(?P<numbering>.+)$' % self.issue_permalink_base, self.page_view('get_articles_by_issue', 'issue_page'), name='issue')
497 if self.issue_archive_page_id:
498 urlpatterns += patterns('',
499 url(r'^%s$' % self.issue_permalink_base, self.issue_archive_view, 'issue_archive')
501 if self.article_archive_page_id:
502 urlpatterns += self.feed_patterns(r'^%s' % self.article_permalink_base, 'get_all_articles', 'article_archive_page', 'articles')
503 if self.article_permalink_style in 'DMY':
504 urlpatterns += self.feed_patterns(r'^%s/(?P<year>\d{4})' % self.article_permalink_base, 'get_articles_by_ymd', 'article_archive_page', 'articles_by_year')
505 if self.article_permalink_style in 'DM':
506 urlpatterns += self.feed_patterns(r'^%s/(?P<year>\d{4})/(?P<month>\d{2})' % self.article_permalink_base, 'get_articles_by_ymd', 'article_archive_page', 'articles_by_month')
507 if self.article_permalink_style == 'D':
508 urlpatterns += self.feed_patterns(r'^%s/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})' % self.article_permalink_base, 'get_articles_by_ymd', 'article_archive_page', 'articles_by_day')
510 if self.article_permalink_style == 'Y':
511 urlpatterns += patterns('',
512 url(r'^%s/(?P<year>\d{4})/(?P<slug>[\w-]+)$' % self.article_permalink_base, self.article_view)
514 elif self.article_permalink_style == 'M':
515 urlpatterns += patterns('',
516 url(r'^%s/(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[\w-]+)$' % self.article_permalink_base, self.article_view)
518 elif self.article_permalink_style == 'D':
519 urlpatterns += patterns('',
520 url(r'^%s/(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[\w-]+)$' % self.article_permalink_base, self.article_view)
523 urlpatterns += patterns('',
524 url(r'^%s/(?P<slug>[-\w]+)$' % self.article_permalink_base, self.article_view)
529 def get_context(self):
530 return {'newsletter': self.newsletter}
532 def get_article_queryset(self, obj):
533 """Returns the default :class:`QuerySet` of :class:`NewsletterArticle` instances for the :class:`NewsletterView` - all articles that are considered posted in the past. This allows for scheduled posting of articles."""
534 return obj.articles.filter(date__lte=datetime.now())
536 def get_issue_queryset(self, obj):
537 """Returns the default :class:`QuerySet` of :class:`NewsletterIssue` instances for the :class:`NewsletterView`."""
538 return obj.issues.all()
540 def get_all_articles(self, obj, request, extra_context=None):
541 """Used to generate :meth:`~.FeedView.feed_patterns` for all entries."""
542 return self.get_article_queryset(obj), extra_context
544 def get_articles_by_ymd(self, obj, request, year, month=None, day=None, extra_context=None):
545 """Used to generate :meth:`~.FeedView.feed_patterns` for a specific year, month, and day."""
546 articles = self.get_article_queryset(obj).filter(date__year=year)
548 articles = articles.filter(date__month=month)
550 articles = articles.filter(date__day=day)
551 return articles, extra_context
553 def get_articles_by_issue(self, obj, request, numbering, extra_context=None):
554 """Used to generate :meth:`~.FeedView.feed_patterns` for articles from a certain issue."""
556 issue = self.get_issue_queryset(obj).get(numbering=numbering)
557 except NewsletterIssue.DoesNotExist:
559 context = extra_context or {}
560 context.update({'issue': issue})
561 return self.get_article_queryset(obj).filter(issues=issue), context
563 def article_view(self, request, slug, year=None, month=None, day=None, extra_context=None):
564 """Renders :attr:`article_page` with the article specified by the given parameters."""
565 articles = self.get_article_queryset(self.newsletter)
567 articles = articles.filter(date__year=year)
569 articles = articles.filter(date__month=month)
571 articles = articles.filter(date__day=day)
573 article = articles.get(slug=slug)
574 except NewsletterArticle.DoesNotExist:
576 context = self.get_context()
577 context.update(extra_context or {})
578 context.update({'article': article})
579 return self.article_page.render_to_response(request, extra_context=context)
581 def issue_archive_view(self, request, extra_context):
582 """Renders :attr:`issue_archive_page` with the result of :meth:`get_issue_queryset` added to the context."""
583 if not self.issue_archive_page:
585 context = self.get_context()
586 context.update(extra_context or {})
588 'issues': self.get_issue_queryset(self.newsletter)
590 return self.issue_archive_page.render_to_response(request, extra_context=context)
592 def title(self, obj):
595 def item_title(self, item):
598 def item_description(self, item):
599 return item.full_text
601 def item_author_name(self, item):
602 authors = list(item.authors.all())
604 return "%s and %s" % (", ".join([author.get_full_name() for author in authors[:-1]]), authors[-1].get_full_name())
606 return authors[0].get_full_name()
610 def item_pubdate(self, item):
613 def item_categories(self, item):
614 return [tag.name for tag in item.tags.all()]