fix files/archive conflict, move item files to data/media, rename api from *File(s) to *Media
This commit is contained in:
parent
8f7a2094cd
commit
5c995553c9
8 changed files with 292 additions and 28 deletions
168
pandora/archive/migrations/0005_data_folders.py
Normal file
168
pandora/archive/migrations/0005_data_folders.py
Normal file
|
@ -0,0 +1,168 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import DataMigration
|
||||
from django.db import models
|
||||
|
||||
class Migration(DataMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
"Write your forwards methods here."
|
||||
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
|
||||
for s in orm['archive.Stream'].objects.all():
|
||||
s.video.name = s.video.name.replace('files/', 'media/')
|
||||
s.save()
|
||||
|
||||
def backwards(self, orm):
|
||||
"Write your backwards methods here."
|
||||
|
||||
models = {
|
||||
'archive.file': {
|
||||
'Meta': {'object_name': 'File'},
|
||||
'audio_codec': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'bits_per_pixel': ('django.db.models.fields.FloatField', [], {'default': '-1'}),
|
||||
'channels': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'data': ('django.db.models.fields.files.FileField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
|
||||
'display_aspect_ratio': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'duration': ('django.db.models.fields.FloatField', [], {'null': 'True'}),
|
||||
'extension': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True'}),
|
||||
'framerate': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'height': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'info': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||
'is_audio': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_subtitle': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_video': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'item': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'files'", 'null': 'True', 'to': "orm['item.Item']"}),
|
||||
'language': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '8', 'null': 'True'}),
|
||||
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||
'oshash': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '16'}),
|
||||
'part': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True'}),
|
||||
'part_title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True'}),
|
||||
'path': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '2048'}),
|
||||
'pixel_format': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'pixels': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}),
|
||||
'samplerate': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'selected': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'size': ('django.db.models.fields.BigIntegerField', [], {'default': '0'}),
|
||||
'sort_path': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '2048'}),
|
||||
'type': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255'}),
|
||||
'uploading': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'version': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '255', 'null': 'True'}),
|
||||
'video_codec': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'wanted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'width': ('django.db.models.fields.IntegerField', [], {'default': '0'})
|
||||
},
|
||||
'archive.frame': {
|
||||
'Meta': {'unique_together': "(('file', 'position'),)", 'object_name': 'Frame'},
|
||||
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'file': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'frames'", 'to': "orm['archive.File']"}),
|
||||
'frame': ('django.db.models.fields.files.ImageField', [], {'default': 'None', 'max_length': '100', 'null': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||
'position': ('django.db.models.fields.FloatField', [], {})
|
||||
},
|
||||
'archive.instance': {
|
||||
'Meta': {'unique_together': "(('path', 'volume'),)", 'object_name': 'Instance'},
|
||||
'atime': ('django.db.models.fields.IntegerField', [], {'default': '1364213876'}),
|
||||
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'ctime': ('django.db.models.fields.IntegerField', [], {'default': '1364213876'}),
|
||||
'file': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'instances'", 'to': "orm['archive.File']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'ignore': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||
'mtime': ('django.db.models.fields.IntegerField', [], {'default': '1364213876'}),
|
||||
'path': ('django.db.models.fields.CharField', [], {'max_length': '2048'}),
|
||||
'volume': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'files'", 'to': "orm['archive.Volume']"})
|
||||
},
|
||||
'archive.stream': {
|
||||
'Meta': {'unique_together': "(('file', 'resolution', 'format'),)", 'object_name': 'Stream'},
|
||||
'aspect_ratio': ('django.db.models.fields.FloatField', [], {'default': '0'}),
|
||||
'available': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'color': ('ox.django.fields.TupleField', [], {'default': '[]'}),
|
||||
'cuts': ('ox.django.fields.TupleField', [], {'default': '[]'}),
|
||||
'duration': ('django.db.models.fields.FloatField', [], {'default': '0'}),
|
||||
'file': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'streams'", 'to': "orm['archive.File']"}),
|
||||
'format': ('django.db.models.fields.CharField', [], {'default': "'webm'", 'max_length': '255'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'info': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||
'oshash': ('django.db.models.fields.CharField', [], {'max_length': '16', 'null': 'True', 'db_index': 'True'}),
|
||||
'resolution': ('django.db.models.fields.IntegerField', [], {'default': '96'}),
|
||||
'source': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'related_name': "'derivatives'", 'null': 'True', 'to': "orm['archive.Stream']"}),
|
||||
'video': ('django.db.models.fields.files.FileField', [], {'default': 'None', 'max_length': '100', 'blank': 'True'}),
|
||||
'volume': ('django.db.models.fields.FloatField', [], {'default': '0'})
|
||||
},
|
||||
'archive.volume': {
|
||||
'Meta': {'unique_together': "(('user', 'name'),)", 'object_name': 'Volume'},
|
||||
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '1024'}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'volumes'", 'to': "orm['auth.User']"})
|
||||
},
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
|
||||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||
},
|
||||
'auth.permission': {
|
||||
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '255', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'password': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
|
||||
},
|
||||
'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
'item.item': {
|
||||
'Meta': {'object_name': 'Item'},
|
||||
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'data': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||
'external_data': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'items'", 'blank': 'True', 'to': "orm['auth.Group']"}),
|
||||
'icon': ('django.db.models.fields.files.ImageField', [], {'default': 'None', 'max_length': '100', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'itemId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}),
|
||||
'json': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||
'level': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
|
||||
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||
'oxdbId': ('django.db.models.fields.CharField', [], {'max_length': '42', 'unique': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'poster': ('django.db.models.fields.files.ImageField', [], {'default': 'None', 'max_length': '100', 'blank': 'True'}),
|
||||
'poster_frame': ('django.db.models.fields.FloatField', [], {'default': '-1'}),
|
||||
'poster_height': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'poster_source': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'poster_width': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'rendered': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
|
||||
'stream_aspect': ('django.db.models.fields.FloatField', [], {'default': '1.3333333333333333'}),
|
||||
'stream_info': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||
'torrent': ('django.db.models.fields.files.FileField', [], {'default': 'None', 'max_length': '1000', 'blank': 'True'}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'items'", 'null': 'True', 'to': "orm['auth.User']"})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['archive']
|
||||
symmetrical = True
|
|
@ -218,7 +218,7 @@ class File(models.Model):
|
|||
|
||||
def get_path(self, name):
|
||||
h = self.oshash
|
||||
return os.path.join('files', h[:2], h[2:4], h[4:6], h[6:], name)
|
||||
return os.path.join('media', h[:2], h[2:4], h[4:6], h[6:], name)
|
||||
|
||||
def contents(self):
|
||||
if self.data != None:
|
||||
|
|
|
@ -166,7 +166,7 @@ class VideoChunkForm(forms.Form):
|
|||
done = forms.IntegerField(required=False)
|
||||
|
||||
@login_required_json
|
||||
def addFile(request):
|
||||
def addMedia(request):
|
||||
'''
|
||||
takes {
|
||||
id: oshash
|
||||
|
@ -216,7 +216,7 @@ def addFile(request):
|
|||
response['data']['item'] = i.itemId
|
||||
response['data']['itemUrl'] = request.build_absolute_uri('/%s' % i.itemId)
|
||||
return render_to_json_response(response)
|
||||
actions.register(addFile, cache=False)
|
||||
actions.register(addMedia, cache=False)
|
||||
|
||||
@login_required_json
|
||||
def firefogg_upload(request):
|
||||
|
@ -289,7 +289,7 @@ actions.register(taskStatus, cache=False)
|
|||
|
||||
|
||||
@login_required_json
|
||||
def moveFiles(request):
|
||||
def moveMedia(request):
|
||||
'''
|
||||
change file / item link
|
||||
takes {
|
||||
|
@ -333,10 +333,10 @@ def moveFiles(request):
|
|||
response = json_response(text='updated')
|
||||
response['data']['itemId'] = i.itemId
|
||||
return render_to_json_response(response)
|
||||
actions.register(moveFiles, cache=False)
|
||||
actions.register(moveMedia, cache=False)
|
||||
|
||||
@login_required_json
|
||||
def editFiles(request):
|
||||
def editMedia(request):
|
||||
'''
|
||||
change file / item link
|
||||
takes {
|
||||
|
@ -385,11 +385,11 @@ def editFiles(request):
|
|||
i.update_selected()
|
||||
i.update_wanted()
|
||||
return render_to_json_response(response)
|
||||
actions.register(editFiles, cache=False)
|
||||
actions.register(editMedia, cache=False)
|
||||
|
||||
|
||||
@login_required_json
|
||||
def removeFiles(request):
|
||||
def removeMedia(request):
|
||||
data = json.loads(request.POST['data'])
|
||||
response = json_response()
|
||||
if request.user.get_profile().get_level() == 'admin':
|
||||
|
@ -402,7 +402,7 @@ def removeFiles(request):
|
|||
else:
|
||||
response = json_response(status=403, text='permissino denied')
|
||||
return render_to_json_response(response)
|
||||
actions.register(removeFiles, cache=False)
|
||||
actions.register(removeMedia, cache=False)
|
||||
|
||||
def getPath(request):
|
||||
'''
|
||||
|
@ -460,7 +460,7 @@ def _order_query(qs, sort, prefix=''):
|
|||
return qs
|
||||
|
||||
|
||||
def findFiles(request):
|
||||
def findMedia(request):
|
||||
'''
|
||||
takes {
|
||||
'query': query,
|
||||
|
@ -594,7 +594,7 @@ Positions
|
|||
response['data']['items'] = files.count()
|
||||
return render_to_json_response(response)
|
||||
|
||||
actions.register(findFiles)
|
||||
actions.register(findMedia)
|
||||
|
||||
def parsePath(request): #parse path and return info
|
||||
'''
|
||||
|
@ -610,7 +610,7 @@ def parsePath(request): #parse path and return info
|
|||
return render_to_json_response(response)
|
||||
actions.register(parsePath)
|
||||
|
||||
def getFileInfo(request):
|
||||
def getMediaInfo(request):
|
||||
'''
|
||||
takes {
|
||||
id: oshash of stream file
|
||||
|
@ -637,5 +637,5 @@ def getFileInfo(request):
|
|||
'item': f.item.itemId
|
||||
}
|
||||
return render_to_json_response(response)
|
||||
actions.register(getFileInfo)
|
||||
actions.register(getMediaInfo)
|
||||
|
||||
|
|
98
pandora/file/migrations/0002_data_folders.py
Normal file
98
pandora/file/migrations/0002_data_folders.py
Normal file
|
@ -0,0 +1,98 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import DataMigration
|
||||
from django.db import models
|
||||
|
||||
class Migration(DataMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
"Write your forwards methods here."
|
||||
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
|
||||
import os
|
||||
from os.path import exists
|
||||
from django.conf import settings
|
||||
|
||||
media_path = os.path.join(settings.MEDIA_ROOT, 'media')
|
||||
files_path = os.path.join(settings.MEDIA_ROOT, 'files')
|
||||
uploads_path = os.path.join(settings.MEDIA_ROOT, 'uploads')
|
||||
if not exists(media_path) and exists(files_path):
|
||||
os.rename(files_path, media_path)
|
||||
if not exists(files_path) and exists(uploads_path):
|
||||
os.rename(uploads_path, files_path)
|
||||
for f in orm['file.File'].objects.all():
|
||||
f.file.name = f.file.name.replace('uploads/', 'files/')
|
||||
f.save()
|
||||
|
||||
def backwards(self, orm):
|
||||
import os
|
||||
from os.path import exists
|
||||
from django.conf import settings
|
||||
|
||||
media_path = os.path.join(settings.MEDIA_ROOT, 'media')
|
||||
files_path = os.path.join(settings.MEDIA_ROOT, 'files')
|
||||
uploads_path = os.path.join(settings.MEDIA_ROOT, 'uploads')
|
||||
if exists(media_path) and exists(files_path) and not exists(uploads_path):
|
||||
os.rename(files_path, uploads_path)
|
||||
if exists(media_path) and not exists(files_path):
|
||||
os.rename(media_path, files_path)
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
|
||||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||
},
|
||||
'auth.permission': {
|
||||
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '255', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'password': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
|
||||
},
|
||||
'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
'file.file': {
|
||||
'Meta': {'unique_together': "(('user', 'name', 'extension'),)", 'object_name': 'File'},
|
||||
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'description': ('django.db.models.fields.TextField', [], {'default': "''"}),
|
||||
'description_sort': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
|
||||
'extension': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'file': ('django.db.models.fields.files.FileField', [], {'default': 'None', 'max_length': '100', 'null': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'matches': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'name_sort': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'oshash': ('django.db.models.fields.CharField', [], {'max_length': '16', 'unique': 'True', 'null': 'True'}),
|
||||
'ratio': ('django.db.models.fields.FloatField', [], {'default': '1'}),
|
||||
'size': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'uploading': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'files'", 'to': "orm['auth.User']"})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['file']
|
||||
symmetrical = True
|
|
@ -48,8 +48,8 @@ class File(models.Model):
|
|||
if self.extension == 'pdf' and not os.path.exists(self.thumbnail()):
|
||||
self.make_thumbnail()
|
||||
|
||||
self.name_sort = ox.sort_string(self.name or u'')[:255]
|
||||
self.description_sort = ox.sort_string(self.description or u'')[:512]
|
||||
self.name_sort = ox.sort_string(self.name or u'')[:255].lower()
|
||||
self.description_sort = ox.sort_string(self.description or u'')[:512].lower()
|
||||
|
||||
super(File, self).save(*args, **kwargs)
|
||||
|
||||
|
@ -130,7 +130,7 @@ class File(models.Model):
|
|||
|
||||
def path(self, name=''):
|
||||
h = "%07d" % self.id
|
||||
return os.path.join('uploads', h[:2], h[2:4], h[4:6], h[6:], name)
|
||||
return os.path.join('files', h[:2], h[2:4], h[4:6], h[6:], name)
|
||||
|
||||
def save_chunk(self, chunk, chunk_id=-1, done=False):
|
||||
if self.uploading:
|
||||
|
|
|
@ -217,7 +217,7 @@ pandora.ui.filesView = function(options, self) {
|
|||
columnsVisible: true,
|
||||
id: 'files',
|
||||
items: function(data, callback) {
|
||||
pandora.api.findFiles(Ox.extend(data, {
|
||||
pandora.api.findMedia(Ox.extend(data, {
|
||||
query: self.filesQuery
|
||||
}), callback);
|
||||
},
|
||||
|
@ -231,7 +231,7 @@ pandora.ui.filesView = function(options, self) {
|
|||
if (data.key == 'selected') {
|
||||
var ignored = self.$filesList.value(data.id, 'instances')
|
||||
.filter(function(i) {return i.ignore; }).length > 0;
|
||||
pandora.api.editFiles({
|
||||
pandora.api.editMedia({
|
||||
files: [{
|
||||
id: data.id,
|
||||
ignore: !ignored
|
||||
|
@ -247,7 +247,7 @@ pandora.ui.filesView = function(options, self) {
|
|||
return self.$filesList.value(id, 'instances').length == 0;
|
||||
});
|
||||
if (ids.length > 0 && pandora.user.level == 'admin') {
|
||||
pandora.api.removeFiles({
|
||||
pandora.api.removeMedia({
|
||||
ids: ids
|
||||
}, function(result) {
|
||||
Ox.Request.clearCache();
|
||||
|
@ -456,7 +456,7 @@ pandora.ui.filesView = function(options, self) {
|
|||
}
|
||||
|
||||
function ignoreFiles() {
|
||||
pandora.api.editFiles({
|
||||
pandora.api.editMedia({
|
||||
files: self.selected.map(function(id) {
|
||||
return {id: id, ignore: true};
|
||||
})
|
||||
|
@ -477,7 +477,7 @@ pandora.ui.filesView = function(options, self) {
|
|||
self.$moveButton.options(
|
||||
{disabled: true, title: 'Moving Files...'}
|
||||
);
|
||||
pandora.api.moveFiles(data, function(result) {
|
||||
pandora.api.moveMedia(data, function(result) {
|
||||
if (
|
||||
pandora.user.ui.item == self.options.id
|
||||
&& pandora.user.ui.itemView == 'files'
|
||||
|
@ -526,11 +526,11 @@ pandora.ui.filesView = function(options, self) {
|
|||
|
||||
function saveChanges() {
|
||||
self.$saveButton.options({disabled: true, title: 'Saving Changes...'});
|
||||
pandora.api.findFiles({
|
||||
pandora.api.findMedia({
|
||||
keys: ['id'],
|
||||
query: self.filesQuery
|
||||
}, function(result) {
|
||||
pandora.api.editFiles({
|
||||
pandora.api.editMedia({
|
||||
files: result.data.items.map(function(item) {
|
||||
[
|
||||
'version', 'part', 'partTitle', 'language', 'extension'
|
||||
|
|
|
@ -332,9 +332,7 @@ pandora.ui.mainMenu = function() {
|
|||
} else if (data.id == 'findsimilar') {
|
||||
pandora.$ui.sequencesDialog = pandora.ui.sequencesDialog().open();
|
||||
} else if (data.id == 'files') {
|
||||
(pandora.$ui.filesDialog || (
|
||||
pandora.$ui.filesDialog = pandora.ui.filesDialog()
|
||||
)).open();
|
||||
pandora.$ui.filesDialog = pandora.ui.filesDialog().open();
|
||||
} else if (data.id == 'titles') {
|
||||
(pandora.$ui.titlesDialog || (
|
||||
pandora.$ui.titlesDialog = pandora.ui.titlesDialog()
|
||||
|
|
|
@ -154,7 +154,7 @@ pandora.ui.uploadDialog = function(data) {
|
|||
item,
|
||||
oshash = info.oshash;
|
||||
resetProgress();
|
||||
pandora.api.addFile({
|
||||
pandora.api.addMedia({
|
||||
filename: filename,
|
||||
id: oshash,
|
||||
info: info,
|
||||
|
@ -337,7 +337,7 @@ pandora.ui.uploadDialog = function(data) {
|
|||
oshash = info.oshash,
|
||||
filename = pandora.firefogg.sourceFilename,
|
||||
item;
|
||||
pandora.api.findFiles({
|
||||
pandora.api.findMedia({
|
||||
query: {
|
||||
conditions: [{key: 'oshash', value: oshash}]
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue