diff --git a/core/admin.py b/core/admin.py index 6e9d058..305613c 100644 --- a/core/admin.py +++ b/core/admin.py @@ -4,7 +4,7 @@ from django.forms import ModelForm import django.forms as forms from django.http import HttpResponse from django.core import serializers -from core.views_other import downloadLogbook +from troggle.core.views_other import downloadLogbook #from troggle.reversion.admin import VersionAdmin #django-reversion version control @@ -12,8 +12,8 @@ class TroggleModelAdmin(admin.ModelAdmin): def save_model(self, request, obj, form, change): """overriding admin save to fill the new_since parsing_field""" - obj.new_since_parsing=True - obj.save() + obj.new_since_parsing=True + obj.save() class Media: js = ('jquery/jquery.min.js','js/QM_helper.js') diff --git a/core/context.py b/core/context.py index a77de49..6b3b928 100644 --- a/core/context.py +++ b/core/context.py @@ -1,5 +1,5 @@ from django.conf import settings -from core.models import Expedition +from troggle.core.models import Expedition def troggle_context(request): return { 'settings':settings, 'Expedition':Expedition } \ No newline at end of file diff --git a/core/models.py b/core/models.py index 22b8ea4..28efaac 100644 --- a/core/models.py +++ b/core/models.py @@ -15,7 +15,7 @@ from django.template import Context, loader import settings getcontext().prec=2 #use 2 significant figures for decimal calculations -from models_survex import * +from troggle.core.models_survex import * def get_related_by_wikilinks(wiki_text): @@ -55,7 +55,7 @@ class TroggleModel(models.Model): return urlparse.urljoin(settings.URL_ROOT, "/admin/core/" + self.object_name().lower() + "/" + str(self.pk)) class Meta: - abstract = True + abstract = True class TroggleImageModel(ImageModel): new_since_parsing = models.BooleanField(default=False, editable=False) @@ -68,7 +68,7 @@ class TroggleImageModel(ImageModel): class Meta: - abstract = True + abstract = True # # single Expedition, usually seen by year @@ -140,7 +140,7 @@ class Person(TroggleModel): return urlparse.urljoin(settings.URL_ROOT,reverse('person',kwargs={'first_name':self.first_name,'last_name':self.last_name})) class Meta: - verbose_name_plural = "People" + verbose_name_plural = "People" class Meta: ordering = ('orderref',) # "Wookey" makes too complex for: ('last_name', 'first_name') diff --git a/core/templatetags/wiki_markup.py b/core/templatetags/wiki_markup.py index 4087b12..3bc5b07 100644 --- a/core/templatetags/wiki_markup.py +++ b/core/templatetags/wiki_markup.py @@ -3,7 +3,7 @@ from django.utils.html import conditional_escape from django.template.defaultfilters import stringfilter from django.utils.safestring import mark_safe from django.conf import settings -from core.models import QM, DPhoto, LogbookEntry, Cave +from troggle.core.models import QM, DPhoto, LogbookEntry, Cave import re, urlparse register = template.Library() diff --git a/databaseReset.py b/databaseReset.py index 0964b79..8e2772c 100644 --- a/databaseReset.py +++ b/databaseReset.py @@ -8,8 +8,8 @@ from django.db import connection from django.contrib.auth.models import User from django.http import HttpResponse from django.core.urlresolvers import reverse -from core.models import Cave, Entrance -import flatpages.models +from troggle.core.models import Cave, Entrance +import troggle.flatpages.models databasename=settings.DATABASES['default']['NAME'] expouser=settings.EXPOUSER diff --git a/flatpages/models.py b/flatpages/models.py index 1c97851..7631881 100644 --- a/flatpages/models.py +++ b/flatpages/models.py @@ -1,5 +1,5 @@ from django.db import models -from core.models import Cave, Entrance +from troggle.core.models import Cave, Entrance class Redirect(models.Model): originalURL = models.CharField(max_length=200, unique=True) diff --git a/flatpages/views.py b/flatpages/views.py index 0b4a8a0..6503d40 100644 --- a/flatpages/views.py +++ b/flatpages/views.py @@ -75,7 +75,7 @@ def flatpage(request, path): body.strip return render_with_context(request, 'flatpage.html', {'editable': True, 'path': path, 'title': title, 'body': body, 'homepage': (path == "index.htm")}) else: - return HttpResponse(o.read(), mimetype=getmimetype(path)) + return HttpResponse(o.read(), content_type=getmimetype(path)) def getmimetype(path): if path.lower().endswith(".png"): return "image/png" diff --git a/manage.py b/manage.py index bd52fd6..f9726f9 100644 --- a/manage.py +++ b/manage.py @@ -1,8 +1,10 @@ #!/usr/bin/env python -import os, sys +import os +import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings") - from django.core.management import execute_from_command_line - execute_from_command_line(sys.argv) + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/parsers/QMs.py b/parsers/QMs.py index f9a6d89..efc8cd6 100644 --- a/parsers/QMs.py +++ b/parsers/QMs.py @@ -2,7 +2,7 @@ import csv from django.conf import settings -from core.models import QM, LogbookEntry, Cave +from troggle.core.models import QM, LogbookEntry, Cave from datetime import * from utils import save_carefully import re, os @@ -87,7 +87,7 @@ def parseCaveQMs(cave,inputFile): continue def parse_KH_QMs(kh, inputFile): - """import QMs from the 1623-161 (Kaninchenhöhle) html pages + """import QMs from the 1623-161 (Kaninchenh�hle) html pages """ khQMs=open(settings.EXPOWEB+inputFile,'r') khQMs=khQMs.readlines() diff --git a/parsers/cavetab.py b/parsers/cavetab.py index 9f04105..99202d5 100644 --- a/parsers/cavetab.py +++ b/parsers/cavetab.py @@ -4,7 +4,7 @@ from django.conf import settings import csv, time, re, os, logging from utils import save_carefully from django.core.urlresolvers import reverse -import flatpages.models +import troggle.flatpages.models ##format of CAVETAB2.CSV is KatasterNumber = 0 diff --git a/parsers/logbooks.py b/parsers/logbooks.py index 4180345..cb40f58 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -1,7 +1,7 @@ #.-*- coding: utf-8 -*- from django.conf import settings -import core.models as models +import troggle.core.models as models from parsers.people import GetPersonExpeditionNameLookup from parsers.cavetab import GetCaveLookup diff --git a/parsers/people.py b/parsers/people.py index 7898ccd..bc18472 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -1,7 +1,7 @@ #.-*- coding: utf-8 -*- from django.conf import settings -import core.models as models +import troggle.core.models as models import csv, re, datetime, os, shutil from utils import save_carefully diff --git a/parsers/subcaves.py b/parsers/subcaves.py index 6905d0a..739af44 100644 --- a/parsers/subcaves.py +++ b/parsers/subcaves.py @@ -6,7 +6,7 @@ import sys, os import os, re, logging from django.conf import settings -from core.models import Subcave, Cave +from troggle.core.models import Subcave, Cave from utils import save_carefully def getLinksInCaveDescription(cave): diff --git a/parsers/surveys.py b/parsers/surveys.py index b94481e..26e46f9 100644 --- a/parsers/surveys.py +++ b/parsers/surveys.py @@ -3,7 +3,7 @@ import sys, os, types, logging, stat #from troggle import * #os.environ['DJANGO_SETTINGS_MODULE']='troggle.settings' import settings -from core.models import * +from troggle.core.models import * from PIL import Image #import settings #import core.models as models diff --git a/profiles/utils.py b/profiles/utils.py index faacfcb..c2dfd61 100644 --- a/profiles/utils.py +++ b/profiles/utils.py @@ -7,7 +7,13 @@ site-specific user profile model specified in the from django import forms from django.conf import settings -from django.contrib.auth.models import SiteProfileNotAvailable +#from django.contrib.auth.models import SiteProfileNotAvailable + +try: + from django.contrib.auth.models import SiteProfileNotAvailable +except ImportError: # django >= 1.7 + SiteProfileNotAvailable = type('SiteProfileNotAvailable', (Exception,), {}) + from django.db.models import get_model diff --git a/profiles/views.py b/profiles/views.py index c9552ab..b5b7143 100644 --- a/profiles/views.py +++ b/profiles/views.py @@ -14,31 +14,31 @@ from django.template import RequestContext from django.views.generic.list import ListView from django import forms -from core.models import Person +from troggle.core.models import Person from profiles import utils from django.conf import settings class SelectPersonForm(forms.Form): #This and the select_profile view - person = forms.ModelChoiceField(queryset=Person.objects.all()) + person = forms.ModelChoiceField(queryset=Person.objects.all()) def select_profile(request): if request.method == 'POST': - form = SelectPersonForm(request.POST) - if form.is_valid(): - profile_obj=form.cleaned_data['person'] - profile_obj.user=request.user - profile_obj.save() - return HttpResponseRedirect(profile_obj.get_absolute_url()) + form = SelectPersonForm(request.POST) + if form.is_valid(): + profile_obj=form.cleaned_data['person'] + profile_obj.user=request.user + profile_obj.save() + return HttpResponseRedirect(profile_obj.get_absolute_url()) else: form = SelectPersonForm() - context = RequestContext(request) + context = RequestContext(request) return render_to_response('profiles/select_profile.html', { 'form':form,}, - context_instance=context - ) + context_instance=context + ) def create_profile(request, form_class=None, success_url=None, diff --git a/settings.py b/settings.py index 2910ac1..1159f4e 100644 --- a/settings.py +++ b/settings.py @@ -2,11 +2,16 @@ from localsettings import * #inital localsettings call so that urljoins work import os import urlparse import django -# Django settings for troggle project. +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) + +# Django settings for troggle project. DEBUG = True TEMPLATE_DEBUG = DEBUG +ALLOWED_HOSTS = [] + ADMINS = ( # ('Your Name', 'your_email@domain.com'), ) @@ -30,6 +35,7 @@ SITE_ID = 1 # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = True +USE_L10N = True FIX_PERMISSIONS = [] NOTABLECAVESHREFS = [ "161", "204", "258", "76", "107", "264" ] @@ -69,23 +75,6 @@ TEMPLATE_CONTEXT_PROCESSORS = ( authmodule, "core.context.troggle_context", ) LOGIN_REDIRECT_URL = '/' -MIDDLEWARE_CLASSES = ( - 'django.middleware.common.CommonMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.redirects.middleware.RedirectFallbackMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'troggle.middleware.SmartAppendSlashMiddleware' -) - -ROOT_URLCONF = 'troggle.urls' - -ACCOUNT_ACTIVATION_DAYS=3 - -AUTH_PROFILE_MODULE = 'core.person' - INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', @@ -94,9 +83,11 @@ INSTALLED_APPS = ( 'django.contrib.sites', 'django.contrib.redirects', 'django.contrib.messages', + 'django.contrib.staticfiles', #'troggle.photologue', #'troggle.reversion', #'django_evolution', + 'tinymce', 'registration', 'troggle.profiles', 'troggle.core', @@ -104,9 +95,32 @@ INSTALLED_APPS = ( 'troggle.imagekit', ) +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.redirects.middleware.RedirectFallbackMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'troggle.middleware.SmartAppendSlashMiddleware' +) + +ROOT_URLCONF = 'troggle.urls' + +WSGI_APPLICATION = 'troggle.wsgi.application' + +ACCOUNT_ACTIVATION_DAYS=3 + +AUTH_PROFILE_MODULE = 'core.person' + QM_PATTERN="\[\[\s*[Qq][Mm]:([ABC]?)(\d{4})-(\d*)-(\d*)\]\]" TINYMCE_JS_URL = 'http://debug.example.org/tiny_mce/tiny_mce_src.js' + +#TINYMCE_JS_URL = os.path.join(MEDIA_URL, "tinybibble_mce.js") + TINYMCE_DEFAULT_CONFIG = { 'plugins': "table,spellchecker,paste,searchreplace", 'theme': "advanced", diff --git a/utils.py b/utils.py index c26f1d9..a91a1aa 100644 --- a/utils.py +++ b/utils.py @@ -1,14 +1,14 @@ from django.conf import settings import random, re, logging -from core.models import CaveDescription +from troggle.core.models import CaveDescription def weighted_choice(lst): - n = random.uniform(0,1) - for item, weight in lst: - if n < weight: - break - n = n - weight - return item + n = random.uniform(0,1) + for item, weight in lst: + if n < weight: + break + n = n - weight + return item def randomLogbookSentence(): from troggle.core.models import LogbookEntry