diff --git a/helios/crypto/utils.py b/helios/crypto/utils.py index ad364dc87bab1a806e471b2a4171eb37ac50fe97..dd395a598fbbec1df4bce90f81e7d95a9228b32b 100644 --- a/helios/crypto/utils.py +++ b/helios/crypto/utils.py @@ -2,9 +2,7 @@ Crypto Utils """ -import hmac, base64 - -from django.utils import simplejson +import hmac, base64, json from hashlib import sha256 @@ -18,8 +16,8 @@ def hash_b64(s): return result def to_json(d): - return simplejson.dumps(d, sort_keys=True) + return json.dumps(d, sort_keys=True) def from_json(json_str): if not json_str: return None - return simplejson.loads(json_str) + return json.loads(json_str) diff --git a/helios/datatypes/djangofield.py b/helios/datatypes/djangofield.py index 670eb59c345c01d73f67a0184c506ad7c1cc9e4b..4465da77d73c90fcbcfd8d9bec255fdbfc073647 100644 --- a/helios/datatypes/djangofield.py +++ b/helios/datatypes/djangofield.py @@ -7,10 +7,10 @@ and adapted to LDObject """ import datetime +import json from django.db import models from django.db.models import signals from django.conf import settings -from django.utils import simplejson as json from django.core.serializers.json import DjangoJSONEncoder from . import LDObject diff --git a/helios/election_urls.py b/helios/election_urls.py index 9b0f87470fcd1cfdb95e67419a2afde133b2042e..e6654d16187cdd6d503c955d7808361d686410b1 100644 --- a/helios/election_urls.py +++ b/helios/election_urls.py @@ -4,7 +4,7 @@ Helios URLs for Election related stuff Ben Adida (ben@adida.net) """ -from django.conf.urls.defaults import * +from django.conf.urls import * from helios.views import * diff --git a/helios/models.py b/helios/models.py index 7fda728b4ea6b9f8bad655be3e4cbf459f6fde05..695494f1fa5c465d1d8604d77f35eb21f09e9577 100644 --- a/helios/models.py +++ b/helios/models.py @@ -7,7 +7,7 @@ Ben Adida """ from django.db import models, transaction -from django.utils import simplejson +import json from django.conf import settings from django.core.mail import send_mail diff --git a/helios/stats_urls.py b/helios/stats_urls.py index 53bae6eec7d336416d3c326687e433b293ba76d0..2d26d1961aabae3a75bef2e16117d9dd3eea7566 100644 --- a/helios/stats_urls.py +++ b/helios/stats_urls.py @@ -4,7 +4,7 @@ Helios URLs for Election related stuff Ben Adida (ben@adida.net) """ -from django.conf.urls.defaults import * +from django.conf.urls import * from helios.stats_views import * diff --git a/helios/urls.py b/helios/urls.py index a8cfd41f7ea2c7162636975a42346b6338da1c10..1a0df511afb7cdbd6548432aa6a4d4d5888cc32e 100644 --- a/helios/urls.py +++ b/helios/urls.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from django.conf.urls.defaults import * +from django.conf.urls import * from django.conf import settings diff --git a/helios/view_utils.py b/helios/view_utils.py index 70b85f678f59e0c1f5289cc6e324ef59117d2620..3e3fb5a81461e0616af9b9ac2b937b2196071924 100644 --- a/helios/view_utils.py +++ b/helios/view_utils.py @@ -77,7 +77,7 @@ def render_json(json_txt): return HttpResponse(json_txt, "application/json") # decorator -def json(func): +def return_json(func): """ A decorator that serializes the output to JSON before returning to the web client. diff --git a/helios/views.py b/helios/views.py index 572517c1dab0093ccad67cee585829a72ec79702..9311f38799a282d491e7537de79f91a7e97eabdf 100644 --- a/helios/views.py +++ b/helios/views.py @@ -115,7 +115,7 @@ def admin_autologin(request): ## General election features ## -@json +@return_json def election_params(request): return ELGAMAL_PARAMS_LD_OBJECT.toJSONDict() @@ -265,14 +265,14 @@ def one_election_schedule(request, election): return HttpResponse("foo") @election_view() -@json +@return_json def one_election(request, election): if not election: raise Http404 return election.toJSONDict(complete=True) @election_view() -@json +@return_json def one_election_meta(request, election): if not election: raise Http404 @@ -381,7 +381,7 @@ def socialbuttons(request): ## As of July 2009, there are always trustees for a Helios election: one trustee is acceptable, for simple elections. ## @election_view() -@json +@return_json def list_trustees(request, election): trustees = Trustee.get_by_election(election) return [t.toJSONDict(complete=True) for t in trustees] @@ -500,7 +500,7 @@ def trustee_upload_pk(request, election, trustee): ## @election_view() -@json +@return_json def get_randomness(request, election): """ get some randomness to sprinkle into the sjcl entropy pool @@ -512,7 +512,7 @@ def get_randomness(request, election): } @election_view(frozen=True) -@json +@return_json def encrypt_ballot(request, election): """ perform the ballot encryption given answers_json, a JSON'ified list of list of answers @@ -780,14 +780,14 @@ def one_election_cast_done(request, election): include_user=(not logout)) @election_view() -@json +@return_json def one_election_result(request, election): if not election.result_released_at: raise PermissionDenied return election.result @election_view() -@json +@return_json def one_election_result_proof(request, election): if not election.result_released_at: raise PermissionDenied @@ -1355,7 +1355,7 @@ def voters_email(request, election): # Individual Voters @election_view() -@json +@return_json def voter_list(request, election): # normalize limit limit = int(request.GET.get('limit', 500)) @@ -1365,7 +1365,7 @@ def voter_list(request, election): return [v.ld_object.toDict() for v in voters] @election_view() -@json +@return_json def one_voter(request, election, voter_uuid): """ View a single voter's info as JSON. @@ -1376,7 +1376,7 @@ def one_voter(request, election, voter_uuid): return voter.toJSONDict() @election_view() -@json +@return_json def voter_votes(request, election, voter_uuid): """ all cast votes by a voter @@ -1386,7 +1386,7 @@ def voter_votes(request, election, voter_uuid): return [v.toJSONDict() for v in votes] @election_view() -@json +@return_json def voter_last_vote(request, election, voter_uuid): """ all cast votes by a voter @@ -1399,7 +1399,7 @@ def voter_last_vote(request, election, voter_uuid): ## @election_view() -@json +@return_json def ballot_list(request, election): """ this will order the ballots from most recent to oldest. diff --git a/helios_auth/auth_systems/facebookclient/__init__.py b/helios_auth/auth_systems/facebookclient/__init__.py index 6e5e6ce923af35606e8a305609f3e5435a865fca..03264730c9ab284b3500793fc232ad15175a945e 100644 --- a/helios_auth/auth_systems/facebookclient/__init__.py +++ b/helios_auth/auth_systems/facebookclient/__init__.py @@ -57,21 +57,24 @@ import mimetypes # try to use simplejson first, otherwise fallback to XML RESPONSE_FORMAT = 'JSON' -try: - import json as simplejson -except ImportError: - try: - import simplejson - except ImportError: - try: - from django.utils import simplejson - except ImportError: - try: - import jsonlib as simplejson - simplejson.loads - except (ImportError, AttributeError): - from xml.dom import minidom - RESPONSE_FORMAT = 'XML' + +import json + +# try: +# import json as simplejson +# except ImportError: +# try: +# import simplejson +# except ImportError: +# try: +# from django.utils import simplejson +# except ImportError: +# try: +# import jsonlib as simplejson +# simplejson.loads +# except (ImportError, AttributeError): +# from xml.dom import minidom +# RESPONSE_FORMAT = 'XML' # support Google App Engine. GAE does not have a working urllib.urlopen. try: diff --git a/helios_auth/auth_systems/facebookclient/djangofb/default_app/views.py b/helios_auth/auth_systems/facebookclient/djangofb/default_app/views.py index 931d6216a8f689167f7c5d22facf9b69551daeff..609314fe01b3bf546984841b9dded39756bfa0cb 100644 --- a/helios_auth/auth_systems/facebookclient/djangofb/default_app/views.py +++ b/helios_auth/auth_systems/facebookclient/djangofb/default_app/views.py @@ -1,5 +1,5 @@ from django.http import HttpResponse -from django.views.generic.simple import direct_to_template +# from django.views.generic.simple import direct_to_template #uncomment the following two lines and the one below #if you dont want to use a decorator instead of the middleware #from django.utils.decorators import decorator_from_middleware @@ -30,7 +30,8 @@ def canvas(request): # User is guaranteed to be logged in, so pass canvas.fbml # an extra 'fbuser' parameter that is the User object for # the currently logged in user. - return direct_to_template(request, 'canvas.fbml', extra_context={'fbuser': user}) + #return direct_to_template(request, 'canvas.fbml', extra_context={'fbuser': user}) + return None @facebook.require_login() def ajax(request): diff --git a/helios_auth/auth_systems/openid/util.py b/helios_auth/auth_systems/openid/util.py index 75272ea2570f3d70d0e205d2f153f4be1a3a423a..277b92ca18f21b5c9f465701217fe82fdea94c28 100644 --- a/helios_auth/auth_systems/openid/util.py +++ b/helios_auth/auth_systems/openid/util.py @@ -11,7 +11,6 @@ from django.template import loader from django import http from django.core.exceptions import ImproperlyConfigured from django.core.urlresolvers import reverse as reverseURL -from django.views.generic.simple import direct_to_template from django.conf import settings @@ -141,13 +140,3 @@ def normalDict(request_data): """ return dict((k, v[0]) for k, v in request_data.iteritems()) -def renderXRDS(request, type_uris, endpoint_urls): - """Render an XRDS page with the specified type URIs and endpoint - URLs in one service block, and return a response with the - appropriate content-type. - """ - response = direct_to_template( - request, 'xrds.xml', - {'type_uris':type_uris, 'endpoint_urls':endpoint_urls,}) - response['Content-Type'] = YADIS_CONTENT_TYPE - return response diff --git a/helios_auth/auth_systems/openid/view_helpers.py b/helios_auth/auth_systems/openid/view_helpers.py index d5ce72cd81290c2541b5c1cd31f7b1f94da911a8..cfdb4e6dfe855ccf8b17c1ed14a5e92d9cd8dc16 100644 --- a/helios_auth/auth_systems/openid/view_helpers.py +++ b/helios_auth/auth_systems/openid/view_helpers.py @@ -1,7 +1,6 @@ from django import http from django.http import HttpResponseRedirect -from django.views.generic.simple import direct_to_template from openid.consumer import consumer from openid.consumer.discover import DiscoveryFailure diff --git a/helios_auth/jsonfield.py b/helios_auth/jsonfield.py index 61b26ace3e1e14661d5cb35d8070986a8ebecab3..c0c83a69e0474cf83688567873a7416d65750fdc 100644 --- a/helios_auth/jsonfield.py +++ b/helios_auth/jsonfield.py @@ -4,11 +4,10 @@ taken from http://www.djangosnippets.org/snippets/377/ """ -import datetime +import datetime, json from django.db import models from django.db.models import signals from django.conf import settings -from django.utils import simplejson as json from django.core.serializers.json import DjangoJSONEncoder class JSONField(models.TextField): diff --git a/helios_auth/urls.py b/helios_auth/urls.py index 9db44e420a6b0b16d98c18463db7f80865d1242e..e4dca398503d1e2f802fd4811330b66b9020a1a9 100644 --- a/helios_auth/urls.py +++ b/helios_auth/urls.py @@ -4,7 +4,7 @@ Authentication URLs Ben Adida (ben@adida.net) """ -from django.conf.urls.defaults import * +from django.conf.urls import * from views import * from auth_systems.password import password_login_view, password_forgotten_view diff --git a/helios_auth/utils.py b/helios_auth/utils.py index 78a613a596f0b1deef8b3a3610269df038793e0f..f57dedf6e961e8598963049dca55f6cdaf211f00 100644 --- a/helios_auth/utils.py +++ b/helios_auth/utils.py @@ -5,18 +5,18 @@ Some basic utils 2010-08-17 """ -from django.utils import simplejson +import json ## JSON def to_json(d): - return simplejson.dumps(d, sort_keys=True) + return json.dumps(d, sort_keys=True) def from_json(json_str): if not json_str: return None - return simplejson.loads(json_str) + return json.loads(json_str) def JSONtoDict(json): - x=simplejson.loads(json) + x=json.loads(json) return x def JSONFiletoDict(filename): diff --git a/requirements.txt b/requirements.txt index d4212da7da640f2840dec177d8b0e551234ce01a..569b6438e442a39ff1b74342931f58d03d7ca22e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Django==1.4.18 +Django==1.6.10 South==0.8.2 anyjson==0.3.1 celery==3.0.16 diff --git a/server_ui/urls.py b/server_ui/urls.py index 2554c6ee1d1a01cb5cff73698874d44a116cd684..d71e04dcac68008d2001ca99c7df7f055bd6404a 100644 --- a/server_ui/urls.py +++ b/server_ui/urls.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from django.conf.urls.defaults import * +from django.conf.urls import * from views import * diff --git a/urls.py b/urls.py index c69f6bab18acd02739267c660900aada4cc782dc..d4674991451a72c154ae6d91bfdf5a0dd0bee8a1 100644 --- a/urls.py +++ b/urls.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from django.conf.urls.defaults import * +from django.conf.urls import * from django.contrib import admin from django.conf import settings