예제 #1
0
    def handle(self, request, data):

        new_name = data['name']
        new_desc = data['description']
        project_id = data['project_id']

        with transaction.atomic():
            #
            # TODO missing index
            #
            pr_list = Project.objects.filter(projectid=project_id)

            if len(pr_list) == 0:
                LOG.error("Missing project %s in database" % project_id)
                return False
            else:
                self.this_project = pr_list[0]

            if new_name == self.this_project.projectname:
                #
                # Change project description
                #
                self.this_project.description = new_desc
                self.this_project.save()
            else:
                #
                # Change project name and description
                #
                newpr = Project()
                newpr.projectname = new_name
                newpr.projectid = project_id
                newpr.description = new_desc
                newpr.status = self.this_project.status
                newpr.save()

                PrjRequest.objects.filter(project=self.this_project).update(
                    project=newpr)
                Expiration.objects.filter(project=self.this_project).update(
                    project=newpr)
                self.this_project.delete()
                self.this_project = newpr

            if not super(ExtUpdateProject, self).handle(request, data):
                raise IntegrityError('Cannot complete update on Keystone')

        return True
    def handle(self, request, data):

        new_name = data["name"]
        new_desc = data["description"]
        project_id = data["project_id"]

        with transaction.atomic():
            #
            # TODO missing index
            #
            pr_list = Project.objects.filter(projectid=project_id)

            if len(pr_list) == 0:
                LOG.error("Missing project %s in database" % project_id)
                return False
            else:
                self.this_project = pr_list[0]

            if new_name == self.this_project.projectname:
                #
                # Change project description
                #
                self.this_project.description = new_desc
                self.this_project.save()
            else:
                #
                # Change project name and description
                #
                newpr = Project()
                newpr.projectname = new_name
                newpr.projectid = project_id
                newpr.description = new_desc
                newpr.status = self.this_project.status
                newpr.save()

                PrjRequest.objects.filter(project=self.this_project).update(project=newpr)
                Expiration.objects.filter(project=self.this_project).update(project=newpr)
                self.this_project.delete()
                self.this_project = newpr

            if not super(ExtUpdateProject, self).handle(request, data):
                raise IntegrityError("Cannot complete update on Keystone")

        return True
    def handle(self, request, data):

        new_name=data['name']
        new_desc = data['description']
        project_id = data['project_id']

        with transaction.atomic():

            pr_list = Project.objects.filter(projectid=project_id)
            
            if len(pr_list) == 0:
                LOG.error("Missing project %s in database" % project_id)
                return False
            else:
                self.this_project = pr_list[0]

            if new_name == self.this_project.projectname:
                #
                # Change project description
                #
                self.this_project.description = new_desc
                self.this_project.save()
            else:
                #
                # Change project name and description
                #
                newpr = Project()
                newpr.projectname = new_name
                newpr.projectid = project_id
                newpr.description = new_desc
                newpr.status = self.this_project.status
                newpr.save()

                old_reqs = PrjRequest.objects.filter(project=self.this_project)
                for item in old_reqs:
                    PrjRequest(
                        registration = item.registration,
                        project = newpr,
                        flowstatus = item.flowstatus,
                        notes = item.notes
                    ).save()
                old_reqs.delete()

                old_exps = Expiration.objects.filter(project=self.this_project)
                for item in old_exps:
                    Expiration(
                        registration = item.registration,
                        project = newpr,
                        expdate = item.expdate
                    ).save()
                old_exps.delete()

                old_rules = PrjRole.objects.filter(project=self.this_project)
                for item in old_rules:
                    PrjRole(
                        registration = item.registration,
                        project = newpr,
                        roleid = item.roleid,
                        status = item.status
                    ).save()
                old_rules.delete()

                self.this_project.delete()
                self.this_project = newpr
            
            if not super(ExtUpdateProject, self).handle(request, data):
                raise IntegrityError('Cannot complete update on Keystone')

        return True
    def handle(self, request, data):

        new_name = data['name']
        new_desc = data['description']
        project_id = data['project_id']

        with transaction.atomic():

            pr_list = Project.objects.filter(projectid=project_id)

            if len(pr_list) == 0:
                LOG.error("Missing project %s in database" % project_id)
                return False
            else:
                self.this_project = pr_list[0]

            if new_name == self.this_project.projectname:
                #
                # Change project description
                #
                self.this_project.description = new_desc
                self.this_project.save()
            else:
                #
                # Change project name and description
                #
                newpr = Project()
                newpr.projectname = new_name
                newpr.projectid = project_id
                newpr.description = new_desc
                newpr.status = self.this_project.status
                newpr.save()

                old_reqs = PrjRequest.objects.filter(project=self.this_project)
                for item in old_reqs:
                    PrjRequest(registration=item.registration,
                               project=newpr,
                               flowstatus=item.flowstatus,
                               notes=item.notes).save()
                old_reqs.delete()

                old_exps = Expiration.objects.filter(project=self.this_project)
                for item in old_exps:
                    Expiration(registration=item.registration,
                               project=newpr,
                               expdate=item.expdate).save()
                old_exps.delete()

                old_rules = PrjRole.objects.filter(project=self.this_project)
                for item in old_rules:
                    PrjRole(registration=item.registration,
                            project=newpr,
                            roleid=item.roleid,
                            status=item.status).save()
                old_rules.delete()

                self.this_project.delete()
                self.this_project = newpr

            if not super(ExtUpdateProject, self).handle(request, data):
                raise IntegrityError('Cannot complete update on Keystone')

        return True