[Backport] Prevent some ObjectDoesNotExist exceptions

remotes/origin/enhancement/email-actions
David Barragán Merino 2014-11-11 15:46:07 +01:00
parent 257ed89b04
commit 48dafad8f4
2 changed files with 11 additions and 7 deletions

View File

@ -61,6 +61,7 @@ def _try_to_close_or_open_us_when_create_or_edit_task(instance):
def _try_to_close_or_open_us_when_delete_task(instance):
from taiga.projects.userstories import services as us_service
with suppress(ObjectDoesNotExist):
if instance.user_story_id:
if us_service.calculate_userstory_is_closed(instance.user_story):
us_service.close_userstory(instance.user_story)

View File

@ -14,6 +14,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from contextlib import suppress
from django.core.exceptions import ObjectDoesNotExist
####################################
# Signals for cached prev US
@ -87,5 +89,6 @@ def _try_to_close_or_open_milestone_when_create_or_edit_us(instance):
def _try_to_close_milestone_when_delete_us(instance):
from taiga.projects.milestones import services as milestone_service
with suppress(ObjectDoesNotExist):
if instance.milestone_id and milestone_service.calculate_milestone_is_closed(instance.milestone):
milestone_service.close_milestone(instance.milestone)