Commit d98f15ff authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Fix precursor application

parent 0d535a04
...@@ -1097,10 +1097,6 @@ class ProjectDefinition(models.Model): ...@@ -1097,10 +1097,6 @@ class ProjectDefinition(models.Model):
through='ProjectResourceGrant' through='ProjectResourceGrant'
) )
def save(self):
self.validate_name()
super(ProjectDefinition, self).save()
@property @property
def violated_resource_grants(self): def violated_resource_grants(self):
return False return False
...@@ -1212,6 +1208,14 @@ class ProjectApplication(models.Model): ...@@ -1212,6 +1208,14 @@ class ProjectApplication(models.Model):
if commit: if commit:
application.save() application.save()
application.definition.resource_policies = resource_policies application.definition.resource_policies = resource_policies
# better implementation ???
if precursor_application:
try:
precursor = ProjectApplication.objects.get(id=precursor_application_id)
except:
pass
application.precursor_application = precursor
application.save()
else: else:
notification = build_notification( notification = build_notification(
settings.SERVER_EMAIL, settings.SERVER_EMAIL,
...@@ -1226,6 +1230,10 @@ class ProjectApplication(models.Model): ...@@ -1226,6 +1230,10 @@ class ProjectApplication(models.Model):
""" """
If approval_user then during owner membership acceptance If approval_user then during owner membership acceptance
it is checked whether the request_user is eligible. it is checked whether the request_user is eligible.
Raises:
ValidationError: if there is other alive project with the same name
""" """
if self.state != PENDING: if self.state != PENDING:
return return
...@@ -1249,6 +1257,7 @@ class ProjectApplication(models.Model): ...@@ -1249,6 +1257,7 @@ class ProjectApplication(models.Model):
project.last_approval_date = datetime.now() project.last_approval_date = datetime.now()
project.save() project.save()
self.precursor_application.state = REPLACED self.precursor_application.state = REPLACED
self.definition.validate_name()
self.state = APPROVED self.state = APPROVED
self.save() self.save()
......
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