def delete_model(modeladmin, request, obj): LOG.debug("Deleting {}".format(obj)) database = obj if database.is_in_quarantine: if database.plan.provider == database.plan.CLOUDSTACK: LOG.debug( "call destroy_database - name=%s, team=%s, project=%s, user=%s" % ( database.name, database.team, database.project, request.user)) task_history = TaskHistory() task_history.task_name="destroy_database" task_history.task_status= task_history.STATUS_WAITING task_history.arguments="Database name: {}".format(database.name) task_history.user= request.user task_history.save() destroy_database.delay(database=database, task_history=task_history, user=request.user ) url = reverse('admin:notification_taskhistory_changelist') else: database.delete() else: database.delete()
def destroy(self, user): if not self.is_in_quarantine: self.delete() return if self.plan.provider != self.plan.CLOUDSTACK: self.delete() return LOG.debug("call destroy_database - name={}, team={}, project={}, " "user={}".format(self.name, self.team, self.project, user)) from notification.models import TaskHistory from notification.tasks import destroy_database task_history = TaskHistory() task_history.task_name = "destroy_database" task_history.task_status = task_history.STATUS_WAITING task_history.arguments = "Database name: {}".format(self.name) task_history.user = user task_history.save() destroy_database.delay(database=self, task_history=task_history, user=user) return
def delete_model(modeladmin, request, obj): LOG.debug("Deleting {}".format(obj)) database = obj if database.status != Database.ALIVE or not database.database_status.is_alive: modeladmin.message_user( request, "Database {} is not alive and cannot be deleted".format( database.name), level=messages.ERROR) url = reverse('admin:logical_database_changelist') return HttpResponseRedirect(url) if database.is_beeing_used_elsewhere(): modeladmin.message_user( request, "Database {} cannot be deleted because it is in use by another task." .format(database.name), level=messages.ERROR) url = reverse('admin:logical_database_changelist') return HttpResponseRedirect(url) if database.has_migration_started(): modeladmin.message_user( request, "Database {} cannot be deleted because it is beeing migrated.". format(database.name), level=messages.ERROR) url = reverse('admin:logical_database_changelist') return HttpResponseRedirect(url) if database.is_in_quarantine: if database.plan.provider == database.plan.CLOUDSTACK: LOG.debug( "call destroy_database - name=%s, team=%s, project=%s, user=%s" % (database.name, database.team, database.project, request.user)) task_history = TaskHistory() task_history.task_name = "destroy_database" task_history.task_status = task_history.STATUS_WAITING task_history.arguments = "Database name: {}".format( database.name) task_history.user = request.user task_history.save() destroy_database.delay(database=database, task_history=task_history, user=request.user) url = reverse('admin:notification_taskhistory_changelist') else: database.delete() else: database.delete()
def delete_model(modeladmin, request, obj): LOG.debug("Deleting {}".format(obj)) database = obj if database.status != Database.ALIVE or not database.database_status.is_alive: modeladmin.message_user( request, "Database {} is not alive and cannot be deleted".format(database.name), level=messages.ERROR) url = reverse('admin:logical_database_changelist') return HttpResponseRedirect(url) if database.is_beeing_used_elsewhere(): modeladmin.message_user( request, "Database {} cannot be deleted because it is in use by another task.".format(database.name), level=messages.ERROR) url = reverse('admin:logical_database_changelist') return HttpResponseRedirect(url) if database.has_migration_started(): modeladmin.message_user( request, "Database {} cannot be deleted because it is beeing migrated.".format(database.name), level=messages.ERROR) url = reverse('admin:logical_database_changelist') return HttpResponseRedirect(url) if database.is_in_quarantine: if database.plan.provider == database.plan.CLOUDSTACK: LOG.debug( "call destroy_database - name=%s, team=%s, project=%s, user=%s" % ( database.name, database.team, database.project, request.user)) task_history = TaskHistory() task_history.task_name = "destroy_database" task_history.task_status = task_history.STATUS_WAITING task_history.arguments = "Database name: {}".format( database.name) task_history.user = request.user task_history.save() destroy_database.delay(database=database, task_history=task_history, user=request.user ) url = reverse('admin:notification_taskhistory_changelist') else: database.delete() else: database.delete()
def delete_model(modeladmin, request, obj): LOG.debug("Deleting {}".format(obj)) database = obj if database.is_in_quarantine: LOG.debug( "call destroy_database - name=%s, team=%s, project=%s, user=%s" % ( database.name, database.team, database.project, request.user)) result = destroy_database.delay(database, request.user) url = reverse('admin:notification_taskhistory_changelist') return None else: database.is_in_quarantine = True database.save()