diff --git a/pandora/layer/__init__.py b/pandora/annotaion/__init__.py similarity index 100% rename from pandora/layer/__init__.py rename to pandora/annotaion/__init__.py diff --git a/pandora/layer/admin.py b/pandora/annotaion/admin.py similarity index 72% rename from pandora/layer/admin.py rename to pandora/annotaion/admin.py index 0426ae38..9566cc40 100644 --- a/pandora/layer/admin.py +++ b/pandora/annotaion/admin.py @@ -6,11 +6,11 @@ from django.contrib import admin import models -class BinAdmin(admin.ModelAdmin): - search_fields = ['name', 'title'] -admin.site.register(models.Bin, BinAdmin) - class LayerAdmin(admin.ModelAdmin): search_fields = ['name', 'title'] admin.site.register(models.Layer, LayerAdmin) +class AnnotationAdmin(admin.ModelAdmin): + search_fields = ['name', 'title'] +admin.site.register(models.Annotation, AnnotationAdmin) + diff --git a/pandora/layer/models.py b/pandora/annotaion/models.py similarity index 92% rename from pandora/layer/models.py rename to pandora/annotaion/models.py index fdcef3c1..6a41e8b3 100644 --- a/pandora/layer/models.py +++ b/pandora/annotaion/models.py @@ -24,7 +24,7 @@ from ox import stripTags from ox.normalize import canonicalTitle, canonicalName -class Bin(models.Model): +class Layer(models.Model): class Meta: ordering = ('position', ) @@ -42,7 +42,7 @@ class Bin(models.Model): subtitle = models.BooleanField(default=True) #bis can be displayed as subtitle, only one bin find = models.BooleanField(default=True) - #words / item duration(wpm), total words, cuts per minute, cuts, number of layers, number of layers/duration + #words / item duration(wpm), total words, cuts per minute, cuts, number of annotations, number of annotations/duration sort = models.CharField(null=True, max_length=255) def properties(self): @@ -53,7 +53,10 @@ class Bin(models.Model): print 'FIXME: need to add sort stuff' return p -class Layer(models.Model): + def json(self): + return {'id': self.name, 'title': self.title, 'type': self.type} + +class Annotation(models.Model): #FIXME: here having a item,start index would be good created = models.DateTimeField(auto_now_add=True) modified = models.DateTimeField(auto_now=True) @@ -66,9 +69,6 @@ class Layer(models.Model): type = models.CharField(blank=True, max_length=255) value = models.TextField() - - #FIXME: relational layers, Locations, clips etc - #location = models.ForeignKey('Location', default=None) def editable(self, user): if user.is_authenticated(): diff --git a/pandora/layer/tests.py b/pandora/annotaion/tests.py similarity index 100% rename from pandora/layer/tests.py rename to pandora/annotaion/tests.py diff --git a/pandora/layer/views.py b/pandora/annotaion/views.py similarity index 100% rename from pandora/layer/views.py rename to pandora/annotaion/views.py diff --git a/pandora/item/models.py b/pandora/item/models.py index ff3e38c7..2dcda7fc 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -30,7 +30,7 @@ import utils import tasks from archive import extract -from layer.models import Layer +from annotaion.models import Annotation, Layer from person.models import get_name_sort, Person @@ -47,6 +47,8 @@ def siteJson(): r['findKeys'].append(f) r['groups'] = [p.name for p in Property.objects.filter(group=True)] + r['layers'] = [l.json() for l in Layer.objects()] + r['itemViews'] = [ {"id": "info", "title": "Info"}, {"id": "statistics", "title": "Statistics"}, @@ -286,7 +288,7 @@ class Item(models.Model): def save(self, *args, **kwargs): self.json = self.get_json() if not self.oxdbId: - self.oxdbId = self.oxid() + self.oxdbId = self.oxdb_id() if self.poster: self.poster_height = self.poster.height @@ -412,7 +414,7 @@ class Item(models.Model): layers['cuts'] = self.data.get('cuts', {}) layers['subtitles'] = {} - #FIXME: subtitles should be stored in Layer + #FIXME: subtitles should be stored in Annotation qs = self.files.filter(is_subtitle=True, is_main=True, available=True) if qs.count()>0: layers['subtitles'] = qs[0].srt() @@ -456,6 +458,10 @@ class Item(models.Model): self.get('series title', ''), self.get('episode title', ''), self.get('season', ''), self.get('episode', '')) + def oxdb_id(self): + return utils.oxdb_id(self.get('title', ''), self.get('directors', []), str(self.get('year', '')), + self.get('season', ''), self.get('episode', ''), + self.get('episode_title', ''), self.get('episode_directors', ''), self.get('episode_year', '')) ''' Search related functions @@ -490,7 +496,7 @@ class Item(models.Model): #FIXME: #f.dialog = 'fixme' - save('dialog', '\n'.join([l.value for l in Layer.objects.filter(type='subtitle', item=self).order_by('start')])) + save('dialog', '\n'.join([l.value for l in Annotation.objects.filter(type='subtitle', item=self).order_by('start')])) #FIXME: collate filenames #f.filename = self.filename diff --git a/pandora/item/utils.py b/pandora/item/utils.py index a2ea33bd..e6e87220 100644 --- a/pandora/item/utils.py +++ b/pandora/item/utils.py @@ -30,11 +30,12 @@ def oxid(title, directors, year='', seriesTitle='', episodeTitle='', season=0, e oxid += hashlib.sha1(oxid_value.encode('utf-8')).hexdigest()[:20] return u"0x" + oxid -def oxdb_id(title, directors=[], year='', season='', episode='', episode_title='', episode_director='', episode_year=''): +def oxdb_id(title, directors=[], year='', season='', episode='', episode_title='', episode_directors=[], episode_year=''): # new id function, will replace oxid() def get_hash(string): return hashlib.sha1(string.encode('utf-8')).hexdigest().upper() director = ', '.join(directors) + episode_director = ', '.join(episode_directors) if not episode: oxdb_id = get_hash(director)[:8] + get_hash('\n'.join([title, year]))[:8] else: diff --git a/pandora/settings.py b/pandora/settings.py index 0e4e52db..a9c69575 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -117,13 +117,13 @@ INSTALLED_APPS = ( # 'south', 'djcelery', + 'annotaion', 'app', 'api', 'archive', 'date', 'item', 'itemlist', - 'layer', 'person', 'place', 'text',