From 977973fffe399dbc35951dd96a2a3755960241da Mon Sep 17 00:00:00 2001 From: Ben Adida <ben@adida.net> Date: Sun, 25 Jan 2015 22:58:33 +0000 Subject: [PATCH] began update to django 1.6 --- helios/crypto/utils.py | 8 ++--- helios/datatypes/djangofield.py | 2 +- helios/election_urls.py | 2 +- helios/models.py | 2 +- helios/stats_urls.py | 2 +- helios/urls.py | 2 +- helios/view_utils.py | 2 +- helios/views.py | 26 +++++++-------- .../auth_systems/facebookclient/__init__.py | 33 ++++++++++--------- .../djangofb/default_app/views.py | 5 +-- helios_auth/auth_systems/openid/util.py | 11 ------- .../auth_systems/openid/view_helpers.py | 1 - helios_auth/jsonfield.py | 3 +- helios_auth/urls.py | 2 +- helios_auth/utils.py | 8 ++--- requirements.txt | 2 +- server_ui/urls.py | 2 +- urls.py | 2 +- 18 files changed, 52 insertions(+), 63 deletions(-) diff --git a/helios/crypto/utils.py b/helios/crypto/utils.py index ad364dc..dd395a5 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 670eb59..4465da7 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 9b0f874..e6654d1 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 7fda728..695494f 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 53bae6e..2d26d19 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 a8cfd41..1a0df51 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 70b85f6..3e3fb5a 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 572517c..9311f38 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 6e5e6ce..0326473 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 931d621..609314f 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 75272ea..277b92c 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 d5ce72c..cfdb4e6 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 61b26ac..c0c83a6 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 9db44e4..e4dca39 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 78a613a..f57dedf 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 d4212da..569b643 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 2554c6e..d71e04d 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 c69f6ba..d467499 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 -- GitLab