collection icons
This commit is contained in:
parent
5eb7d8c99f
commit
5129b75650
4 changed files with 283 additions and 22 deletions
22
pandora/documentcollection/migrations/0004_jsonfield.py
Normal file
22
pandora/documentcollection/migrations/0004_jsonfield.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.4 on 2018-06-19 17:23
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django.contrib.postgres.fields.jsonb
|
||||
from django.db import migrations, models
|
||||
|
||||
def remove_posterframes(apps, schema_editor):
|
||||
Collection = apps.get_model("documentcollection", "Collection")
|
||||
for c in Collection.objects.exclude(poster_frames=None):
|
||||
c.poster_frames = []
|
||||
c.save()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('documentcollection', '0003_jsonfield'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(remove_posterframes),
|
||||
]
|
||||
|
|
@ -265,38 +265,23 @@ class Collection(models.Model):
|
|||
|
||||
def update_icon(self):
|
||||
frames = []
|
||||
#fixme
|
||||
'''
|
||||
if not self.poster_frames:
|
||||
documents = self.get_documents(self.user)
|
||||
documents = self.get_documents(self.user).all()
|
||||
if documents.count():
|
||||
poster_frames = []
|
||||
for i in range(0, documents.count(), max(1, int(documents.count()/4))):
|
||||
poster_frames.append({
|
||||
'document': documents[int(i)].id,
|
||||
'position': documents[int(i)].poster_frame
|
||||
'document': documents[int(i)].get_id(),
|
||||
#'page': documents[int(i)]
|
||||
})
|
||||
self.poster_frames = tuple(poster_frames)
|
||||
self.save()
|
||||
for i in self.poster_frames:
|
||||
from document.models import Document
|
||||
qs = Document.objects.filter(id=i['document'])
|
||||
qs = Document.objects.filter(id=ox.fromAZ(i['document']))
|
||||
if qs.count() > 0:
|
||||
if i.get('position'):
|
||||
frame = qs[0].frame(i['position'])
|
||||
if frame:
|
||||
frames.append(frame)
|
||||
'''
|
||||
from item.models import Item
|
||||
for i in self.poster_frames:
|
||||
try:
|
||||
qs = Item.objects.filter(public_id=i['item'])
|
||||
if qs.count() > 0:
|
||||
frame = qs[0].frame(i['position'])
|
||||
if frame:
|
||||
frames.append(frame)
|
||||
except:
|
||||
pass
|
||||
frame = qs[0].thumbnail(size=1024, page=i.get('page'))
|
||||
frames.append(frame)
|
||||
self.icon.name = self.path('icon.jpg')
|
||||
icon = self.icon.path
|
||||
if frames:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue