Skip to content
Snippets Groups Projects
Verified Commit d2a359bb authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Fix use of some preferences

parent 256e3864
No related branches found
No related tags found
1 merge request!217Migrate from constance to dynamic-preferences
......@@ -43,7 +43,6 @@ class ColourPrimary(StringPreference):
default = "#0d5eaf"
required = False
verbose_name = _("Primary colour")
widget = ColorWidget
@global_preferences_registry.register
......@@ -53,7 +52,6 @@ class ColourSecondary(StringPreference):
default = "#0d5eaf"
required = False
verbose_name = _("Secondary colour")
widget = ColorWidget
@global_preferences_registry.register
......@@ -68,7 +66,7 @@ class MailOutName(StringPreference):
@global_preferences_registry.register
class MailOut(StringPreference):
section = mail
name = "name"
name = "address"
default = settings.DEFAULT_FROM_EMAIL
required = False
verbose_name = _("Mail out address")
......@@ -115,10 +113,10 @@ class NotificationChannels(ChoicePreference):
# FIXME should be a MultipleChoicePreference
section = notification
name = "channels"
default = ["email"]
default = "email"
required = False
verbose_name = _("Channels to use for notifications")
choices = get_notification_choices_lazy
choices = get_notification_choices_lazy()
@global_preferences_registry.register
......
......@@ -38,7 +38,7 @@ def _send_notification_email(notification: "Notification", template: str = "noti
}
send_templated_mail(
template_name=template,
from_email=lazy_preference("notification__mail_out"),
from_email=lazy_preference("mail", "address"),
recipient_list=[notification.recipient.email],
context=context,
)
......@@ -63,7 +63,7 @@ def _send_notification_sms(
# - Check for availability
# - Send notification through it
_CHANNELS_MAP = {
"email": (_("E-Mail"), lambda: lazy_preference("notification__mail_out"), _send_notification_email),
"email": (_("E-Mail"), lambda: lazy_preference("mail", "address"), _send_notification_email),
"sms": (_("SMS"), lambda: getattr(settings, "TWILIO_SID", None), _send_notification_sms),
}
......@@ -75,7 +75,7 @@ def send_notification(notification: Union[int, "Notification"], resend: bool = F
previously marked as sent.
"""
channels = lazy_preference("notification__channels")
channels = lazy_preference("notification", "channels")
if isinstance(notification, int):
Notification = apps.get_model("core", "Notification")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment