From f5484afeba79cc5940f116ba70d3203883b5e32d Mon Sep 17 00:00:00 2001 From: pavel Date: Wed, 17 Dec 2014 12:15:23 +0000 Subject: [PATCH] bug with note --- exposition/views.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/exposition/views.py b/exposition/views.py index 0b031e4d..e94f650e 100644 --- a/exposition/views.py +++ b/exposition/views.py @@ -11,6 +11,7 @@ from django.shortcuts import get_object_or_404 from django.http import Http404 from django.utils import translation #models +from accounts.models import User from models import Exposition from service.views import order_forms from service.models import Service @@ -408,11 +409,11 @@ def add_note(request, slug): ct = ContentType.objects.get_for_model(e) object_id = e.id - user = request.user - if Note.objects.filter(user__id=user.id, content_type=ct, object_id=object_id).exists(): - Note.objects.filter(user__id=user.id, content_type=ct, object_id=object_id).update(text=text) + user = User.objects.get(id=request.user.id) + if Note.objects.filter(user=user, content_type=ct, object_id=object_id).exists(): + Note.objects.filter(user=user, content_type=ct, object_id=object_id).update(text=text) else: - Note.objects.create(content_type=ct, object_id=object_id, user=user.id, text=text) + Note.objects.create(content_type=ct, object_id=object_id, user=user, text=text) user.calendar.expositions.add(e) @@ -420,4 +421,4 @@ def add_note(request, slug): args['success'] = True args['text'] = text - return HttpResponse(json.dumps(args), content_type='application/json') \ No newline at end of file + return HttpResponse(json.dumps(args), content_type='application/json')