BTHLABS-53: Processing task fails for newly created saves

This commit is contained in:
Tomek Wójcik 2025-08-29 08:20:53 +02:00
parent fb39818be3
commit 38d768a584
5 changed files with 38 additions and 41 deletions

View File

@ -2,6 +2,7 @@
from __future__ import annotations
from django.contrib import messages
import django.db
from django.http import HttpRequest, HttpResponse
from django.shortcuts import redirect
from django.urls import reverse
@ -21,6 +22,7 @@ class CreateSaveWorkflow(SaveWorkflow):
url: str,
force_post_save: bool = False,
) -> HttpResponse:
with django.db.transaction.atomic():
save = self.create(
account.pk,
SaveIn(url=url),
@ -28,9 +30,6 @@ class CreateSaveWorkflow(SaveWorkflow):
association = self.associate(account.pk, save)
if save.last_processed_at is None:
processing_result = self.schedule_processing(save) # noqa: F841
response = redirect(reverse('ui.associations.browse'))
if force_post_save is True or save.is_netloc_banned is True:
response = redirect(reverse(
@ -47,4 +46,7 @@ class CreateSaveWorkflow(SaveWorkflow):
response.headers['X-HotPocket-Testing-Save-PK'] = save.pk
response.headers['X-HotPocket-Testing-Association-PK'] = association.pk
if save.last_processed_at is None:
processing_result = self.schedule_processing(save) # noqa: F841
return response

View File

@ -4,7 +4,6 @@ from __future__ import annotations
import http
import logging
import django.db
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.views.decorators.csrf import csrf_exempt
@ -21,7 +20,6 @@ def share_sheet(request: HttpRequest) -> HttpResponse:
LOGGER.debug('POST=`%s`', request.POST)
try:
with django.db.transaction.atomic():
assert request.user.is_anonymous is False, 'Login required'
assert 'text' in request.POST, 'Bad request: Missing `text`'

View File

@ -4,7 +4,6 @@ from __future__ import annotations
import http
import logging
import django.db
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
@ -19,7 +18,6 @@ def shortcut(request: HttpRequest) -> HttpResponse:
LOGGER.debug('GET=`%s`', request.GET)
try:
with django.db.transaction.atomic():
assert request.user.is_anonymous is False, 'Login required'
assert 'url' in request.GET, 'Bad request: Missing `url`'

View File

@ -4,7 +4,6 @@ from __future__ import annotations
import http
import logging
import django.db
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.urls import reverse
@ -24,7 +23,6 @@ class CreateView(AccountRequiredMixin, FormView):
form_class = CreateForm
def form_valid(self, form: CreateForm) -> HttpResponse:
with django.db.transaction.atomic():
return CreateSaveWorkflow().run(
request=self.request,
account=self.request.user,

View File

@ -2,8 +2,9 @@
extend-exclude =
hotpocket_backend/apps/*/migrations/*.py,
node_modules/**/*.py,
skel/*.py
skel/*/*.py
skel/*.py,
skel/*/*.py,
playground.py
ignore = E131,W503,W504
max-line-length = 119
hang-closing = False