How to use the threatexchange.forms function in threatexchange

To help you get started, we’ve selected a few threatexchange examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github crits / crits_services / threatexchange / __init__.py View on Github external
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
github crits / crits_services / threatexchange / __init__.py View on Github external
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