alphagov/stagecraft — pull request #49 by paulfurley (2014-02-21 18:35:56+00:00)
Title:  from stagecraft.apps.datasets.models import DataSet >>> from stagecraft.apps.datasets.models import DataSet, DataGroup, DataType >>> group = DataGroup.objects.create(name='group') >>> type_=DataGroup.objects.create(name='type')Make blank/empty bearer_tok

So it turns out that CharFields & NULL really don't work together, even
if you set null=true (see https://code.djangoproject.com/ticket/9590)

So the first change is a data migration to change any NULL bearer tokens
back to "" after previous commit which allowed NULL.

I've changed the ``serialize()`` method to interpret bearer_token of ""
as NULL. I've added tests and updated the view test so we are sure that
our backdrop endpoint will present NULL, not "".

I've tested the data migration by making a DataSet with a NULL bearer_token (on origin/master)
```
from stagecraft.apps.datasets.models import DataSet, DataGroup, DataType
group = DataGroup.objects.create(name='group')
type_=DataGroup.objects.create(name='type')
a = DataSet.objects.create(name='foo', data_group=group, data_type=type_, bearer_token=None)
```

Then checking out this branch and running the migration ``0006_convert_null_bearer_token_to_blank``