From b7ae5b70a9078eb80cfdff23abce9070dbf9b5f2 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 8 Nov 2010 18:43:59 +0100 Subject: [PATCH] Instance --- pandora/archive/admin.py | 4 ++-- pandora/archive/migrations/0001_initial.py | 24 +++++++++---------- pandora/archive/migrations/0002_volume.py | 22 ++++++++--------- pandora/archive/migrations/0003_file_time.py | 14 +++++------ pandora/archive/migrations/0004_file_name.py | 18 +++++++------- .../archive/migrations/0005_oshash_unique.py | 2 +- .../migrations/0006_addFileContents.py | 2 +- pandora/archive/migrations/0007_stream.py | 2 +- pandora/archive/migrations/0008_available.py | 2 +- .../archive/migrations/0009_rename_movie.py | 2 +- pandora/archive/models.py | 2 +- pandora/archive/views.py | 12 +++++----- 12 files changed, 53 insertions(+), 53 deletions(-) diff --git a/pandora/archive/admin.py b/pandora/archive/admin.py index 8526e00a6..4af841b8a 100644 --- a/pandora/archive/admin.py +++ b/pandora/archive/admin.py @@ -13,9 +13,9 @@ class FileAdmin(admin.ModelAdmin): admin.site.register(models.File, FileAdmin) -class FileInstanceAdmin(admin.ModelAdmin): +class InstanceAdmin(admin.ModelAdmin): search_fields = ['path', 'volume__name'] #form = ArchiveFileAdminForm -admin.site.register(models.FileInstance, FileInstanceAdmin) +admin.site.register(models.Instance, InstanceAdmin) diff --git a/pandora/archive/migrations/0001_initial.py b/pandora/archive/migrations/0001_initial.py index 653749f3d..03553167d 100644 --- a/pandora/archive/migrations/0001_initial.py +++ b/pandora/archive/migrations/0001_initial.py @@ -77,19 +77,19 @@ class Migration: )) db.send_create_signal('archive', ['File']) - # Adding model 'FileInstance' + # Adding model 'Instance' db.create_table('archive_fileinstance', ( - ('id', orm['archive.FileInstance:id']), - ('created', orm['archive.FileInstance:created']), - ('modified', orm['archive.FileInstance:modified']), - ('published', orm['archive.FileInstance:published']), - ('accessed', orm['archive.FileInstance:accessed']), - ('path', orm['archive.FileInstance:path']), - ('folder', orm['archive.FileInstance:folder']), - ('file', orm['archive.FileInstance:file']), - ('archive', orm['archive.FileInstance:archive']), + ('id', orm['archive.Instance:id']), + ('created', orm['archive.Instance:created']), + ('modified', orm['archive.Instance:modified']), + ('published', orm['archive.Instance:published']), + ('accessed', orm['archive.Instance:accessed']), + ('path', orm['archive.Instance:path']), + ('folder', orm['archive.Instance:folder']), + ('file', orm['archive.Instance:file']), + ('archive', orm['archive.Instance:archive']), )) - db.send_create_signal('archive', ['FileInstance']) + db.send_create_signal('archive', ['Instance']) @@ -107,7 +107,7 @@ class Migration: # Deleting model 'File' db.delete_table('archive_file') - # Deleting model 'FileInstance' + # Deleting model 'Instance' db.delete_table('archive_fileinstance') diff --git a/pandora/archive/migrations/0002_volume.py b/pandora/archive/migrations/0002_volume.py index 295284be8..96c8a838a 100644 --- a/pandora/archive/migrations/0002_volume.py +++ b/pandora/archive/migrations/0002_volume.py @@ -67,19 +67,19 @@ class Migration(SchemaMigration): # Deleting field 'fileinstance.archive' db.delete_column('archive_fileinstance', 'archive_id') - # Adding field 'FileInstance.ctime' + # Adding field 'Instance.ctime' db.add_column('archive_fileinstance', 'ctime', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now), keep_default=False) - # Adding field 'FileInstance.mtime' + # Adding field 'Instance.mtime' db.add_column('archive_fileinstance', 'mtime', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now), keep_default=False) - # Adding field 'FileInstance.atime' + # Adding field 'Instance.atime' db.add_column('archive_fileinstance', 'atime', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now), keep_default=False) - # Adding field 'FileInstance.volume' + # Adding field 'Instance.volume' db.add_column('archive_fileinstance', 'volume', self.gf('django.db.models.fields.related.ForeignKey')(default=None, related_name='files', to=orm['archive.Volume']), keep_default=False) - # Adding unique constraint on 'FileInstance', fields ['volume', 'path', 'folder'] + # Adding unique constraint on 'Instance', fields ['volume', 'path', 'folder'] db.create_unique('archive_fileinstance', ['volume_id', 'path', 'folder']) @@ -154,19 +154,19 @@ class Migration(SchemaMigration): # Adding field 'fileinstance.archive' db.add_column('archive_fileinstance', 'archive', self.gf('django.db.models.fields.related.ForeignKey')(default=None, related_name='files', to=orm['archive.Archive']), keep_default=False) - # Deleting field 'FileInstance.ctime' + # Deleting field 'Instance.ctime' db.delete_column('archive_fileinstance', 'ctime') - # Deleting field 'FileInstance.mtime' + # Deleting field 'Instance.mtime' db.delete_column('archive_fileinstance', 'mtime') - # Deleting field 'FileInstance.atime' + # Deleting field 'Instance.atime' db.delete_column('archive_fileinstance', 'atime') - # Deleting field 'FileInstance.volume' + # Deleting field 'Instance.volume' db.delete_column('archive_fileinstance', 'volume_id') - # Removing unique constraint on 'FileInstance', fields ['volume', 'path', 'folder'] + # Removing unique constraint on 'Instance', fields ['volume', 'path', 'folder'] db.delete_unique('archive_fileinstance', ['volume_id', 'path', 'folder']) @@ -209,7 +209,7 @@ class Migration(SchemaMigration): 'width': ('django.db.models.fields.IntegerField', [], {'default': '0'}) }, 'archive.fileinstance': { - 'Meta': {'unique_together': "(('path', 'folder', 'volume'),)", 'object_name': 'FileInstance'}, + 'Meta': {'unique_together': "(('path', 'folder', 'volume'),)", 'object_name': 'Instance'}, 'atime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'ctime': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), diff --git a/pandora/archive/migrations/0003_file_time.py b/pandora/archive/migrations/0003_file_time.py index 9a446a705..a3e56fcd6 100644 --- a/pandora/archive/migrations/0003_file_time.py +++ b/pandora/archive/migrations/0003_file_time.py @@ -8,28 +8,28 @@ class Migration(SchemaMigration): def forwards(self, orm): - # Changing field 'FileInstance.ctime' + # Changing field 'Instance.ctime' db.delete_column('archive_fileinstance', 'ctime') db.add_column('archive_fileinstance', 'ctime', self.gf('django.db.models.fields.IntegerField')()) - # Changing field 'FileInstance.mtime' + # Changing field 'Instance.mtime' db.delete_column('archive_fileinstance', 'mtime') db.add_column('archive_fileinstance', 'mtime', self.gf('django.db.models.fields.IntegerField')()) - # Changing field 'FileInstance.atime' + # Changing field 'Instance.atime' db.delete_column('archive_fileinstance', 'atime') db.add_column('archive_fileinstance', 'atime', self.gf('django.db.models.fields.IntegerField')()) def backwards(self, orm): - # Changing field 'FileInstance.ctime' + # Changing field 'Instance.ctime' db.alter_column('archive_fileinstance', 'ctime', self.gf('django.db.models.fields.DateTimeField')()) - # Changing field 'FileInstance.mtime' + # Changing field 'Instance.mtime' db.alter_column('archive_fileinstance', 'mtime', self.gf('django.db.models.fields.DateTimeField')()) - # Changing field 'FileInstance.atime' + # Changing field 'Instance.atime' db.alter_column('archive_fileinstance', 'atime', self.gf('django.db.models.fields.DateTimeField')()) @@ -72,7 +72,7 @@ class Migration(SchemaMigration): 'width': ('django.db.models.fields.IntegerField', [], {'default': '0'}) }, 'archive.fileinstance': { - 'Meta': {'unique_together': "(('path', 'folder', 'volume'),)", 'object_name': 'FileInstance'}, + 'Meta': {'unique_together': "(('path', 'folder', 'volume'),)", 'object_name': 'Instance'}, 'atime': ('django.db.models.fields.IntegerField', [], {'default': '1281357186.5094559'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'ctime': ('django.db.models.fields.IntegerField', [], {'default': '1281357186.5095601'}), diff --git a/pandora/archive/migrations/0004_file_name.py b/pandora/archive/migrations/0004_file_name.py index 9d78a334a..ceb624cac 100644 --- a/pandora/archive/migrations/0004_file_name.py +++ b/pandora/archive/migrations/0004_file_name.py @@ -8,31 +8,31 @@ class Migration(SchemaMigration): def forwards(self, orm): - # Deleting field 'FileInstance.path' + # Deleting field 'Instance.path' db.delete_column('archive_fileinstance', 'path') - # Adding field 'FileInstance.name' + # Adding field 'Instance.name' db.add_column('archive_fileinstance', 'name', self.gf('django.db.models.fields.CharField')(default='', max_length=2048), keep_default=False) - # Removing unique constraint on 'FileInstance', fields ['volume', 'path', 'folder'] + # Removing unique constraint on 'Instance', fields ['volume', 'path', 'folder'] #db.delete_unique('archive_fileinstance', ['volume_id', 'path', 'folder']) - # Adding unique constraint on 'FileInstance', fields ['volume', 'folder', 'name'] + # Adding unique constraint on 'Instance', fields ['volume', 'folder', 'name'] db.create_unique('archive_fileinstance', ['volume_id', 'folder', 'name']) def backwards(self, orm): - # Adding field 'FileInstance.path' + # Adding field 'Instance.path' db.add_column('archive_fileinstance', 'path', self.gf('django.db.models.fields.CharField')(default='', max_length=2048), keep_default=False) - # Deleting field 'FileInstance.name' + # Deleting field 'Instance.name' db.delete_column('archive_fileinstance', 'name') - # Adding unique constraint on 'FileInstance', fields ['volume', 'path', 'folder'] + # Adding unique constraint on 'Instance', fields ['volume', 'path', 'folder'] db.create_unique('archive_fileinstance', ['volume_id', 'path', 'folder']) - # Removing unique constraint on 'FileInstance', fields ['volume', 'folder', 'name'] + # Removing unique constraint on 'Instance', fields ['volume', 'folder', 'name'] db.delete_unique('archive_fileinstance', ['volume_id', 'folder', 'name']) @@ -75,7 +75,7 @@ class Migration(SchemaMigration): 'width': ('django.db.models.fields.IntegerField', [], {'default': '0'}) }, 'archive.fileinstance': { - 'Meta': {'unique_together': "(('name', 'folder', 'volume'),)", 'object_name': 'FileInstance'}, + 'Meta': {'unique_together': "(('name', 'folder', 'volume'),)", 'object_name': 'Instance'}, 'atime': ('django.db.models.fields.IntegerField', [], {'default': '1281358260'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'ctime': ('django.db.models.fields.IntegerField', [], {'default': '1281358260'}), diff --git a/pandora/archive/migrations/0005_oshash_unique.py b/pandora/archive/migrations/0005_oshash_unique.py index 41b7f2400..a203a2b92 100644 --- a/pandora/archive/migrations/0005_oshash_unique.py +++ b/pandora/archive/migrations/0005_oshash_unique.py @@ -57,7 +57,7 @@ class Migration(SchemaMigration): 'width': ('django.db.models.fields.IntegerField', [], {'default': '0'}) }, 'archive.fileinstance': { - 'Meta': {'unique_together': "(('name', 'folder', 'volume'),)", 'object_name': 'FileInstance'}, + 'Meta': {'unique_together': "(('name', 'folder', 'volume'),)", 'object_name': 'Instance'}, 'atime': ('django.db.models.fields.IntegerField', [], {'default': '1281372184'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'ctime': ('django.db.models.fields.IntegerField', [], {'default': '1281372184'}), diff --git a/pandora/archive/migrations/0006_addFileContents.py b/pandora/archive/migrations/0006_addFileContents.py index 6401cda34..a083f98c1 100644 --- a/pandora/archive/migrations/0006_addFileContents.py +++ b/pandora/archive/migrations/0006_addFileContents.py @@ -78,7 +78,7 @@ class Migration(SchemaMigration): 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}) }, 'archive.fileinstance': { - 'Meta': {'unique_together': "(('name', 'folder', 'volume'),)", 'object_name': 'FileInstance'}, + 'Meta': {'unique_together': "(('name', 'folder', 'volume'),)", 'object_name': 'Instance'}, 'atime': ('django.db.models.fields.IntegerField', [], {'default': '1282476196'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'ctime': ('django.db.models.fields.IntegerField', [], {'default': '1282476196'}), diff --git a/pandora/archive/migrations/0007_stream.py b/pandora/archive/migrations/0007_stream.py index cef839f3a..27ef24f18 100644 --- a/pandora/archive/migrations/0007_stream.py +++ b/pandora/archive/migrations/0007_stream.py @@ -99,7 +99,7 @@ class Migration(SchemaMigration): 'width': ('django.db.models.fields.IntegerField', [], {'default': '0'}) }, 'archive.fileinstance': { - 'Meta': {'unique_together': "(('name', 'folder', 'volume'),)", 'object_name': 'FileInstance'}, + 'Meta': {'unique_together': "(('name', 'folder', 'volume'),)", 'object_name': 'Instance'}, 'atime': ('django.db.models.fields.IntegerField', [], {'default': '1282732467'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'ctime': ('django.db.models.fields.IntegerField', [], {'default': '1282732467'}), diff --git a/pandora/archive/migrations/0008_available.py b/pandora/archive/migrations/0008_available.py index dfab018d2..71f068bab 100644 --- a/pandora/archive/migrations/0008_available.py +++ b/pandora/archive/migrations/0008_available.py @@ -59,7 +59,7 @@ class Migration(SchemaMigration): 'width': ('django.db.models.fields.IntegerField', [], {'default': '0'}) }, 'archive.fileinstance': { - 'Meta': {'unique_together': "(('name', 'folder', 'volume'),)", 'object_name': 'FileInstance'}, + 'Meta': {'unique_together': "(('name', 'folder', 'volume'),)", 'object_name': 'Instance'}, 'atime': ('django.db.models.fields.IntegerField', [], {'default': '1283966008'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'ctime': ('django.db.models.fields.IntegerField', [], {'default': '1283966008'}), diff --git a/pandora/archive/migrations/0009_rename_movie.py b/pandora/archive/migrations/0009_rename_movie.py index f0222ffe1..d772cf7a7 100644 --- a/pandora/archive/migrations/0009_rename_movie.py +++ b/pandora/archive/migrations/0009_rename_movie.py @@ -57,7 +57,7 @@ class Migration(SchemaMigration): 'width': ('django.db.models.fields.IntegerField', [], {'default': '0'}) }, 'archive.fileinstance': { - 'Meta': {'unique_together': "(('name', 'folder', 'volume'),)", 'object_name': 'FileInstance'}, + 'Meta': {'unique_together': "(('name', 'folder', 'volume'),)", 'object_name': 'Instance'}, 'atime': ('django.db.models.fields.IntegerField', [], {'default': '1285254686'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'ctime': ('django.db.models.fields.IntegerField', [], {'default': '1285254686'}), diff --git a/pandora/archive/models.py b/pandora/archive/models.py index 3bb8de3ba..a55f3d386 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -240,7 +240,7 @@ class Volume(models.Model): def __unicode__(self): return u"%s's %s"% (self.user, self.name) -class FileInstance(models.Model): +class Instance(models.Model): class Meta: unique_together = ("name", "folder", "volume") diff --git a/pandora/archive/views.py b/pandora/archive/views.py index 28a0398e6..bb7f91989 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -87,7 +87,7 @@ def api_update(request): oshash = f['oshash'] all_files.append(oshash) - same_folder = models.FileInstance.objects.filter(folder=folder, volume=volume) + same_folder = models.Instance.objects.filter(folder=folder, volume=volume) if same_folder.count() > 0: item = same_folder[0].file.item else: @@ -95,7 +95,7 @@ def api_update(request): path = os.path.join(folder, name) - instance = models.FileInstance.objects.filter(file__oshash=oshash, volume=volume) + instance = models.Instance.objects.filter(file__oshash=oshash, volume=volume) if instance.count()>0: instance = instance[0] updated = False @@ -121,7 +121,7 @@ def api_update(request): file_object.item = item file_object.save() response['data']['info'].append(oshash) - instance = models.FileInstance() + instance = models.Instance() instance.volume = volume instance.file = file_object for key in ('mtime', 'name', 'folder'): @@ -130,7 +130,7 @@ def api_update(request): #remove deleted files #FIXME: can this have any bad consequences? i.e. on the selction of used item files. - models.FileInstance.objects.filter(volume=volume).exclude(file__oshash__in=all_files).delete() + models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files).delete() user_profile = user.get_profile() user_profile.files_updated = datetime.now() @@ -139,7 +139,7 @@ def api_update(request): if 'info' in data: for oshash in data['info']: info = data['info'][oshash] - instance = models.FileInstance.objects.filter(file__oshash=oshash, volume__user=user) + instance = models.Instance.objects.filter(file__oshash=oshash, volume__user=user) if instance.count()>0: instance = instance[0] if not instance.file.info: @@ -149,7 +149,7 @@ def api_update(request): instance.file.info = info instance.file.save() - files = models.FileInstance.objects.filter(volume__user=user, file__available=False) + files = models.Instance.objects.filter(volume__user=user, file__available=False) if volume: files = files.filter(volume=volume) response['data']['info'] = [f.file.oshash for f in files.filter(file__info='{}')]