def handle(self, request):
data = self.data
try:
with transaction.atomic():
author = Author.objects.get(
id=data['idField'])
userChanged = data['user_id'] != author.user_id
if author.isChanged(**data) or userChanged:
problem = author.setDelta(request, **data)
if problem is None:
if userChanged and request.user.is_staff:
author.user_id = data['user_id']
author.save()
else:
messages.error(
request, author.deltaReport(**problem))
except Exception:
logging.exception('Problem while updating author.')
messages.error(
request, 'Problem saving author data: %s' % data)
评论列表
文章目录