forked from CGM_Public/pretix_original
Add special input widgets for markdown fields (#1577)
* Add markdown text input widgets * Update src/pretix/static/pretixcontrol/scss/_forms.scss * Improvements --------- Co-authored-by: Raphael Michel <michel@rami.io>
This commit is contained in:
@@ -55,12 +55,14 @@ from django.utils.timezone import get_current_timezone_name
|
||||
from django.utils.translation import gettext, gettext_lazy as _, pgettext_lazy
|
||||
from django_countries.fields import LazyTypedChoiceField
|
||||
from i18nfield.forms import (
|
||||
I18nForm, I18nFormField, I18nFormSetMixin, I18nTextarea, I18nTextInput,
|
||||
I18nForm, I18nFormField, I18nFormSetMixin, I18nTextInput,
|
||||
)
|
||||
from pytz import common_timezones
|
||||
|
||||
from pretix.base.channels import get_all_sales_channels
|
||||
from pretix.base.forms import I18nModelForm, PlaceholderValidator, SettingsForm
|
||||
from pretix.base.forms import (
|
||||
I18nMarkdownTextarea, I18nModelForm, PlaceholderValidator, SettingsForm,
|
||||
)
|
||||
from pretix.base.models import Event, Organizer, TaxRule, Team
|
||||
from pretix.base.models.event import EventFooterLink, EventMetaValue, SubEvent
|
||||
from pretix.base.reldate import RelativeDateField, RelativeDateTimeField
|
||||
@@ -988,7 +990,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_signature = I18nFormField(
|
||||
label=_("Signature"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
help_text=_("This will be attached to every email. Available placeholders: {event}"),
|
||||
validators=[PlaceholderValidator(['{event}'])],
|
||||
widget_kwargs={'attrs': {
|
||||
@@ -1011,7 +1013,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_placed = I18nFormField(
|
||||
label=_("Text sent to order contact address"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_send_order_placed_attendee = forms.BooleanField(
|
||||
label=_("Send an email to attendees"),
|
||||
@@ -1027,7 +1029,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_placed_attendee = I18nFormField(
|
||||
label=_("Text sent to attendees"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
|
||||
mail_subject_order_paid = I18nFormField(
|
||||
@@ -1038,7 +1040,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_paid = I18nFormField(
|
||||
label=_("Text sent to order contact address"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_send_order_paid_attendee = forms.BooleanField(
|
||||
label=_("Send an email to attendees"),
|
||||
@@ -1054,7 +1056,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_paid_attendee = I18nFormField(
|
||||
label=_("Text sent to attendees"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
|
||||
mail_subject_order_free = I18nFormField(
|
||||
@@ -1065,7 +1067,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_free = I18nFormField(
|
||||
label=_("Text sent to order contact address"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_send_order_free_attendee = forms.BooleanField(
|
||||
label=_("Send an email to attendees"),
|
||||
@@ -1081,7 +1083,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_free_attendee = I18nFormField(
|
||||
label=_("Text sent to attendees"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
|
||||
mail_subject_order_changed = I18nFormField(
|
||||
@@ -1092,7 +1094,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_changed = I18nFormField(
|
||||
label=_("Text"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_subject_resend_link = I18nFormField(
|
||||
label=_("Subject (sent by admin)"),
|
||||
@@ -1107,7 +1109,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_resend_link = I18nFormField(
|
||||
label=_("Text (sent by admin)"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_subject_resend_all_links = I18nFormField(
|
||||
label=_("Subject (requested by user)"),
|
||||
@@ -1117,7 +1119,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_resend_all_links = I18nFormField(
|
||||
label=_("Text (requested by user)"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_days_order_expire_warning = forms.IntegerField(
|
||||
label=_("Number of days"),
|
||||
@@ -1129,7 +1131,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_expire_warning = I18nFormField(
|
||||
label=_("Text (if order will expire automatically)"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_subject_order_expire_warning = I18nFormField(
|
||||
label=_("Subject (if order will expire automatically)"),
|
||||
@@ -1139,7 +1141,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_pending_warning = I18nFormField(
|
||||
label=_("Text (if order will not expire automatically)"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_subject_order_pending_warning = I18nFormField(
|
||||
label=_("Subject (if order will not expire automatically)"),
|
||||
@@ -1154,7 +1156,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_incomplete_payment = I18nFormField(
|
||||
label=_("Text"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
help_text=_("This email only applies to payment methods that can receive incomplete payments, "
|
||||
"such as bank transfer."),
|
||||
)
|
||||
@@ -1166,7 +1168,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_payment_failed = I18nFormField(
|
||||
label=_("Text"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_subject_waiting_list = I18nFormField(
|
||||
label=_("Subject"),
|
||||
@@ -1176,7 +1178,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_waiting_list = I18nFormField(
|
||||
label=_("Text"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_subject_order_canceled = I18nFormField(
|
||||
label=_("Subject"),
|
||||
@@ -1186,12 +1188,12 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_canceled = I18nFormField(
|
||||
label=_("Text"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_text_order_custom_mail = I18nFormField(
|
||||
label=_("Text"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_subject_download_reminder = I18nFormField(
|
||||
label=_("Subject sent to order contact address"),
|
||||
@@ -1201,7 +1203,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_download_reminder = I18nFormField(
|
||||
label=_("Text sent to order contact address"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_send_download_reminder_attendee = forms.BooleanField(
|
||||
label=_("Send an email to attendees"),
|
||||
@@ -1217,7 +1219,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_download_reminder_attendee = I18nFormField(
|
||||
label=_("Text sent to attendees"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_days_download_reminder = forms.IntegerField(
|
||||
label=_("Number of days"),
|
||||
@@ -1234,7 +1236,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_placed_require_approval = I18nFormField(
|
||||
label=_("Text for received order"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_subject_order_approved = I18nFormField(
|
||||
label=_("Subject for approved order"),
|
||||
@@ -1244,7 +1246,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_approved = I18nFormField(
|
||||
label=_("Text for approved order"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
help_text=_("This will only be sent out for non-free orders. Free orders will receive the free order "
|
||||
"template from below instead."),
|
||||
)
|
||||
@@ -1262,7 +1264,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_approved_attendee = I18nFormField(
|
||||
label=_("Text sent to attendees"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
help_text=_("This will only be sent out for non-free orders. Free orders will receive the free order "
|
||||
"template from below instead."),
|
||||
)
|
||||
@@ -1274,7 +1276,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_approved_free = I18nFormField(
|
||||
label=_("Text for approved free order"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
help_text=_("This will only be sent out for free orders. Non-free orders will receive the non-free order "
|
||||
"template from above instead."),
|
||||
)
|
||||
@@ -1292,7 +1294,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_approved_free_attendee = I18nFormField(
|
||||
label=_("Text sent to attendees"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
help_text=_("This will only be sent out for free orders. Non-free orders will receive the non-free order "
|
||||
"template from above instead."),
|
||||
)
|
||||
@@ -1304,7 +1306,7 @@ class MailSettingsForm(FormPlaceholderMixin, SettingsForm):
|
||||
mail_text_order_denied = I18nFormField(
|
||||
label=_("Text for denied order"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
base_context = {
|
||||
'mail_text_order_placed': ['event', 'order', 'payments'],
|
||||
@@ -1737,7 +1739,7 @@ class ItemMetaPropertyForm(forms.ModelForm):
|
||||
|
||||
class ConfirmTextForm(I18nForm):
|
||||
text = I18nFormField(
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
widget_kwargs={'attrs': {'rows': '2'}},
|
||||
)
|
||||
|
||||
|
||||
@@ -36,10 +36,12 @@ from collections import OrderedDict
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from i18nfield.forms import I18nFormField, I18nTextarea, I18nTextInput
|
||||
from i18nfield.forms import I18nFormField, I18nTextInput
|
||||
|
||||
from pretix import settings
|
||||
from pretix.base.forms import SecretKeySettingsField, SettingsForm
|
||||
from pretix.base.forms import (
|
||||
I18nMarkdownTextarea, SecretKeySettingsField, SettingsForm,
|
||||
)
|
||||
from pretix.base.settings import GlobalSettingsObject
|
||||
from pretix.base.signals import register_global_settings
|
||||
|
||||
@@ -67,12 +69,12 @@ class GlobalSettingsForm(SettingsForm):
|
||||
help_text=_("Will be included as the link in the additional footer text.")
|
||||
)),
|
||||
('banner_message', I18nFormField(
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
required=False,
|
||||
label=_("Global message banner"),
|
||||
)),
|
||||
('banner_message_detail', I18nFormField(
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
required=False,
|
||||
label=_("Global message banner detail text"),
|
||||
)),
|
||||
|
||||
@@ -56,7 +56,7 @@ from django_scopes.forms import (
|
||||
from i18nfield.forms import I18nFormField, I18nTextarea
|
||||
|
||||
from pretix.base.channels import get_all_sales_channels
|
||||
from pretix.base.forms import I18nFormSet, I18nModelForm
|
||||
from pretix.base.forms import I18nFormSet, I18nMarkdownTextarea, I18nModelForm
|
||||
from pretix.base.forms.widgets import DatePickerWidget
|
||||
from pretix.base.models import (
|
||||
Item, ItemCategory, ItemVariation, Question, QuestionOption, Quota,
|
||||
@@ -82,6 +82,9 @@ class CategoryForm(I18nModelForm):
|
||||
'description',
|
||||
'is_addon'
|
||||
]
|
||||
widgets = {
|
||||
'description': I18nMarkdownTextarea,
|
||||
}
|
||||
|
||||
|
||||
class QuestionForm(I18nModelForm):
|
||||
@@ -188,6 +191,7 @@ class QuestionForm(I18nModelForm):
|
||||
attrs={'class': 'scrolling-multiple-choice'}
|
||||
),
|
||||
'dependency_values': forms.SelectMultiple,
|
||||
'help_text': I18nMarkdownTextarea,
|
||||
}
|
||||
field_classes = {
|
||||
'valid_datetime_min': SplitDateTimeField,
|
||||
@@ -823,6 +827,7 @@ class ItemUpdateForm(I18nModelForm):
|
||||
'max_per_order': forms.widgets.NumberInput(attrs={'min': 0}),
|
||||
'min_per_order': forms.widgets.NumberInput(attrs={'min': 0}),
|
||||
'checkin_text': forms.TextInput(),
|
||||
'description': I18nMarkdownTextarea,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,11 +47,14 @@ from django.utils.translation import (
|
||||
gettext_lazy as _, gettext_noop, pgettext_lazy,
|
||||
)
|
||||
from django_scopes.forms import SafeModelChoiceField
|
||||
from i18nfield.forms import I18nFormField, I18nTextarea, I18nTextInput
|
||||
from i18nfield.forms import I18nFormField, I18nTextInput
|
||||
from i18nfield.strings import LazyI18nString
|
||||
|
||||
from pretix.base.email import get_available_placeholders
|
||||
from pretix.base.forms import I18nModelForm, PlaceholderValidator
|
||||
from pretix.base.forms import (
|
||||
I18nMarkdownTextarea, I18nModelForm, MarkdownTextarea,
|
||||
PlaceholderValidator,
|
||||
)
|
||||
from pretix.base.forms.questions import WrappedPhoneNumberPrefixWidget
|
||||
from pretix.base.forms.widgets import (
|
||||
DatePickerWidget, SplitDateTimePickerWidget, format_placeholders_help_text,
|
||||
@@ -699,7 +702,7 @@ class OrderMailForm(forms.Form):
|
||||
self.fields['message'] = forms.CharField(
|
||||
label=_("Message"),
|
||||
required=True,
|
||||
widget=forms.Textarea,
|
||||
widget=MarkdownTextarea,
|
||||
initial=order.event.settings.mail_text_order_custom_mail.localize(order.locale),
|
||||
)
|
||||
self.fields['attach_invoices'].queryset = order.invoices.all()
|
||||
@@ -716,7 +719,7 @@ class OrderPositionMailForm(OrderMailForm):
|
||||
self.fields['message'] = forms.CharField(
|
||||
label=_("Message"),
|
||||
required=True,
|
||||
widget=forms.Textarea,
|
||||
widget=MarkdownTextarea,
|
||||
initial=self.order.event.settings.mail_text_order_custom_mail.localize(self.order.locale),
|
||||
)
|
||||
self._set_field_placeholders('message', ['event', 'order', 'position'])
|
||||
@@ -883,7 +886,7 @@ class EventCancelForm(FormPlaceholderMixin, forms.Form):
|
||||
)
|
||||
self.fields['send_message'] = I18nFormField(
|
||||
label=_('Message'),
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
required=True,
|
||||
widget_kwargs={'attrs': {'data-display-dependency': '#id_send'}},
|
||||
locales=self.event.settings.get('locales'),
|
||||
@@ -910,7 +913,7 @@ class EventCancelForm(FormPlaceholderMixin, forms.Form):
|
||||
)
|
||||
self.fields['send_waitinglist_message'] = I18nFormField(
|
||||
label=_('Message'),
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
required=True,
|
||||
locales=self.event.settings.get('locales'),
|
||||
widget_kwargs={'attrs': {'data-display-dependency': '#id_send_waitinglist'}},
|
||||
|
||||
@@ -48,7 +48,7 @@ from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import gettext_lazy as _, pgettext_lazy
|
||||
from django_scopes.forms import SafeModelChoiceField
|
||||
from i18nfield.forms import (
|
||||
I18nForm, I18nFormField, I18nFormSetMixin, I18nTextarea, I18nTextInput,
|
||||
I18nForm, I18nFormField, I18nFormSetMixin, I18nTextInput,
|
||||
)
|
||||
from phonenumber_field.formfields import PhoneNumberField
|
||||
from pytz import common_timezones
|
||||
@@ -56,7 +56,9 @@ from pytz import common_timezones
|
||||
from pretix.api.models import WebHook
|
||||
from pretix.api.webhooks import get_all_webhook_events
|
||||
from pretix.base.customersso.oidc import oidc_validate_and_complete_config
|
||||
from pretix.base.forms import I18nModelForm, PlaceholderValidator, SettingsForm
|
||||
from pretix.base.forms import (
|
||||
I18nMarkdownTextarea, I18nModelForm, PlaceholderValidator, SettingsForm,
|
||||
)
|
||||
from pretix.base.forms.questions import (
|
||||
NamePartsFormField, WrappedPhoneNumberPrefixWidget, get_country_by_locale,
|
||||
get_phone_prefix,
|
||||
@@ -524,7 +526,7 @@ class MailSettingsForm(SettingsForm):
|
||||
mail_text_signature = I18nFormField(
|
||||
label=_("Signature"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
help_text=_("This will be attached to every email."),
|
||||
validators=[PlaceholderValidator([])],
|
||||
widget_kwargs={'attrs': {
|
||||
@@ -543,7 +545,7 @@ class MailSettingsForm(SettingsForm):
|
||||
mail_text_customer_registration = I18nFormField(
|
||||
label=_("Text"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_subject_customer_email_change = I18nFormField(
|
||||
label=_("Subject"),
|
||||
@@ -553,7 +555,7 @@ class MailSettingsForm(SettingsForm):
|
||||
mail_text_customer_email_change = I18nFormField(
|
||||
label=_("Text"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
mail_subject_customer_reset = I18nFormField(
|
||||
label=_("Subject"),
|
||||
@@ -563,7 +565,7 @@ class MailSettingsForm(SettingsForm):
|
||||
mail_text_customer_reset = I18nFormField(
|
||||
label=_("Text"),
|
||||
required=False,
|
||||
widget=I18nTextarea,
|
||||
widget=I18nMarkdownTextarea,
|
||||
)
|
||||
|
||||
base_context = {
|
||||
|
||||
@@ -45,7 +45,9 @@ from django.utils.translation import gettext_lazy as _, pgettext_lazy
|
||||
from django_scopes.forms import SafeModelChoiceField
|
||||
|
||||
from pretix.base.email import get_available_placeholders
|
||||
from pretix.base.forms import I18nModelForm, PlaceholderValidator
|
||||
from pretix.base.forms import (
|
||||
I18nModelForm, MarkdownTextarea, PlaceholderValidator,
|
||||
)
|
||||
from pretix.base.forms.widgets import format_placeholders_help_text
|
||||
from pretix.base.models import Item, Voucher
|
||||
from pretix.control.forms import SplitDateTimeField, SplitDateTimePickerWidget
|
||||
@@ -271,7 +273,7 @@ class VoucherBulkForm(VoucherForm):
|
||||
)
|
||||
send_message = forms.CharField(
|
||||
label=_("Message"),
|
||||
widget=forms.Textarea(attrs={'data-display-dependency': '#id_send'}),
|
||||
widget=MarkdownTextarea(attrs={'data-display-dependency': '#id_send'}),
|
||||
required=False,
|
||||
initial=_('Hello,\n\n'
|
||||
'with this email, we\'re sending you one or more vouchers for {event}:\n\n{voucher_list}\n\n'
|
||||
|
||||
Reference in New Issue
Block a user