Clean up more lock DB
This commit is contained in:
parent
ad73e4cdf3
commit
3457eff339
3 changed files with 9 additions and 15 deletions
|
@ -23,7 +23,6 @@ from reversion import revisions
|
||||||
from reversion.models import Revision, Version
|
from reversion.models import Revision, Version
|
||||||
from django_ratelimit.decorators import ratelimit
|
from django_ratelimit.decorators import ratelimit
|
||||||
|
|
||||||
from judge.dblock import LockModel
|
|
||||||
from judge.models import Comment, Notification
|
from judge.models import Comment, Notification
|
||||||
from judge.widgets import HeavyPreviewPageDownWidget
|
from judge.widgets import HeavyPreviewPageDownWidget
|
||||||
from judge.jinja2.reference import get_user_from_text
|
from judge.jinja2.reference import get_user_from_text
|
||||||
|
|
|
@ -12,7 +12,6 @@ from judge.models.bookmark import BookMark, MakeBookMark
|
||||||
from django.views.generic.base import TemplateResponseMixin
|
from django.views.generic.base import TemplateResponseMixin
|
||||||
from django.views.generic.detail import SingleObjectMixin
|
from django.views.generic.detail import SingleObjectMixin
|
||||||
|
|
||||||
from judge.dblock import LockModel
|
|
||||||
from django.views.generic import View, ListView
|
from django.views.generic import View, ListView
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ from reversion.models import Version
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django_ratelimit.decorators import ratelimit
|
from django_ratelimit.decorators import ratelimit
|
||||||
|
|
||||||
from judge.dblock import LockModel
|
|
||||||
from judge.models import Comment, CommentVote, Notification, BlogPost
|
from judge.models import Comment, CommentVote, Notification, BlogPost
|
||||||
from judge.utils.views import TitleMixin
|
from judge.utils.views import TitleMixin
|
||||||
from judge.widgets import MathJaxPagedownWidget, HeavyPreviewPageDownWidget
|
from judge.widgets import MathJaxPagedownWidget, HeavyPreviewPageDownWidget
|
||||||
|
@ -83,11 +82,8 @@ def vote_comment(request, delta):
|
||||||
try:
|
try:
|
||||||
vote.save()
|
vote.save()
|
||||||
except IntegrityError:
|
except IntegrityError:
|
||||||
with LockModel(write=(CommentVote,)):
|
|
||||||
try:
|
try:
|
||||||
vote = CommentVote.objects.get(
|
vote = CommentVote.objects.get(comment_id=comment_id, voter=request.profile)
|
||||||
comment_id=comment_id, voter=request.profile
|
|
||||||
)
|
|
||||||
except CommentVote.DoesNotExist:
|
except CommentVote.DoesNotExist:
|
||||||
raise Http404()
|
raise Http404()
|
||||||
if -vote.score != delta:
|
if -vote.score != delta:
|
||||||
|
|
Loading…
Reference in a new issue