show default messages in options

This commit is contained in:
Jim Ladd
2019-08-14 10:33:24 -07:00
parent 0ddc32a6dc
commit 7bf250ecfa
11 changed files with 63 additions and 0 deletions

View File

@@ -114,6 +114,17 @@ class Metadata(metadata.SimpleMetadata):
for (notification_type_name, notification_tr_name, notification_type_class) in NotificationTemplate.NOTIFICATION_TYPES:
field_info[notification_type_name] = notification_type_class.init_parameters
# Special handling of notification messages where the required properties
# are conditional on the type selected.
try:
view_model = field.context['view'].model
except (AttributeError, KeyError):
view_model = None
if view_model == NotificationTemplate and field.field_name == 'messages':
for (notification_type_name, notification_tr_name, notification_type_class) in NotificationTemplate.NOTIFICATION_TYPES:
field_info[notification_type_name] = notification_type_class.default_messages
# Update type of fields returned...
if field.field_name == 'type':
field_info['type'] = 'choice'