Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added setting to allow response methods to be any module, not just ajax.py #53

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
abdef25
Added settings.DAJAXICE_IMPLICIT_MODULE_NAME functionality
Ghopper21 Jun 28, 2012
8e5debb
Changed accidental tabs to spaces
Ghopper21 Jun 28, 2012
8770f89
Hide 'something goes wrong' pop-up error caused by timing
Ghopper21 Dec 30, 2012
982f474
tweaks to work with django1.6
seawaywen Dec 1, 2013
6ca420c
tweaks to work with django1.6
seawaywen Dec 1, 2013
ec09476
tweaks to work with django1.6
seawaywen Dec 1, 2013
7cb384e
fixed the issue that still use simplejson after import the json package
seawaywen Dec 2, 2013
2586834
Merge branch 'master' of https://github.com/jorgebastida/django-dajaxice
Jan 21, 2014
dc1d50c
Change an import for update to Django 1.6.
Jan 21, 2014
b238b14
Merge pull request #1 from azlyth/master
Ghopper21 Jan 22, 2014
c86f06f
Merge branch 'master' of https://github.com/seawaywen/django-dajaxice
Jan 22, 2014
89ea015
Merge pull request #2 from azlyth/master
Ghopper21 Jan 22, 2014
5cbc437
Make compatible with Django 1.7+
airikh Jan 6, 2016
6ab875f
Merge pull request #3 from Ghopper21/django-1.7-support
Ghopper21 Jan 6, 2016
ef0a9fc
Add missing django import
airikh Jan 6, 2016
2b894c8
Merge pull request #4 from Ghopper21/bugfix-missing-django-import
Ghopper21 Jan 6, 2016
19bda83
Change django utils to standard importlib library
korsunowk Oct 11, 2017
8ac7014
Merge pull request #5 from Ghopper21/managerjellyfish/ch229/fix-use-o…
Ghopper21 Oct 12, 2017
c291aaf
Remove deprecated in Django 1.9 url from future, use build-in url
korsunowk Oct 19, 2017
6f514ff
Merge pull request #6 from Ghopper21/managerjellyfish/ch288/fix-dajax…
Ghopper21 Oct 19, 2017
e842e42
Fix all things for upgrade to the Django 1.9 version
korsunowk Nov 3, 2017
21022a1
Merge pull request #7 from Ghopper21/managerjellyfish/ch288/fix-dajax…
Ghopper21 Nov 3, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dajaxice/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = (0, 5, 5, 'beta')
__version__ = (0, 5, 6, 'beta')
2 changes: 1 addition & 1 deletion dajaxice/core/Dajaxice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from django.utils.importlib import import_module
from importlib import import_module

log = logging.getLogger('dajaxice')

Expand Down
2 changes: 1 addition & 1 deletion dajaxice/finders.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def dajaxice_core_js(self):

dajaxice_autodiscover()

c = Context({'dajaxice_config': dajaxice_config})
c = {'dajaxice_config': dajaxice_config}
return get_template(os.path.join('dajaxice', 'dajaxice.core.js')).render(c)


Expand Down
3 changes: 1 addition & 2 deletions dajaxice/templates/dajaxice/dajaxice.core.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{% load url from future %}
var Dajaxice = {

{% with module=dajaxice_config.modules top='top' %}
Expand Down Expand Up @@ -48,7 +47,7 @@ var Dajaxice = {
oXMLHttpRequest.setRequestHeader("X-CSRFToken", Dajaxice.get_cookie('{{ dajaxice_config.django_settings.CSRF_COOKIE_NAME }}'));
oXMLHttpRequest.onreadystatechange = function() {
if (this.readyState == XMLHttpRequest.DONE) {
if(this.responseText == Dajaxice.EXCEPTION || !(this.status in Dajaxice.valid_http_responses())){
if(this.status != '' && (this.responseText == Dajaxice.EXCEPTION || !(this.status in Dajaxice.valid_http_responses()))){
error_callback();
}
else{
Expand Down
3 changes: 2 additions & 1 deletion dajaxice/templatetags/dajaxice_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.middleware.csrf import get_token
from django.conf import settings
from django.core.files.storage import get_storage_class
from django.utils.html import format_html

staticfiles_storage = get_storage_class(settings.STATICFILES_STORAGE)()

Expand Down Expand Up @@ -32,4 +33,4 @@ def dajaxice_js_import(context, csrf=True):
"and render your views using a RequestContext.")

url = staticfiles_storage.url('dajaxice/dajaxice.core.js')
return '<script src="%s" type="text/javascript" charset="utf-8"></script>' % url
return format_html('<script src="%s" type="text/javascript" charset="utf-8"></script>' % url)
6 changes: 3 additions & 3 deletions dajaxice/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from django.conf.urls.defaults import *
from django.conf.urls import url, include

from dajaxice.core import dajaxice_autodiscover, dajaxice_config

dajaxice_autodiscover()

urlpatterns = patterns('',
urlpatterns = [
#Dajaxice URLS
url(dajaxice_config.dajaxice_url, include('dajaxice.urls')),
)
]
6 changes: 3 additions & 3 deletions dajaxice/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf.urls.defaults import *
from django.conf.urls import url
from .views import DajaxiceRequest

urlpatterns = patterns('dajaxice.views',
urlpatterns = [
url(r'^(.+)/$', DajaxiceRequest.as_view(), name='dajaxice-call-endpoint'),
url(r'', DajaxiceRequest.as_view(), name='dajaxice-endpoint'),
)
]
10 changes: 7 additions & 3 deletions dajaxice/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging
import json
import django

from django.conf import settings
from django.utils import simplejson
from django.views.generic.base import View
from django.http import HttpResponse, Http404

Expand Down Expand Up @@ -41,7 +42,7 @@ def dispatch(self, request, name=None):
# Clean the argv
if data != 'undefined':
try:
data = safe_dict(simplejson.loads(data))
data = safe_dict(json.loads(data))
except Exception:
data = {}
else:
Expand All @@ -55,6 +56,9 @@ def dispatch(self, request, name=None):
raise
response = dajaxice_config.DAJAXICE_EXCEPTION

return HttpResponse(response, mimetype="application/x-json")
if django.get_version() >= '1.7':
return HttpResponse(response, content_type="application/x-json")
else:
return HttpResponse(response, mimetype="application/x-json")
else:
raise FunctionNotCallableError(name)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='django-dajaxice',
version='0.5.5',
version='0.5.6',
author='Jorge Bastida',
author_email='me@jorgebastida.com',
description='Agnostic and easy to use ajax library for django',
Expand Down