def delete(self, *args, **kwargs): from wirecloud.platform.workspace.models import VariableValue # Delete all IWidget's variables variables = Variable.objects.filter(iwidget=self) for var in variables: # Deleting variable value VariableValue.objects.filter(variable=var).delete() var.delete() # Delete IWidget and its position self.position.delete() icon_position = self.icon_position if icon_position is not None: icon_position.delete() # Delete IWidget from wiring wiring = json.loads(self.tab.workspace.wiringStatus) remove_related_iwidget_connections(wiring, self) self.tab.workspace.wiringStatus = json.dumps(wiring, ensure_ascii=False) self.tab.workspace.save() from wirecloud.platform.get_data import _invalidate_cached_variables _invalidate_cached_variables(self) super(IWidget, self).delete(*args, **kwargs)
def delete(self, *args, **kwargs): # Delete IWidget from wiring remove_related_iwidget_connections(self.tab.workspace.wiringStatus, self) self.tab.workspace.save() # This also invalidates the workspace cache super(IWidget, self).delete(*args, **kwargs)
def delete(self, *args, **kwargs): # Delete all IWidget's variables self.variable_set.all().delete() # Delete IWidget and its position self.position.delete() icon_position = self.icon_position if icon_position is not None: icon_position.delete() # Delete IWidget from wiring wiring = json.loads(self.tab.workspace.wiringStatus) remove_related_iwidget_connections(wiring, self) self.tab.workspace.wiringStatus = json.dumps(wiring, ensure_ascii=False) self.tab.workspace.save() # This also invalidates the workspace cache super(IWidget, self).delete(*args, **kwargs)