1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.db import models
6 from django.utils.translation import ugettext_lazy as _
10 class Document(models.Model):
11 """Dokument - materiał pomocniczy dla nauczycieli."""
12 title = models.CharField(_('title'), max_length=120)
13 slug = models.SlugField(_('slug'))
14 file = models.FileField(_('file'), upload_to='lessons/document')
15 author = models.CharField(_('author'), blank=True, max_length=120)
16 slideshare_id = models.CharField(_('slideshare ID'), blank=True, max_length=120)
17 description = models.TextField(_('description'), blank=True)
18 created_at = models.DateTimeField(auto_now_add=True)
20 def slideshare_player(self):
21 base, ext = path.splitext(self.file.name)
22 if ext in ('.ppt', '.pps', '.pot', '.pptx', '.potx', '.ppsx', '.odp', '.key', '.zip', '.pdf',):
23 return 'ssplayer2.swf'
25 return 'ssplayerd.swf'
29 verbose_name, verbose_name_plural = _("document"), _("documents")
31 def __unicode__(self):
35 def get_absolute_url(self):
36 return ('lessons_document_detail', [self.slug])