This commit is contained in:
j 2010-11-08 18:43:59 +01:00
parent b483f330c2
commit b7ae5b70a9
12 changed files with 53 additions and 53 deletions

View file

@ -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)

View file

@ -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')

View file

@ -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'}),

View file

@ -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'}),

View file

@ -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'}),

View file

@ -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'}),

View file

@ -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'}),

View file

@ -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'}),

View file

@ -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'}),

View file

@ -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'}),

View file

@ -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")

View file

@ -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='{}')]