Skip to content
Snippets Groups Projects
Commit 06cd41b9 authored by Felix Schäfer's avatar Felix Schäfer :construction_worker:
Browse files

Schedule tasks only after DB transactions are committed

parent 64eb2c17
Branches
Tags
No related merge requests found
......@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Fixed
- Schedule tasks only after DB transactions are committed
## [1.7.0] - 2023-02-09
### Added
......
from django.core.exceptions import ValidationError
import re
from django.core.validators import URLValidator
from django.forms import (
CharField,
CheckboxSelectMultiple,
......@@ -8,8 +9,6 @@ from django.forms import (
from django.utils.translation import gettext_lazy
from i18nfield.forms import I18nFormField, I18nTextInput
from pretix.base.forms import SettingsForm
from urllib3.exceptions import LocationParseError
from urllib3.util import parse_url
from .helpers import matrix_room_info_for_event
......@@ -31,9 +30,10 @@ class MatrixInviterSettingsForm(SettingsForm):
"your own Matrix account but from a dedicated Matrix account."
),
)
matrix_inviter_matrix_server = CharField(
matrix_inviter_matrix_server = RegexField(
label=gettext_lazy("Matrix server"),
strip=True,
regex=re.compile(r"^" + URLValidator.host_re + r"\Z", re.IGNORECASE),
help_text=gettext_lazy(
"The matrix server the above access token is valid for."
),
......@@ -61,14 +61,6 @@ class MatrixInviterSettingsForm(SettingsForm):
strip=True,
)
def clean_matrix_inviter_matrix_server(self):
url = self.cleaned_data["matrix_inviter_matrix_server"]
try:
return parse_url(url).host
except LocationParseError:
raise ValidationError("Please enter a valid hostname")
return url
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["matrix_inviter_items"].choices = [
......
......@@ -2,7 +2,7 @@ import logging
import requests
from celery.exceptions import MaxRetriesExceededError
from pretix.base.models import Order, OrderPosition
from pretix.base.services.tasks import ProfiledEventTask
from pretix.base.services.tasks import TransactionAwareProfiledEventTask
from pretix.celery_app import app
from urllib.parse import quote as url_quote
......@@ -12,7 +12,7 @@ logger = logging.getLogger(__name__)
@app.task(
base=ProfiledEventTask,
base=TransactionAwareProfiledEventTask,
bind=True,
max_retries=10,
retry_backoff=True,
......@@ -98,7 +98,7 @@ def matrix_inviter_invite(
@app.task(
base=ProfiledEventTask,
base=TransactionAwareProfiledEventTask,
bind=True,
max_retries=10,
retry_backoff=True,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment