Commit e9ce3b88 authored by Joseph Wilhelm's avatar Joseph Wilhelm

Merge branch 'master' of labs.lyrical.net:jwilhelm/django-botscout

parents c664d980 cf6dc20b
django-botscout django-botscout
=============== ===============
This provides an easy hook into the Botscout system for Django forms This provides an easy hook into the Botscout system for Django forms
Available Settings Available Settings
------------------ ------------------
```python ```python
# All settings are optional. They are displayed here with their defaults # All settings are optional. They are displayed here with their defaults
BOTSCOUT_API_KEY = None BOTSCOUT_API_KEY = None
BOTSCOUT_API_URL = 'http://botscout.com/test/' BOTSCOUT_API_URL = 'http://botscout.com/test/'
BOTSCOUT_CACHE_TIMEOUT = 1800 BOTSCOUT_CACHE_TIMEOUT = 1800
BOTSCOUT_NETWORK_TIMEOUT = 5 BOTSCOUT_NETWORK_TIMEOUT = 5
``` ```
Additionally, you can set the following variables on individual forms to alter
their behavior: Additionally, you can set the following variables on individual forms to alter
```python their behavior:
BOTSCOUT_NAME_FIELD = 'name'
BOTSCOUT_EMAIL_FIELD = 'email' ```python
BOTSCOUT_ERROR_MESSAGE = 'This request was matched in the BotScout database' BOTSCOUT_NAME_FIELD = 'name'
``` BOTSCOUT_EMAIL_FIELD = 'email'
BOTSCOUT_ERROR_MESSAGE = 'This request was matched in the BotScout database'
```
Basic Usage
-----------
In forms.py: Basic Usage
```python -----------
from botscout import BotScoutForm In forms.py:
from django import forms
```python
from botscout import BotScoutForm
class ContactForm(BotScoutForm, forms.Form): from django import forms
name = forms.CharField('Name')
email = forms.EmailField('Email')
``` class ContactForm(BotScoutForm, forms.Form):
In views.py: name = forms.CharField('Name')
```python email = forms.EmailField('Email')
from .forms import ContactForm ```
In views.py:
def contact(request):
if request.method == 'POST': ```python
form = ContactForm(request=request, data=request.POST) from .forms import ContactForm
if form.is_valid():
...
else: def contact(request):
form = ContactForm(request=request) if request.method == 'POST':
... form = ContactForm(request=request, data=request.POST)
``` if form.is_valid():
...
Advanced Usage else:
-------------- form = ContactForm(request=request)
```python ...
from botscout import BotScoutForm ```
from django import forms
from django.db import models Advanced Usage
--------------
```python
class Person(models.Model): from botscout import BotScoutForm
full_name = models.CharField('Full name', max_length=255) from django import forms
email_address = models.EmailField('Email') from django.db import models
class MyForm(BotScoutForm, forms.ModelForm): class Person(models.Model):
BOTSCOUT_NAME_FIELD = 'full_name' full_name = models.CharField('Full name', max_length=255)
BOTSCOUT_EMAIL_FIELD = 'email_address' email_address = models.EmailField('Email')
BOTSCOUT_ERROR_MESSAGE = 'GO AWAY SPAM BOT!'
class Meta: class MyForm(BotScoutForm, forms.ModelForm):
model = Person BOTSCOUT_NAME_FIELD = 'full_name'
BOTSCOUT_EMAIL_FIELD = 'email_address'
BOTSCOUT_ERROR_MESSAGE = 'GO AWAY SPAM BOT!'
class Meta:
model = Person
``` ```
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment