Revision ece3b66e snf-astakos-app/astakos/im/models.py

b/snf-astakos-app/astakos/im/models.py
1208 1208

  
1209 1209

  
1210 1210
    @staticmethod
1211
    def submit(definition, resource_policies, applicant, comments, precursor_application=None, commit=True):
1212
        application = None
1211
    def submit(definition, resource_policies, applicant, comments,
1212
               precursor_application=None, commit=True):
1213

  
1214
        application = ProjectApplication()
1213 1215
        if precursor_application:
1214
            precursor_application_id = precursor_application.id
1215
            application = precursor_application
1216
            application.id = None
1217
            application.precursor_application = None
1216
            application.precursor_application = precursor_application
1217
            application.owner = precursor_application.owner
1218 1218
        else:
1219
            application = ProjectApplication(owner=applicant)
1219
            application.owner = applicant
1220

  
1220 1221
        application.definition = definition
1221
        application.definition.id = None
1222
        application.definition.resource_policies = resource_policies
1222 1223
        application.applicant = applicant
1223 1224
        application.comments = comments
1224 1225
        application.issue_date = datetime.now()
1225 1226
        application.state = PENDING
1227

  
1226 1228
        if commit:
1227 1229
            application.save()
1228
            application.definition.resource_policies = resource_policies
1229
            # better implementation ???
1230
            if precursor_application:
1231
                try:
1232
                    precursor = ProjectApplication.objects.get(id=precursor_application_id)
1233
                except:
1234
                    pass
1235
                application.precursor_application = precursor
1236
                application.save()
1237 1230
        else:
1238 1231
            notification = build_notification(
1239 1232
                settings.SERVER_EMAIL,
1240 1233
                [i[1] for i in settings.ADMINS],
1241 1234
                _(GROUP_CREATION_SUBJECT) % {'group':application.definition.name},
1242
                _('An new project application identified by %(id)s has been submitted.') % application.__dict__
1235
                _('A new project application identified by %(id)s has been submitted.') % application.__dict__
1243 1236
            )
1244 1237
            notification.send()
1245 1238
        return application
1246
        
1239

  
1247 1240
    def approve(self, approval_user=None):
1248 1241
        """
1249 1242
        If approval_user then during owner membership acceptance

Also available in: Unified diff