template_name='catalogue/daisy_list.html')
-def counters(request):
- form = forms.SearchForm()
-
- books = models.Book.objects.count()
- books_nonempty = models.Book.objects.exclude(html_file='').count()
- books_empty = models.Book.objects.filter(html_file='').count()
- books_root = models.Book.objects.filter(parent=None).count()
-
- media = models.BookMedia.objects.count()
- media_types = models.BookMedia.objects.values('type').\
- annotate(count=Count('type')).\
- order_by('type')
- for mt in media_types:
- mt['size'] = sum(b.file.size for b in models.BookMedia.objects.filter(type=mt['type']))
- mt['deprecated'] = models.BookMedia.objects.filter(
- type=mt['type'], source_sha1=None).count() if mt['type'] in ('mp3', 'ogg') else '-'
-
- return render_to_response('catalogue/counters.html',
- locals(), context_instance=RequestContext(request))
-
-
def differentiate_tags(request, tags, ambiguous_slugs):
beginning = '/'.join(tag.url_chunk for tag in tags)
unparsed = '/'.join(ambiguous_slugs[1:])
if not project:
# temporary fallback
project = u'CzytamySłuchając'
-
- projects.add((project, meta.get('funded_by')))
+
+ projects.add((project, meta.get('funded_by', '')))
projects = sorted(projects)
form = forms.SearchForm()
return HttpResponse(datetime.now().strftime('%Y/%m/%d %H:%M:%S'))
-@cache.never_cache
-def xmls(request):
- """"
- Create a zip archive with all XML files.
- This should be removed when we have real API.
- """
- temp = tempfile.TemporaryFile()
- archive = zipfile.ZipFile(temp, 'w')
-
- for book in models.Book.objects.all():
- archive.write(book.xml_file.path, str('%s.xml' % book.slug))
- archive.close()
-
- response = HttpResponse(content_type='application/zip', mimetype='application/x-zip-compressed')
- response['Content-Disposition'] = 'attachment; filename=xmls.zip'
- response['Content-Length'] = temp.tell()
-
- temp.seek(0)
- response.write(temp.read())
- return response
-
-
-
# info views for API
def book_info(request, id, lang='pl'):