def __init__(self, domain, config, *args, **kwargs): self.domain = domain self.config = config def _to_initial(config): initial = copy.copy(config._doc) initial['schedule'] = config.schedule.interval if config.template_variables: initial['application'] = config.template_variables[0].app_id initial['source'] = config.template_variables[0].source_id initial['time_range'] = config.template_variables[0].time_range return initial super(PerformanceMessageEditForm, self).__init__(initial=_to_initial(config), *args, **kwargs) self.fields['recipient_id'] = GroupField(domain=domain, label=_('Recipient Group')) self.app_source_helper = ApplicationDataSourceUIHelper( enable_cases=False) self.app_source_helper.bootstrap(self.domain) data_source_fields = self.app_source_helper.get_fields() self.fields.update(data_source_fields) self.helper = _get_default_form_helper() form_layout = self.fields.keys() form_layout.append( hqcrispy.FormActions( StrictButton( _("Save Changes"), type="submit", css_class="btn btn-primary", ), )) self.helper.layout = Layout(*form_layout)
def __init__(self, domain, config, *args, **kwargs): self.domain = domain self.config = config super(AdvancedPerformanceMessageEditForm, self).__init__(initial=config.to_json(), *args, **kwargs) self.fields['recipient_id'] = GroupField(domain=domain, label=_('Recipient Group')) self.helper = _get_default_form_helper() form_layout = self.fields.keys() form_layout.append( hqcrispy.FormActions( StrictButton( _("Save Changes"), type="submit", css_class="btn btn-primary", ), )) self.helper.layout = Layout(*form_layout)