diff options
Diffstat (limited to 'src/meetingtools')
-rw-r--r-- | src/meetingtools/apps/auth/views.py | 9 | ||||
-rw-r--r-- | src/meetingtools/apps/room/feeds.py | 3 | ||||
-rw-r--r-- | src/meetingtools/apps/room/models.py | 10 | ||||
-rw-r--r-- | src/meetingtools/apps/room/tasks.py | 7 | ||||
-rw-r--r-- | src/meetingtools/apps/room/views.py | 23 | ||||
-rw-r--r-- | src/meetingtools/extensions/templatetags/prefix.py | 18 | ||||
-rw-r--r-- | src/meetingtools/extensions/templatetags/roomurl.py | 3 | ||||
-rw-r--r-- | src/meetingtools/multiresponse.py | 11 | ||||
-rw-r--r-- | src/meetingtools/settings.py | 19 | ||||
-rw-r--r-- | src/meetingtools/urls.py | 2 | ||||
-rw-r--r-- | src/meetingtools/utils.py | 5 |
11 files changed, 48 insertions, 62 deletions
diff --git a/src/meetingtools/apps/auth/views.py b/src/meetingtools/apps/auth/views.py index e294b0c..ee23df3 100644 --- a/src/meetingtools/apps/auth/views.py +++ b/src/meetingtools/apps/auth/views.py @@ -13,9 +13,9 @@ from meetingtools.multiresponse import redirect_to, make_response_dict from meetingtools.ac import ac_api_client from django.shortcuts import render_to_response from django.contrib import auth -from django_co_connector.models import co_import_from_request, add_member,\ - remove_member +from django_co_connector.models import co_import_from_request, add_member,remove_member from meetingtools.apps.cluster.models import acc_for_user +from django.conf import settings def meta(request,attr): v = request.META.get(attr) @@ -123,6 +123,8 @@ def accounts_login_federated(request): next = request.session.get("after_login_redirect", None) if not next and request.GET.has_key('next'): next = request.GET['next'] + else: + next = settings.DEFAULT_URL acc = acc_for_user(request.user) with ac_api_client(request) as api: @@ -163,4 +165,5 @@ def accounts_login_federated(request): return redirect_to(next) else: pass - return redirect_to(next) + + return redirect_to(settings.LOGIN_URL) diff --git a/src/meetingtools/apps/room/feeds.py b/src/meetingtools/apps/room/feeds.py index 3dff05e..a72caaa 100644 --- a/src/meetingtools/apps/room/feeds.py +++ b/src/meetingtools/apps/room/feeds.py @@ -7,7 +7,6 @@ Created on May 13, 2011 from django.contrib.syndication.views import Feed from meetingtools.apps.room.models import Room from tagging.models import TaggedItem -from meetingtools.settings import BASE_URL from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed from meetingtools.apps.room.views import room_recordings from django.shortcuts import get_object_or_404 @@ -25,7 +24,7 @@ class TagsWrapper(object): return self.title() def link(self,ext): - return "%s/room/+%s.%s" % (BASE_URL,"+".join(self.tags),ext) + return "/room/+%s.%s" % ("+".join(self.tags),ext) class MeetingToolsFeed(Feed): diff --git a/src/meetingtools/apps/room/models.py b/src/meetingtools/apps/room/models.py index 249b1bf..2177b24 100644 --- a/src/meetingtools/apps/room/models.py +++ b/src/meetingtools/apps/room/models.py @@ -12,7 +12,7 @@ from django.contrib.auth.models import User from meetingtools.apps.cluster.models import ACCluster import time import tagging -from meetingtools.settings import BASE_URL, LOCK_DIR +from meetingtools.settings import LOCK_DIR from django.db.models.signals import post_save from tagging.models import Tag import os @@ -102,16 +102,16 @@ class Room(models.Model): return int(time.mktime(self.lastupdated.timetuple())) def go_url(self): - return "%s/go/%s" % (BASE_URL,self.urlpath) + return "/go/%s" % self.urlpath def go_url_internal(self): - return "%s/go/%d" % (BASE_URL,self.id) + return "/go/%d" % self.id def permalink(self): - return "%s/room/%d" % (BASE_URL,self.id) + return "/room/%d" % self.id def recordings_url(self): - return "%s/room/%d/recordings" % (BASE_URL,self.id) + return "/room/%d/recordings" % self.id def nusers(self): if self.user_count == None: diff --git a/src/meetingtools/apps/room/tasks.py b/src/meetingtools/apps/room/tasks.py index feb0ec5..ce9f275 100644 --- a/src/meetingtools/apps/room/tasks.py +++ b/src/meetingtools/apps/room/tasks.py @@ -17,9 +17,8 @@ from datetime import datetime,timedelta from lxml import etree from django.db.models import Q from django.contrib.humanize.templatetags import humanize -from meetingtools.apps.userprofile.models import profile +from django.conf import settings from django.core.mail import send_mail -from meetingtools.settings import NOREPLY, BASE_URL def _owner_username(api,sco): logging.debug(sco) @@ -231,7 +230,7 @@ def send_message(user,subject,message): try: p = user.get_profile() if p and p.email: - send_mail(subject,message,NOREPLY,[p.email]) + send_mail(subject,message,settings.NOREPLY,[p.email]) else: logging.info("User %s has no email address - email not sent" % user.username) except ObjectDoesNotExist: @@ -248,4 +247,4 @@ def clean_old_rooms(): with ac_api_client(acc) as api: for room in Room.objects.filter(lastvisited__lt=then): logging.debug("room %s was last used %s" % (room.name,humanize.naturalday(room.lastvisited))) - send_message.apply_async([room.creator,"You have an unused meetingroom at %s" % BASE_URL,"Do you still need %s (%s)?" % (room.name,room.permalink())])
\ No newline at end of file + send_message.apply_async([room.creator,"You have an unused meetingroom at %s" % acc.name ,"Do you still need %s (%s)?" % (room.name,room.permalink())])
\ No newline at end of file diff --git a/src/meetingtools/apps/room/views.py b/src/meetingtools/apps/room/views.py index e612141..c46ab6e 100644 --- a/src/meetingtools/apps/room/views.py +++ b/src/meetingtools/apps/room/views.py @@ -4,8 +4,7 @@ Created on Jan 31, 2011 @author: leifj ''' from meetingtools.apps.room.models import Room, ACCluster -from meetingtools.multiresponse import respond_to, redirect_to, json_response,\ - timeAsrfc822 +from meetingtools.multiresponse import respond_to, redirect_to, json_response from meetingtools.apps.room.forms import DeleteRoomForm,\ CreateRoomForm, ModifyRoomForm, TagRoomForm from django.shortcuts import get_object_or_404 @@ -15,10 +14,9 @@ from meetingtools.apps import room from django.contrib.auth.decorators import login_required import logging from pprint import pformat -from meetingtools.utils import session +from meetingtools.utils import session, base_url import time -from meetingtools.settings import GRACE, BASE_URL, DEFAULT_TEMPLATE_SCO,\ - IMPORT_TTL +from django.conf import settings from django.utils.datetime_safe import datetime from django.http import HttpResponseRedirect from django.core.exceptions import ObjectDoesNotExist @@ -27,7 +25,7 @@ from meetingtools.ac.api import ACPClient from tagging.models import Tag, TaggedItem import random, string from django.utils.feedgenerator import rfc3339_date -from django.views.decorators.cache import cache_control, never_cache +from django.views.decorators.cache import never_cache from meetingtools.apps.cluster.models import acc_for_user from django.contrib.auth.models import User import iso8601 @@ -111,13 +109,14 @@ def view(request,id): {'user':request.user, 'rooms':[room], 'title': room.name, + 'baseurl': base_url(request), 'active': True, }) def _init_update_form(request,form,acc,my_meetings_sco_id): if form.fields.has_key('urlpath'): - url = BASE_URL - form.fields['urlpath'].widget.prefix = url.rstrip('/')+"/" + url = base_url(request) + form.fields['urlpath'].widget.prefix = url if form.fields.has_key('source_sco_id'): form.fields['source_sco_id'].widget.choices = [('','-- select template --')]+[r for r in _user_templates(request,acc,my_meetings_sco_id)] @@ -234,7 +233,7 @@ def _import_room(request,acc,r): modified = False room = None - if room and (abs(room.lastupdate() - time.time()) < IMPORT_TTL): + if room and (abs(room.lastupdate() - time.time()) < settings.IMPORT_TTL): return room if r.has_key('urlpath'): @@ -406,7 +405,7 @@ def _goto(request,room,clean=True,promote=False): if clean: # don't clean the room unless you get a good status code from the call to the usermanager api above if room.self_cleaning and room.user_count == 0: - if (room.user_count == 0) and (abs(lastvisit - now) > GRACE): + if (room.user_count == 0) and (abs(lastvisit - now) > settings.GRACE): room.lock("Locked for cleaning") try: room = _clean(request,room) @@ -465,7 +464,7 @@ def list_by_tag(request,tn): 'description':title , 'edit':False, 'active':len(rooms) == 1, - 'baseurl': BASE_URL, + 'baseurl': base_url(request), 'tagstring': tn, 'rooms':rooms}) @@ -483,7 +482,7 @@ def list_and_import_by_tag(request,tn): 'description':title , 'edit':False, 'active':len(rooms) == 1, - 'baseurl': BASE_URL, + 'baseurl': base_url(request), 'tagstring': tn, 'rooms':rooms}) diff --git a/src/meetingtools/extensions/templatetags/prefix.py b/src/meetingtools/extensions/templatetags/prefix.py deleted file mode 100644 index 32b8656..0000000 --- a/src/meetingtools/extensions/templatetags/prefix.py +++ /dev/null @@ -1,18 +0,0 @@ -''' -Created on Feb 9, 2011 - -@author: leifj -''' - -from django import template -from meetingtools.settings import PREFIX_URL, BASE_URL -register = template.Library() - -@register.simple_tag -def baseurl(): - return BASE_URL - - -@register.simple_tag -def prefix(): - return PREFIX_URL
\ No newline at end of file diff --git a/src/meetingtools/extensions/templatetags/roomurl.py b/src/meetingtools/extensions/templatetags/roomurl.py index 37f1e80..e5abe57 100644 --- a/src/meetingtools/extensions/templatetags/roomurl.py +++ b/src/meetingtools/extensions/templatetags/roomurl.py @@ -1,5 +1,4 @@ from django import template -from meetingtools.settings import BASE_URL register = template.Library() @@ -14,7 +13,7 @@ def roomurl(room): if room.urlpath: path = room.urlpath - return "%s/go/%s" % (BASE_URL,path) + return "/go/%s" % path roomurl.is_safe = True register.filter(roomurl)
\ No newline at end of file diff --git a/src/meetingtools/multiresponse.py b/src/meetingtools/multiresponse.py index 077f446..f599323 100644 --- a/src/meetingtools/multiresponse.py +++ b/src/meetingtools/multiresponse.py @@ -1,3 +1,4 @@ +from meetingtools import context_processors import meetingtools.mimeparse as mimeparse import re import rfc822 @@ -6,8 +7,7 @@ from django.shortcuts import render_to_response from django.http import HttpResponse, HttpResponseForbidden,\ HttpResponseRedirect from django.utils import simplejson -from django.template import loader -from meetingtools.settings import PREFIX_URL +from django.template import loader, RequestContext default_suffix_mapping = {"\.htm(l?)$": "text/html", "\.json$": "application/json", @@ -30,9 +30,10 @@ def make_response_dict(request,d={}): if request.user.is_authenticated(): d['user'] = request.user - d['prefix'] = PREFIX_URL - return d + ctx = RequestContext(request,d,[context_processors.theme]) + print repr(ctx['theme']) + return ctx def json_response(data,request=None): response_data = None @@ -73,4 +74,4 @@ def respond_to(request, template_mapping, dict={}, suffix_mapping=default_suffix return response def redirect_to(path): - return HttpResponseRedirect("%s%s" % (PREFIX_URL,path))
\ No newline at end of file + return HttpResponseRedirect(path)
\ No newline at end of file diff --git a/src/meetingtools/settings.py b/src/meetingtools/settings.py index 1e54f1f..8e72dca 100644 --- a/src/meetingtools/settings.py +++ b/src/meetingtools/settings.py @@ -1,4 +1,5 @@ # Django settings for meetingtools project. +from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS import meetingtools.site_logging import os @@ -13,8 +14,6 @@ ADMINS = ( SRC_DIR = os.path.dirname(os.path.abspath(__file__)) BASE_DIR = os.path.abspath(os.path.join(SRC_DIR, '..')) -PREFIX_URL = "" -BASE_URL = "http://localhost:8000%s" % PREFIX_URL MANAGERS = ADMINS LOCK_DIR = "/var/lock" @@ -58,15 +57,12 @@ USE_I18N = True # calendars according to the current locale USE_L10N = True -MEDIA_ROOT = "%s/site-media" % BASE_DIR -ADMIN_MEDIA_ROOT = "%s/admin-media" % BASE_DIR -MEDIA_URL = '%s/site-media/' % PREFIX_URL -ADMIN_MEDIA_PREFIX = '%s/admin-media/' % PREFIX_URL STATIC_ROOT = "%s/static" % BASE_DIR -STATIC_URL = "%s/static/" % PREFIX_URL +STATIC_URL = "/static/" -LOGIN_URL = "%s/accounts/login" % PREFIX_URL -LOGOUT_URL = "%s/accounts/logout" % PREFIX_URL +LOGIN_URL = "/accounts/login" +LOGOUT_URL = "/accounts/logout" +DEFAULT_URL = "/" # Make this unique, and don't share it with anybody. SECRET_KEY = 'tz78l!c=cl2=jic5$2#(bq)7-4s1ivtm*a+q0w1yi0$)hrmc7l' @@ -83,6 +79,11 @@ CACHES = { } } +THEMES = { + '__default__': {'base': "%s/themes/default" % STATIC_URL }, + 'meetingtools.nordu.net': {'base': "%s/themes/meetingtools.nordu.net" % STATIC_URL} +} + # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', diff --git a/src/meetingtools/urls.py b/src/meetingtools/urls.py index 24f58e7..1c42d08 100644 --- a/src/meetingtools/urls.py +++ b/src/meetingtools/urls.py @@ -2,7 +2,7 @@ from django.conf.urls.defaults import patterns,include # Uncomment the next two lines to enable the admin: from django.contrib import admin -from meetingtools.settings import ADMIN_MEDIA_ROOT, MEDIA_ROOT, STATIC_ROOT +from meetingtools.settings import STATIC_ROOT from meetingtools.multiresponse import redirect_to from meetingtools.apps.room.feeds import RoomAtomTagFeed,RoomRSSTagField,\ AtomRecordingFeed, RSSRecordingField diff --git a/src/meetingtools/utils.py b/src/meetingtools/utils.py index cadfb36..eee0d80 100644 --- a/src/meetingtools/utils.py +++ b/src/meetingtools/utils.py @@ -14,4 +14,7 @@ def session(request,key=None,val=None): request.session[key] = None return request.session[key] else: - return request.session
\ No newline at end of file + return request.session + +def base_url(request): + return "%s://%s/" % ({True: 'https',False:'http'}[request.is_secure()],request.get_host())
\ No newline at end of file |