1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-23 04:18:21 +00:00

add try-except when set notice seen by id

This commit is contained in:
lian
2015-11-04 11:46:10 +08:00
parent 2448871ada
commit 3eba328e18

View File

@@ -1534,7 +1534,14 @@ def set_notice_seen_by_id(request):
content_type = 'application/json; charset=utf-8'
notice_id = request.GET.get('notice_id')
notice = UserNotification.objects.get(id=notice_id)
try:
notice = UserNotification.objects.get(id=notice_id)
except UserNotification.DoesNotExist as e:
logger.error(e)
return HttpResponse(json.dumps({
'error': _(u'Failed')
}), status=400, content_type=content_type)
if not notice.seen:
notice.seen = True
notice.save()