<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def delete(self, hard=False):
 """ Override the vanilla delete functionality to soft-delete instead. Soft-delete is accomplished by setting the status field to "deleted" Arguments: hard <bool=False> if true, do a hard delete instead, effectively removing the object from the database """


        if hard:
            return models.Model.delete(self)
        self.status = "deleted"
        self.save()
        for key in self._handleref.delete_cascade:
            q = getattr(self, key).all()

            if not hard:
                # if we are soft deleting only trigger delete on
                # objects that are not already deleted, as to avoid
                # unnecessary re-saves and overriding of updated dates
                q = q.exclude(status="deleted")

            for child in q:
                child.delete(hard=hard)