divio/django-cms — pull request #1155 by charettes (2012-01-27 17:43:43+00:00)
Title: Modifying jQuery global between `plugin_editor.js` loading and initialization using `.data()` breaks `PlaceholderPluginEditorWidget`

If the jQuery object is set to another object (it happens if another jQuery version gets included between plugin_editor.js finished loading but before the script in ```templates/admin/cms/page/widgets/plugin_editor.html``` is executed.

This patch makes sure they share the same jQuery object and thus plugin_editor can access the ```.data('id')``` of the object. Without this patch ```.data('id')``` returns ```null``` and then the request to create a plugin to the server chokes trying to cast ```'null'``` to ```int```

```
Traceback (most recent call last):

File ".../lib/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File ".../lib/django/utils/decorators.py", line 93, in _wrapped_view
response = view_func(request, *args, **kwargs)

File ".../lib/django/views/decorators/cache.py", line 79, in _wrapped_view_func
response = view_func(request, *args, **kwargs)

File ".../lib/django/contrib/admin/sites.py", line 197, in inner
return view(request, *args, **kwargs)

File ".../lib/cms/admin/placeholderadmin.py", line 140, in add_plugin
placeholder = get_object_or_404(Placeholder, pk=placeholder_id)

File ".../lib/django/shortcuts/__init__.py", line 113, in get_object_or_404
return queryset.get(*args, **kwargs)

File ".../lib/django/db/models/query.py", line 341, in get
clone = self.filter(*args, **kwargs)

File ".../lib/django/db/models/query.py", line 550, in filter
return self._filter_or_exclude(False, *args, **kwargs)

File ".../lib/django/db/models/query.py", line 568, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))

File ".../lib/django/db/models/sql/query.py", line 1194, in add_q
can_reuse=used_aliases, force_having=force_having)

File ".../lib/django/db/models/sql/query.py", line 1129, in add_filter
connector)

File ".../lib/django/db/models/sql/where.py", line 67, in add
value = obj.prepare(lookup_type, value)

File ".../lib/django/db/models/sql/where.py", line 316, in prepare
return self.field.get_prep_lookup(lookup_type, value)

File ".../lib/django/db/models/fields/__init__.py", line 292, in get_prep_lookup
return self.get_prep_value(value)

File ".../lib/django/db/models/fields/__init__.py", line 479, in get_prep_value
return int(value)

ValueError: invalid literal for int() with base 10: 'null'
```