Commit 7af1dcf1 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Several fixes

parent 688ad9f1
......@@ -57,7 +57,7 @@ from django.contrib.auth.models import AnonymousUser
from astakos.im.models import (
AstakosUser, EmailChange, AstakosGroup, Invitation, GroupKind,
Resource, PendingThirdPartyUser, get_latest_terms, RESOURCE_SEPARATOR,
ProjectDefinition, ProjectApplication, submit_application
ProjectDefinition, ProjectApplication
)
from astakos.im.settings import (
INVITATIONS_PER_LEVEL, BASEURL, SITENAME, RECAPTCHA_PRIVATE_KEY,
......@@ -969,7 +969,7 @@ class ProjectApplicationForm(forms.ModelForm):
precursor_application = self.instance.projectapplication
except:
precursor_application = None
return submit_application(
return ProjectApplication.submit(
definition,
applicant,
comments,
......
......@@ -71,7 +71,7 @@ class Migration(DataMigration):
continue
map(destroy_policies, SERVICES.iteritems())
models = {
'auth.group': {
'Meta': {'object_name': 'Group'},
......@@ -117,14 +117,14 @@ class Migration(DataMigration):
},
'im.approvalterms': {
'Meta': {'object_name': 'ApprovalTerms'},
'date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 6, 9, 57, 4, 932883)', 'db_index': 'True'}),
'date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 7, 16, 31, 23, 704384)', 'db_index': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'location': ('django.db.models.fields.CharField', [], {'max_length': '255'})
},
'im.astakosgroup': {
'Meta': {'object_name': 'AstakosGroup', '_ormbases': ['auth.Group']},
'approval_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 6, 9, 57, 4, 925144)'}),
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 7, 16, 31, 23, 696770)'}),
'desc': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'estimated_participants': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
'expiration_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
......@@ -190,7 +190,7 @@ class Migration(DataMigration):
'activation_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '40', 'db_index': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'new_email_address': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'requested_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 6, 9, 57, 4, 934567)'}),
'requested_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 7, 16, 31, 23, 706057)'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'emailchange_user'", 'unique': 'True', 'to': "orm['im.AstakosUser']"})
},
'im.groupkind': {
......@@ -209,16 +209,10 @@ class Migration(DataMigration):
'realname': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
},
'im.memberacceptpolicy': {
'Meta': {'object_name': 'MemberAcceptPolicy'},
'description': ('django.db.models.fields.CharField', [], {'max_length': '80'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'policy': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'})
},
'im.membership': {
'Meta': {'unique_together': "(('person', 'group'),)", 'object_name': 'Membership'},
'date_joined': ('django.db.models.fields.DateField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
'date_requested': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2012, 12, 6, 9, 57, 4, 930535)', 'blank': 'True'}),
'date_requested': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2012, 12, 7, 16, 31, 23, 702070)', 'blank': 'True'}),
'group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosGroup']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'person': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosUser']"})
......@@ -236,54 +230,6 @@ class Migration(DataMigration):
'token': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}),
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
},
'im.project': {
'Meta': {'object_name': 'Project'},
'application': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'project'", 'unique': 'True', 'to': "orm['im.ProjectApplication']"}),
'creation_date': ('django.db.models.fields.DateTimeField', [], {}),
'last_approval_date': ('django.db.models.fields.DateTimeField', [], {}),
'last_synced_application': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'last_project'", 'unique': 'True', 'null': 'True', 'to': "orm['im.ProjectApplication']"}),
'members': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['im.AstakosUser']", 'through': "orm['im.ProjectMembership']", 'symmetrical': 'False'}),
'serial': ('django.db.models.fields.CharField', [], {'default': "'3853dff39e254f1cac9f1e76a235df'", 'unique': 'True', 'max_length': '30', 'primary_key': 'True'}),
'termination_date': ('django.db.models.fields.DateTimeField', [], {})
},
'im.projectapplication': {
'Meta': {'object_name': 'ProjectApplication'},
'applicant': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'my_project_applications'", 'to': "orm['im.AstakosUser']"}),
'comments': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
'definition': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['im.ProjectDefinition']", 'unique': 'True'}),
'issue_date': ('django.db.models.fields.DateTimeField', [], {}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'own_project_applications'", 'to': "orm['im.AstakosUser']"}),
'precursor_application': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['im.ProjectApplication']", 'unique': 'True', 'null': 'True', 'blank': 'True'}),
'serial': ('django.db.models.fields.CharField', [], {'default': "'84b9d92532ef4258a6980a046f9126'", 'unique': 'True', 'max_length': '30', 'primary_key': 'True'})
},
'im.projectdefinition': {
'Meta': {'object_name': 'ProjectDefinition'},
'description': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'end_date': ('django.db.models.fields.DateTimeField', [], {}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'limit_on_members_number': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
'member_accept_policy': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.MemberAcceptPolicy']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '80'}),
'resource_grants': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['im.Resource']", 'null': 'True', 'through': "orm['im.ProjectResourceGrant']", 'blank': 'True'}),
'start_date': ('django.db.models.fields.DateTimeField', [], {})
},
'im.projectmembership': {
'Meta': {'unique_together': "(('person', 'project'),)", 'object_name': 'ProjectMembership'},
'decision_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'db_index': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'issue_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2012, 12, 6, 9, 57, 4, 944049)'}),
'person': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosUser']"}),
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.Project']"})
},
'im.projectresourcegrant': {
'Meta': {'unique_together': "(('resource', 'project_definition'),)", 'object_name': 'ProjectResourceGrant'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'member_limit': ('django.db.models.fields.BigIntegerField', [], {'null': 'True'}),
'project_definition': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.ProjectDefinition']", 'blank': 'True'}),
'project_limit': ('django.db.models.fields.BigIntegerField', [], {'null': 'True'}),
'resource': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.Resource']"})
},
'im.resource': {
'Meta': {'object_name': 'Resource'},
'desc': ('django.db.models.fields.TextField', [], {'null': 'True'}),
......
......@@ -8,9 +8,23 @@ class Migration(SchemaMigration):
def forwards(self, orm):
# Adding model 'ProjectMembershipHistory'
db.create_table('im_projectmembershiphistory', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('person', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.AstakosUser'])),
('project', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.Project'])),
('request_date', self.gf('django.db.models.fields.DateField')(default=datetime.datetime(2012, 12, 7, 16, 55, 19, 659537))),
('removal_date', self.gf('django.db.models.fields.DateField')(null=True)),
('rejection_date', self.gf('django.db.models.fields.DateField')(null=True)),
))
db.send_create_signal('im', ['ProjectMembershipHistory'])
# Adding unique constraint on 'ProjectMembershipHistory', fields ['person', 'project']
db.create_unique('im_projectmembershiphistory', ['person_id', 'project_id'])
# Adding model 'ProjectApplication'
db.create_table('im_projectapplication', (
('serial', self.gf('django.db.models.fields.CharField')(default='a3e0784bfd924d4ba9a1181332d5e9', unique=True, max_length=30, primary_key=True)),
('serial', self.gf('django.db.models.fields.CharField')(unique=True, max_length=30, primary_key=True)),
('applicant', self.gf('django.db.models.fields.related.ForeignKey')(related_name='my_project_applications', to=orm['im.AstakosUser'])),
('owner', self.gf('django.db.models.fields.related.ForeignKey')(related_name='own_project_applications', to=orm['im.AstakosUser'])),
('comments', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
......@@ -22,12 +36,14 @@ class Migration(SchemaMigration):
# Adding model 'Project'
db.create_table('im_project', (
('serial', self.gf('django.db.models.fields.CharField')(default='ab6c5646977c4e678daff27ff3c7cb', unique=True, max_length=30, primary_key=True)),
('serial', self.gf('django.db.models.fields.CharField')(unique=True, max_length=30, primary_key=True)),
('application', self.gf('django.db.models.fields.related.OneToOneField')(related_name='project', unique=True, to=orm['im.ProjectApplication'])),
('creation_date', self.gf('django.db.models.fields.DateTimeField')()),
('last_approval_date', self.gf('django.db.models.fields.DateTimeField')()),
('termination_date', self.gf('django.db.models.fields.DateTimeField')()),
('last_synced_application', self.gf('django.db.models.fields.related.OneToOneField')(blank=True, related_name='last_project', unique=True, null=True, to=orm['im.ProjectApplication'])),
('last_approval_date', self.gf('django.db.models.fields.DateTimeField')(null=True)),
('termination_start_date', self.gf('django.db.models.fields.DateTimeField')(null=True)),
('termination_date', self.gf('django.db.models.fields.DateTimeField')(null=True)),
('membership_dirty', self.gf('django.db.models.fields.BooleanField')(default=False)),
('last_application_synced', self.gf('django.db.models.fields.related.OneToOneField')(blank=True, related_name='last_project', unique=True, null=True, to=orm['im.ProjectApplication'])),
))
db.send_create_signal('im', ['Project'])
......@@ -36,9 +52,8 @@ class Migration(SchemaMigration):
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('person', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.AstakosUser'])),
('project', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.Project'])),
('issue_date', self.gf('django.db.models.fields.DateField')(default=datetime.datetime(2012, 12, 6, 10, 11, 33, 387204))),
('decision_date', self.gf('django.db.models.fields.DateField')(null=True, db_index=True)),
('is_accepted', self.gf('django.db.models.fields.BooleanField')(default=False)),
('request_date', self.gf('django.db.models.fields.DateField')(default=datetime.datetime(2012, 12, 7, 16, 55, 19, 658816))),
('acceptance_date', self.gf('django.db.models.fields.DateField')(null=True, db_index=True)),
))
db.send_create_signal('im', ['ProjectMembership'])
......@@ -62,6 +77,7 @@ class Migration(SchemaMigration):
('start_date', self.gf('django.db.models.fields.DateTimeField')()),
('end_date', self.gf('django.db.models.fields.DateTimeField')()),
('member_accept_policy', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.MemberAcceptPolicy'])),
('member_reject_policy', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.MemberRejectPolicy'])),
('limit_on_members_number', self.gf('django.db.models.fields.PositiveIntegerField')(null=True, blank=True)),
))
db.send_create_signal('im', ['ProjectDefinition'])
......@@ -79,6 +95,14 @@ class Migration(SchemaMigration):
# Adding unique constraint on 'ProjectResourceGrant', fields ['resource', 'project_definition']
db.create_unique('im_projectresourcegrant', ['resource_id', 'project_definition_id'])
# Adding model 'MemberRejectPolicy'
db.create_table('im_memberrejectpolicy', (
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
('policy', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255, db_index=True)),
('description', self.gf('django.db.models.fields.CharField')(max_length=80)),
))
db.send_create_signal('im', ['MemberRejectPolicy'])
def backwards(self, orm):
......@@ -88,6 +112,12 @@ class Migration(SchemaMigration):
# Removing unique constraint on 'ProjectMembership', fields ['person', 'project']
db.delete_unique('im_projectmembership', ['person_id', 'project_id'])
# Removing unique constraint on 'ProjectMembershipHistory', fields ['person', 'project']
db.delete_unique('im_projectmembershiphistory', ['person_id', 'project_id'])
# Deleting model 'ProjectMembershipHistory'
db.delete_table('im_projectmembershiphistory')
# Deleting model 'ProjectApplication'
db.delete_table('im_projectapplication')
......@@ -106,6 +136,9 @@ class Migration(SchemaMigration):
# Deleting model 'ProjectResourceGrant'
db.delete_table('im_projectresourcegrant')
# Deleting model 'MemberRejectPolicy'
db.delete_table('im_memberrejectpolicy')
models = {
'auth.group': {
......@@ -152,14 +185,14 @@ class Migration(SchemaMigration):
},
'im.approvalterms': {
'Meta': {'object_name': 'ApprovalTerms'},
'date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 6, 10, 11, 33, 376205)', 'db_index': 'True'}),
'date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 7, 16, 55, 19, 649024)', 'db_index': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'location': ('django.db.models.fields.CharField', [], {'max_length': '255'})
},
'im.astakosgroup': {
'Meta': {'object_name': 'AstakosGroup', '_ormbases': ['auth.Group']},
'approval_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 6, 10, 11, 33, 368608)'}),
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 7, 16, 55, 19, 641334)'}),
'desc': ('django.db.models.fields.TextField', [], {'null': 'True'}),
'estimated_participants': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
'expiration_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
......@@ -225,7 +258,7 @@ class Migration(SchemaMigration):
'activation_key': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '40', 'db_index': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'new_email_address': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
'requested_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 6, 10, 11, 33, 378081)'}),
'requested_at': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 7, 16, 55, 19, 650690)'}),
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'emailchange_user'", 'unique': 'True', 'to': "orm['im.AstakosUser']"})
},
'im.groupkind': {
......@@ -250,10 +283,16 @@ class Migration(SchemaMigration):
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'policy': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'})
},
'im.memberrejectpolicy': {
'Meta': {'object_name': 'MemberRejectPolicy'},
'description': ('django.db.models.fields.CharField', [], {'max_length': '80'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'policy': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255', 'db_index': 'True'})
},
'im.membership': {
'Meta': {'unique_together': "(('person', 'group'),)", 'object_name': 'Membership'},
'date_joined': ('django.db.models.fields.DateField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
'date_requested': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2012, 12, 6, 10, 11, 33, 373957)', 'blank': 'True'}),
'date_requested': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2012, 12, 7, 16, 55, 19, 646801)', 'blank': 'True'}),
'group': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosGroup']"}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'person': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosUser']"})
......@@ -275,11 +314,13 @@ class Migration(SchemaMigration):
'Meta': {'object_name': 'Project'},
'application': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'project'", 'unique': 'True', 'to': "orm['im.ProjectApplication']"}),
'creation_date': ('django.db.models.fields.DateTimeField', [], {}),
'last_approval_date': ('django.db.models.fields.DateTimeField', [], {}),
'last_synced_application': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'last_project'", 'unique': 'True', 'null': 'True', 'to': "orm['im.ProjectApplication']"}),
'last_application_synced': ('django.db.models.fields.related.OneToOneField', [], {'blank': 'True', 'related_name': "'last_project'", 'unique': 'True', 'null': 'True', 'to': "orm['im.ProjectApplication']"}),
'last_approval_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'members': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['im.AstakosUser']", 'through': "orm['im.ProjectMembership']", 'symmetrical': 'False'}),
'serial': ('django.db.models.fields.CharField', [], {'default': "'ab6c5646977c4e678daff27ff3c7cb'", 'unique': 'True', 'max_length': '30', 'primary_key': 'True'}),
'termination_date': ('django.db.models.fields.DateTimeField', [], {})
'membership_dirty': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'serial': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30', 'primary_key': 'True'}),
'termination_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True'}),
'termination_start_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True'})
},
'im.projectapplication': {
'Meta': {'object_name': 'ProjectApplication'},
......@@ -289,7 +330,7 @@ class Migration(SchemaMigration):
'issue_date': ('django.db.models.fields.DateTimeField', [], {}),
'owner': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'own_project_applications'", 'to': "orm['im.AstakosUser']"}),
'precursor_application': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['im.ProjectApplication']", 'unique': 'True', 'null': 'True', 'blank': 'True'}),
'serial': ('django.db.models.fields.CharField', [], {'default': "'a3e0784bfd924d4ba9a1181332d5e9'", 'unique': 'True', 'max_length': '30', 'primary_key': 'True'})
'serial': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30', 'primary_key': 'True'})
},
'im.projectdefinition': {
'Meta': {'object_name': 'ProjectDefinition'},
......@@ -299,18 +340,27 @@ class Migration(SchemaMigration):
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'limit_on_members_number': ('django.db.models.fields.PositiveIntegerField', [], {'null': 'True', 'blank': 'True'}),
'member_accept_policy': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.MemberAcceptPolicy']"}),
'member_reject_policy': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.MemberRejectPolicy']"}),
'name': ('django.db.models.fields.CharField', [], {'max_length': '80'}),
'resource_grants': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['im.Resource']", 'null': 'True', 'through': "orm['im.ProjectResourceGrant']", 'blank': 'True'}),
'start_date': ('django.db.models.fields.DateTimeField', [], {})
},
'im.projectmembership': {
'Meta': {'unique_together': "(('person', 'project'),)", 'object_name': 'ProjectMembership'},
'decision_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'db_index': 'True'}),
'acceptance_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'db_index': 'True'}),
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'person': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosUser']"}),
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.Project']"}),
'request_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2012, 12, 7, 16, 55, 19, 658816)'})
},
'im.projectmembershiphistory': {
'Meta': {'unique_together': "(('person', 'project'),)", 'object_name': 'ProjectMembershipHistory'},
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
'is_accepted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
'issue_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2012, 12, 6, 10, 11, 33, 387204)'}),
'person': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.AstakosUser']"}),
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.Project']"})
'project': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['im.Project']"}),
'rejection_date': ('django.db.models.fields.DateField', [], {'null': 'True'}),
'removal_date': ('django.db.models.fields.DateField', [], {'null': 'True'}),
'request_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2012, 12, 7, 16, 55, 19, 659537)'})
},
'im.projectresourcegrant': {
'Meta': {'unique_together': "(('resource', 'project_definition'),)", 'object_name': 'ProjectResourceGrant'},
......
......@@ -1043,6 +1043,7 @@ class ProjectDefinition(models.Model):
start_date = models.DateTimeField()
end_date = models.DateTimeField()
member_accept_policy = models.ForeignKey(MemberAcceptPolicy)
member_reject_policy = models.ForeignKey(MemberRejectPolicy)
limit_on_members_number = models.PositiveIntegerField(null=True,blank=True)
resource_grants = models.ManyToManyField(
Resource,
......@@ -1084,6 +1085,22 @@ class ProjectDefinition(models.Model):
uplimit = p.get('uplimit', 0)
update = p.get('update', True)
self.add_resource_policy(service, resource, uplimit, update)
def validate_name(self):
"""
Validate name uniqueness among all active projects.
"""
alive_projects = list(get_alive_projects())
q = filter(
lambda p: p.definition.name == self.name and \
p.application.serial != self.projectapplication.serial,
alive_projects
)
if q:
raise ValidationError(
{'name': [_(astakos_messages.UNIQUE_PROJECT_NAME_CONSTRAIN_ERR)]}
)
class ProjectResourceGrant(models.Model):
objects = ExtendedManager()
......@@ -1099,8 +1116,7 @@ class ProjectApplication(models.Model):
serial = models.CharField(
primary_key=True,
max_length=30,
unique=True,
default=uuid.uuid4().hex[:30]
unique=True
)
applicant = models.ForeignKey(
AstakosUser,
......@@ -1118,14 +1134,42 @@ class ProjectApplication(models.Model):
null=True,
blank=True
)
def save(self):
if not self.serial:
self.serial = uuid.uuid4().hex[:30]
super(ProjectApplication, self).save()
@staticmethod
def submit(definition, applicant, comments, precursor_application=None, commit=True):
if precursor_application and precursor_application.project.is_valid:
application = precursor_application.copy()
application.precursor_application = precursor_application
else:
application = ProjectApplication(owner=applicant)
application.definition = definition
application.applicant = applicant
application.comments = comments
application.issue_date = datetime.now()
if commit:
definition.save()
application.save()
if applicant.is_superuser:
self.approve_application()
notification = build_notification(
settings.SERVER_EMAIL,
[i[1] for i in settings.ADMINS],
_(GROUP_CREATION_SUBJECT) % {'group':application.definition.name},
_('An new project application identified by %(serial)s has been submitted.') % application.__dict__
)
notification.send()
return application
class Project(models.Model):
serial = models.CharField(
_('username'),
primary_key=True,
max_length=30,
unique=True,
default=uuid.uuid4().hex[:30]
unique=True
)
application = models.OneToOneField(ProjectApplication, related_name='project')
creation_date = models.DateTimeField()
......@@ -1138,6 +1182,11 @@ class Project(models.Model):
ProjectApplication, related_name='last_project', null=True, blank=True
)
def save(self):
if not self.serial:
self.serial = uuid.uuid4().hex[:30]
super(ProjectApplication, self).save()
@property
def definition(self):
return self.application.definition
......@@ -1213,7 +1262,7 @@ class Project(models.Model):
@property
def approved_members(self):
return [m.person for m in self.projectmembership_set.filter(is_accepted=True)]
return [m.person for m in self.projectmembership_set.filter(~Q(acceptance_date=None))]
def sync(self, specific_members=()):
if self.is_synchornized():
......@@ -1237,32 +1286,8 @@ class Project(models.Model):
created, m = ProjectMembership.objects.get_or_create(
person=user, project=project
)
if m.is_accepted:
return
if created:
m.issue_date = datetime.now()
m.is_accepted = True
m.decision_date = datetime.now()
m.save()
m.accept()
# set membership_dirty flag
self.membership_dirty = True
self.save()
rejected = self.sync([user])
if not rejected:
# if syncing was successful unset membership_dirty flag
self.membership_dirty = False
self.save()
notification = build_notification(
settings.SERVER_EMAIL,
[user.email],
_('Your membership on project %(name)s has been accepted.') % project.definition.__dict__,
_('Your membership on project %(name)s has been accepted.') % project.definition.__dict__
)
def remove_member(self, user, request_user=None):
if user.is_digit():
user = _lookup_object(AstakosUser, id=user)
......@@ -1272,71 +1297,8 @@ class Project(models.Model):
if not self.is_alive:
raise Exception(_(astakos_messages.NOT_ALIVE_PROJECT) % project.__dict__)
m = _lookup_object(ProjectMembership, person=user, project=project)
if not m.is_accepted:
return
m.is_accepted = False
m.decision_date = datetime.now()
m.save()
m.remove()
# set membership_dirty flag
self.membership_dirty = True
self.save()
rejected = self.sync([user])
if not rejected:
# if syncing was successful unset membership_dirty flag
self.membership_dirty = False
self.save()
notification = build_notification(
settings.SERVER_EMAIL,
[user.email],
_('Your membership on project %(name)s has been removed.') % project.definition.__dict__,
_('Your membership on project %(name)s has been removed.') % project.definition.__dict__
)
notification.send()
def validate_name(self):
"""
Validate name uniqueness among all active projects.
"""
alive_projects = list(get_alive_projects())
q = filter(
lambda p: p.definition.name == self.definition.name and \
p.application.serial != self.application.serial,
alive_projects
)
if q:
raise ValidationError(
{'name': [_(astakos_messages.UNIQUE_PROJECT_NAME_CONSTRAIN_ERR)]}
)
@classmethod
def submit(definition, applicant, comments, precursor_application=None, commit=True):
if precursor_application and precursor_application.project.is_valid:
application = precursor_application.copy()
application.precursor_application = precursor_application
else:
application = ProjectApplication(owner=applicant)
application.definition = definition
application.applicant = applicant
application.comments = comments
application.issue_date = datetime.now()
if commit:
definition.save()
application.save()
if applicant.is_superuser():
self.approve_application()
notification = build_notification(
settings.SERVER_EMAIL,
[i[1] for i in settings.ADMINS],
_(GROUP_CREATION_SUBJECT) % {'group':application.definition.name},
_('An new project application identified by %(serial)s has been submitted.') % application.__dict__
)
notification.send()
return application
def approve(self, approval_user=None):
"""
If approval_user then during owner membership acceptance
......@@ -1412,18 +1374,84 @@ class Project(models.Model):
)
notification.send()
class ProjectMembership(models.Model):
person = models.ForeignKey(AstakosUser)
project = models.ForeignKey(Project)
request_date = models.DateField(default=datetime.now())
acceptance_date = models.DateField(null=True, db_index=True)
class Meta:
unique_together = ("person", "project")
def accept(self):