0001-python3-build-ajax-response-using-text-content-40733.patch
src/authentic2/manager/views.py | ||
---|---|---|
276 | 276 |
# otherwise compute an absolute URI from the relative URI |
277 | 277 |
if location and (not location.startswith('http://') |
278 | 278 |
or not location.startswith('https://') |
279 | 279 |
or not location.startswith('/')): |
280 | 280 |
location = request.build_absolute_uri(location) |
281 | 281 |
data['location'] = location |
282 | 282 |
if hasattr(response, 'render'): |
283 | 283 |
response.render() |
284 |
data['content'] = response.content
|
|
284 |
data['content'] = force_text(response.content)
|
|
285 | 285 |
return HttpResponse(json.dumps(data), content_type='application/json') |
286 | 286 | |
287 | 287 | |
288 | 288 |
class TitleMixin(object): |
289 | 289 |
'''Mixin to provide a title to the view's template''' |
290 | 290 |
title = '' |
291 | 291 | |
292 | 292 |
def get_context_data(self, **kwargs): |
tests/test_manager.py | ||
---|---|---|
933 | 933 | |
934 | 934 |
response = app.get(url) |
935 | 935 |
form = response.form |
936 | 936 |
form.set('email', 'new.email@gmail.net') |
937 | 937 |
response = form.submit().follow() |
938 | 938 | |
939 | 939 |
user = User.objects.get(id=simple_user.id) |
940 | 940 |
assert not user.email_verified |
941 | ||
942 | ||
943 |
def test_manager_ajax_form_view_mixin_response(superuser_or_admin, app): |
|
944 |
app.set_user(superuser_or_admin.username) |
|
945 |
resp = app.get('/manage/roles/add/', xhr=True) |
|
946 |
assert 'Authentic' in resp.text |
|
941 |
- |