def __init__(self, **kwargs): super(ScriptForm, self).__init__(**kwargs) event_choices = get_name_map("notify_event") self.fields["event_identifier"].choices = event_choices self.fields["event_identifier"].widget.choices = event_choices if self.instance.pk: self.fields["event_identifier"].help_text = ( _(u"Warning: Changing the event for an existing script may have unexpected effects.") )
def get_event_identifier_text(self, instance): if not hasattr(self, "_event_identifier_names"): self._event_identifier_names = dict(get_name_map("notify_event")) return self._event_identifier_names.get(instance.event_identifier, instance.event_identifier)