Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_config(existing_config):
# Generate default config from form and initial values.
config = {}
fields = forms.ThreatExchangeConfigForm().fields
for name, field in fields.iteritems():
config[name] = field.initial
# If there is a config in the database, use values from that.
if existing_config:
for key, value in existing_config.iteritems():
config[key] = value
return config
def generate_config_form(self, config):
html = render_to_string('services_config_form.html',
{'name': self.name,
'form': forms.ThreatExchangeConfigForm(
initial=config),
'config_error': None})
form = forms.ThreatExchangeConfigForm
return form, html