Commit 00ff54e2 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

astakos: Reintroduce foreign key from Resource to Service

Also merge all migrations from 0026 to 0032.
parent c315efc0
......@@ -8,6 +8,33 @@ class Migration(SchemaMigration):
def forwards(self, orm):
# Removing unique constraint on 'Resource', fields ['name', 'service']
db.delete_unique('im_resource', ['name', 'service_id'])
# Deleting model 'ResourceMetadata'
db.delete_table('im_resourcemetadata')
# Deleting field 'AstakosUserQuota.import_limit'
db.delete_column('im_astakosuserquota', 'import_limit')
# Deleting field 'AstakosUserQuota.export_limit'
db.delete_column('im_astakosuserquota', 'export_limit')
# Deleting field 'AstakosUserQuota.quantity'
db.delete_column('im_astakosuserquota', 'quantity')
# Deleting field 'Service.order'
db.delete_column('im_service', 'order')
# Deleting field 'Service.icon'
db.delete_column('im_service', 'icon')
# Adding field 'Service.api_url'
db.add_column('im_service', 'api_url', self.gf('django.db.models.fields.CharField')(max_length=255, null=True), keep_default=False)
# Changing field 'Service.url'
db.alter_column('im_service', 'url', self.gf('django.db.models.fields.CharField')(max_length=255, null=True))
# Deleting field 'Project.is_active'
db.delete_column('im_project', 'is_active')
......@@ -29,9 +56,65 @@ class Migration(SchemaMigration):
# Deleting field 'ProjectMembership.is_pending'
db.delete_column('im_projectmembership', 'is_pending')
# Deleting field 'Resource.group'
db.delete_column('im_resource', 'group')
# Removing M2M table for field meta on 'Resource'
db.delete_table('im_resource_meta')
# Adding unique constraint on 'Resource', fields ['name']
db.create_unique('im_resource', ['name'])
# Deleting field 'ProjectResourceGrant.member_import_limit'
db.delete_column('im_projectresourcegrant', 'member_import_limit')
# Deleting field 'ProjectResourceGrant.project_export_limit'
db.delete_column('im_projectresourcegrant', 'project_export_limit')
# Deleting field 'ProjectResourceGrant.project_import_limit'
db.delete_column('im_projectresourcegrant', 'project_import_limit')
# Deleting field 'ProjectResourceGrant.member_export_limit'
db.delete_column('im_projectresourcegrant', 'member_export_limit')
# Changing field 'ProjectResourceGrant.project_capacity'
db.alter_column('im_projectresourcegrant', 'project_capacity', self.gf('snf_django.lib.db.fields.IntDecimalField')(null=True, max_digits=38, decimal_places=0))
def backwards(self, orm):
# Removing unique constraint on 'Resource', fields ['name']
db.delete_unique('im_resource', ['name'])
# Adding model 'ResourceMetadata'
db.create_table('im_resourcemetadata', (
('value', self.gf('django.db.models.fields.CharField')(max_length=255)),
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('key', self.gf('django.db.models.fields.CharField')(max_length=255, unique=True, db_index=True)),
))
db.send_create_signal('im', ['ResourceMetadata'])
# Adding field 'AstakosUserQuota.import_limit'
db.add_column('im_astakosuserquota', 'import_limit', self.gf('snf_django.lib.db.fields.IntDecimalField')(default=100000000000000000000000000000000L, max_digits=38, decimal_places=0), keep_default=False)
# Adding field 'AstakosUserQuota.export_limit'
db.add_column('im_astakosuserquota', 'export_limit', self.gf('snf_django.lib.db.fields.IntDecimalField')(default=100000000000000000000000000000000L, max_digits=38, decimal_places=0), keep_default=False)
# Adding field 'AstakosUserQuota.quantity'
db.add_column('im_astakosuserquota', 'quantity', self.gf('snf_django.lib.db.fields.IntDecimalField')(default=0, max_digits=38, decimal_places=0), keep_default=False)
# Adding field 'Service.order'
db.add_column('im_service', 'order', self.gf('django.db.models.fields.PositiveIntegerField')(default=0), keep_default=False)
# Adding field 'Service.icon'
db.add_column('im_service', 'icon', self.gf('django.db.models.fields.FilePathField')(default='', max_length=100, blank=True), keep_default=False)
# Deleting field 'Service.api_url'
db.delete_column('im_service', 'api_url')
# Changing field 'Service.url'
db.alter_column('im_service', 'url', self.gf('django.db.models.fields.FilePathField')(default='', max_length=100))
# Adding field 'Project.is_active'
db.add_column('im_project', 'is_active', self.gf('django.db.models.fields.BooleanField')(default=True, db_index=True), keep_default=False)
......@@ -53,6 +136,35 @@ class Migration(SchemaMigration):
# Adding field 'ProjectMembership.is_pending'
db.add_column('im_projectmembership', 'is_pending', self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False)
# Adding field 'Resource.group'
db.add_column('im_resource', 'group', self.gf('django.db.models.fields.CharField')(max_length=255, null=True), keep_default=False)
# Adding M2M table for field meta on 'Resource'
db.create_table('im_resource_meta', (
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
('resource', models.ForeignKey(orm['im.resource'], null=False)),
('resourcemetadata', models.ForeignKey(orm['im.resourcemetadata'], null=False))
))
db.create_unique('im_resource_meta', ['resource_id', 'resourcemetadata_id'])
# Adding unique constraint on 'Resource', fields ['name', 'service']
db.create_unique('im_resource', ['name', 'service_id'])
# Adding field 'ProjectResourceGrant.member_import_limit'
db.add_column('im_projectresourcegrant', 'member_import_limit', self.gf('snf_django.lib.db.fields.IntDecimalField')(default=100000000000000000000000000000000L, max_digits=38, decimal_places=0), keep_default=False)
# Adding field 'ProjectResourceGrant.project_export_limit'
db.add_column('im_projectresourcegrant', 'project_export_limit', self.gf('snf_django.lib.db.fields.IntDecimalField')(default=100000000000000000000000000000000L, max_digits=38, decimal_places=0), keep_default=False)
# Adding field 'ProjectResourceGrant.project_import_limit'
db.add_column('im_projectresourcegrant', 'project_import_limit', self.gf('snf_django.lib.db.fields.IntDecimalField')(default=100000000000000000000000000000000L, max_digits=38, decimal_places=0), keep_default=False)
# Adding field 'ProjectResourceGrant.member_export_limit'
db.add_column('im_projectresourcegrant', 'member_export_limit', self.gf('snf_django.lib.db.fields.IntDecimalField')(default=100000000000000000000000000000000L, max_digits=38, decimal_places=0), keep_default=False)
# Changing field 'ProjectResourceGrant.project_capacity'
db.alter_column('im_projectresourcegrant', 'project_capacity', self.gf('snf_django.lib.db.fields.IntDecimalField')(max_digits=38, decimal_places=0))
models = {
'auth.group': {
......@@ -140,10 +252,7 @@ class Migration(SchemaMigration):
'im.astakosuserquota': {
'Meta': {'unique_together': "(('resource', 'user'),)", 'object_name': 'AstakosUserQuota'},
'capacity': ('snf_django.lib.db.fields.IntDecimalField', [], {'max_digits': '38', 'decimal_places': '0'}),
'export_limit': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '100000000000000000000000000000000L', 'max_digits': '38', 'decimal_places': '0'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'import_limit': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '100000000000000000000000000000000L', 'max_digits': '38', 'decimal_places': '0'}),
'quantity': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '0', 'max_digits': '38', 'decimal_places': '0'}),
'resource': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.Resource']"}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosUser']"})
},
......@@ -259,13 +368,9 @@ class Migration(SchemaMigration):
'im.projectresourcegrant': {
'Meta': {'unique_together': "(('resource', 'project_application'),)", 'object_name': 'ProjectResourceGrant'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'member_capacity': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '100000000000000000000000000000000L', 'max_digits': '38', 'decimal_places': '0'}),
'member_export_limit': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '100000000000000000000000000000000L', 'max_digits': '38', 'decimal_places': '0'}),
'member_import_limit': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '100000000000000000000000000000000L', 'max_digits': '38', 'decimal_places': '0'}),
'member_capacity': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '0', 'max_digits': '38', 'decimal_places': '0'}),
'project_application': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.ProjectApplication']", 'null': 'True'}),
'project_capacity': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '100000000000000000000000000000000L', 'max_digits': '38', 'decimal_places': '0'}),
'project_export_limit': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '100000000000000000000000000000000L', 'max_digits': '38', 'decimal_places': '0'}),
'project_import_limit': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '100000000000000000000000000000000L', 'max_digits': '38', 'decimal_places': '0'}),
'project_capacity': ('snf_django.lib.db.fields.IntDecimalField', [], {'null': 'True', 'max_digits': '38', 'decimal_places': '0'}),
'resource': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.Resource']"})
},
'im.resource': {
......@@ -273,7 +378,7 @@ class Migration(SchemaMigration):
'desc': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
'service': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
'service': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.Service']"}),
'unit': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'}),
'uplimit': ('snf_django.lib.db.fields.IntDecimalField', [], {'default': '0', 'max_digits': '38', 'decimal_places': '0'})
},
......@@ -288,7 +393,8 @@ class Migration(SchemaMigration):
'auth_token_created': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'auth_token_expires': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'})
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'}),
'url': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True'})
},
'im.sessioncatalog': {
'Meta': {'object_name': 'SessionCatalog'},
......
......@@ -200,8 +200,7 @@ def get_presentation(resource):
class Resource(models.Model):
name = models.CharField(_('Name'), max_length=255, unique=True)
desc = models.TextField(_('Description'), null=True)
service = models.CharField(_('Service identifier'), max_length=255,
null=True)
service = models.ForeignKey(Service)
unit = models.CharField(_('Unit'), null=True, max_length=255)
uplimit = intDecimalField(default=0)
......
......@@ -97,7 +97,7 @@ def get_user_quotas(user, resources=None, sources=None):
def get_service_quotas(service, users=None):
resources = Resource.objects.filter(service=service.name)
resources = Resource.objects.filter(service=service)
resource_names = [r.name for r in resources]
counters = qh.get_quota(holders=users, resources=resource_names)
return transform_data(counters)
......
......@@ -53,7 +53,7 @@ def add_resource(service, resource, uplimit):
old_uplimit = None
r.uplimit = uplimit
r.service = service
r.service = s
for key, value in resource.iteritems():
setattr(r, key, value)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment