From 2148ac7e2b5af33ab1465241da9e008335f11b6b Mon Sep 17 00:00:00 2001 From: Sanjay Bhangar Date: Fri, 9 Mar 2018 20:26:31 +0530 Subject: [PATCH] upgrade to django 1.4, remove unneeded dependencies --- requirements.txt | 7 ++----- rizk/egypt/views.py | 15 ++++++++++++++- rizk/settings.py | 32 +++++++++++++++++++++----------- rizk/static/js/rizk.js | 2 +- 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/requirements.txt b/requirements.txt index f5e987e..11bbf61 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,3 @@ --e svn+http://code.djangoproject.com/svn/django/branches/releases/1.2.X/#egg=django -ox -South -elementtree +Django==1.4 django-extensions -django-debug-toolbar +# django-debug-toolbar diff --git a/rizk/egypt/views.py b/rizk/egypt/views.py index 3b8cedc..54ef307 100644 --- a/rizk/egypt/views.py +++ b/rizk/egypt/views.py @@ -2,10 +2,10 @@ from django.shortcuts import render_to_response from django.http import HttpResponse from django.shortcuts import get_object_or_404 -from oxdjango.shortcuts import render_to_json_response from django.core.mail import send_mail from models import * from settings import GOOGLE_MAPS_API_KEY as gkey +import json QUESTIONS = { '1problems': 'What problems do flyover and skywalk projects create?', @@ -13,6 +13,19 @@ QUESTIONS = { '3stories': 'Do you have any stories about flyovers or skywalks in Mumbai or elsewhere?' } +def render_to_json_response(dictionary, content_type="text/json", status=200): + indent=None + if settings.DEBUG: + content_type = "text/javascript" + indent = 2 + if settings.JSON_DEBUG: + print json.dumps(dictionary, indent=2) + if 'status' in dictionary and 'code' in dictionary['status']: + status = dictionary['status']['code'] + return HttpResponse(json.dumps(dictionary, indent=indent), + content_type=content_type, status=status) + + def geojson(request): features = [] for l in Location.objects.all(): diff --git a/rizk/settings.py b/rizk/settings.py index fddd214..d617021 100644 --- a/rizk/settings.py +++ b/rizk/settings.py @@ -16,12 +16,23 @@ ADMINS = ( MANAGERS = ADMINS GOOGLE_MAPS_API_KEY = 'ABQIAAAAsn1j-ZGGtRgZ9aMJPCZbRxQ7qtcPomt5R65jYWcqt6293S9jUBRFELNu52BN---sow276q3W0R-Hvg' -DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. -DATABASE_NAME = 'rizk' # Or path to database file if using sqlite3. -DATABASE_USER = 'root' # Not used with sqlite3. -DATABASE_PASSWORD = '' # Not used with sqlite3. -DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. -DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. + +DATABASES = { + 'default': { + 'ENGINE': 'django.contrib.gis.db.backends.postgis', + 'NAME': 'rizk', + # 'USER': , + # 'PASSWORD': env('POSTGRES_PASSWORD'), + # 'HOST': + } +} + +# DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. +# DATABASE_NAME = 'rizk' # Or path to database file if using sqlite3. +# DATABASE_USER = 'root' # Not used with sqlite3. +# DATABASE_PASSWORD = '' # Not used with sqlite3. +# DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. +# DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name @@ -68,8 +79,8 @@ TEMPLATE_CONTEXT_PROCESSORS = ( # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.load_template_source', - 'django.template.loaders.app_directories.load_template_source', + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.load_template_source', ) @@ -77,7 +88,7 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'debug_toolbar.middleware.DebugToolbarMiddleware', + # 'debug_toolbar.middleware.DebugToolbarMiddleware', ) ROOT_URLCONF = 'urls' @@ -97,8 +108,7 @@ INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.gis', 'egypt', - 'debug_toolbar', - 'django_extensions', + # 'django_extensions' ) #overwrite default settings with local settings diff --git a/rizk/static/js/rizk.js b/rizk/static/js/rizk.js index 2e3f5b5..c73d733 100644 --- a/rizk/static/js/rizk.js +++ b/rizk/static/js/rizk.js @@ -96,7 +96,7 @@ $(function() { $('.eventSelected').removeClass('eventSelected'); $(this).addClass('eventSelected'); } - var eventId = $(this).data('id'); + var eventId = $(this).attr('data-id'); $('#media').html("Loading..."); $.getJSON("eventMedia", {'id': eventId}, function(data) { // console.log(data);