AUTHENTICATION_BACKENDS.append(
'conifer.custom.auth_evergreen.EvergreenAuthBackend')
-# stuff that I really ought not check into svn...
-#SIP_HOST = ('hostname', 9999)
-#SIP_CREDENTIALS = ('userid', 'password', 'location')
-
try:
# Graham has this right now; it's not official Syrup. Nothing to see here.
from private_local_settings import SIP_HOST, SIP_CREDENTIALS
except:
+ # stuff that I really ought not check into svn...
+ #SIP_HOST = ('hostname', 9999)
+ #SIP_CREDENTIALS = ('userid', 'password', 'location')
pass
#CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
import re
import random
from django.utils import simplejson
+from conifer.middleware import genshi_locals
def highlight(text, phrase,
highlighter='<strong class="highlight">\\1</strong>'):
return mbr.role in (u'INSTR', u'PROXY')
def course_url(self, suffix=''):
- return '/syrup/course/%d/%s' % (self.id, suffix)
+ req = genshi_locals.get_request()
+ prefix = req.META['SCRIPT_NAME']
+ return '%s/course/%d/%s' % (prefix, self.id, suffix)
def generate_new_passkey(self):
# todo: have a pluggable passkey algorithm.
return self.item_type in ('ELEC', 'URL', 'PHYS')
def item_url(self, suffix='', force_local_url=False):
+ req = genshi_locals.get_request()
+ prefix = req.META['SCRIPT_NAME']
if self.item_type == 'ELEC' and suffix == '':
- return '/syrup/course/%d/item/%d/dl/%s' % (
- self.course_id, self.id,
+ return '%s/course/%d/item/%d/dl/%s' % (
+ prefix, self.course_id, self.id,
self.fileobj.name.split('/')[-1])
if self.item_type == 'URL' and suffix == '' and not force_local_url:
return self.url
- else:
- return '/syrup/course/%d/item/%d/%s' % (
- self.course_id, self.id, suffix)
+ else:
+ return '%s/course/%d/item/%d/%s' % (
+ prefix, self.course_id, self.id, suffix)
def parent_url(self, suffix=''):
if self.parent_heading:
from conifer.custom import lib_integration
from conifer.libsystems.z3950.marcxml import marcxml_to_dictionary, marcxml_dictionary_to_dc
from fuzzy_match import rank_pending_items
+from django.core.urlresolvers import reverse
#-----------------------------------------------------------------------------
# Z39.50 Support
# Authentication
def auth_handler(request, path):
+ default_url = reverse(welcome) #request.META['SCRIPT_NAME'] + '/'
if path == 'login/':
if request.method == 'GET':
- next=request.GET.get('next', '/syrup/')
+ next=request.GET.get('next', default_url)
if request.user.is_authenticated():
return HttpResponseRedirect(next)
else:
except models.UserProfile.DoesNotExist:
profile = models.UserProfile.objects.create(user=user)
profile.save()
- return HttpResponseRedirect(request.POST.get('next', '/syrup/'))
+ return HttpResponseRedirect(request.POST.get('next', default_url))
elif path == 'logout':
logout(request)
- return HttpResponseRedirect('/syrup/')
+ return HttpResponseRedirect(default_url)
else:
return HttpResponse('auth_handler: ' + path)
def _access_denied(request, message):
if request.user.is_anonymous():
# then take them to login screen....
- dest = '/syrup/accounts/login/?next=' + request.environ['PATH_INFO']
+ dest = request.META['SCRIPT_NAME'] + '/accounts/login/?next=' + request.environ['PATH_INFO']
return HttpResponseRedirect(dest)
else:
return simple_message(_('Access denied.'), message,
course = get_object_or_404(models.Course, pk=course_id)
if request.POST.get('confirm_delete'):
course.delete()
- return HttpResponseRedirect('/syrup/course/')
+ return HttpResponseRedirect(reverse('my_courses'))
else:
return HttpResponseRedirect('../')
app_name = _('Syrup E-Reserve System')
search = _('search...')
import os
+rooted = lambda url: request.META['SCRIPT_NAME'] + url
?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
<head py:attrs="select('@*')"
py:with="t=list(select('title/text()'))">
<title>${app_name}<py:if test="t">: ${t}</py:if></title>
- <link rel="stylesheet" type="text/css" href="/syrup/static/main.css"/>
- <script type="text/javascript" src="/syrup/static/jquery/js/jquery-1.3.2.min.js"/>
- <script type="text/javascript" src="/syrup/static/jquery/js/jquery-ui-1.7.1.custom.min.js"/>
- <script type="text/javascript" src="/syrup/static/jquery/js/jquery.tablesorter.min.js"/>
+ <link rel="stylesheet" type="text/css" href="${rooted('/static/main.css')}"/>
+ <script type="text/javascript" src="${rooted('/static/jquery/js/jquery-1.3.2.min.js')}"/>
+ <script type="text/javascript" src="${rooted('/static/jquery/js/jquery-ui-1.7.1.custom.min.js')}"/>
+ <script type="text/javascript" src="${rooted('/static/jquery/js/jquery.tablesorter.min.js')}"/>
${select('*[local-name()!="title"]')}
</head>
</py:match>
${os.getpid()}
${app_name}
</div>
- <img src="/syrup/static/institution-logo.png" style="height: 50;"/>
+ <img src="${rooted('/static/institution-logo.png')}" style="height: 50;"/>
</div>
<!--
<div id="header" py:if="user.is_authenticated()">
-->
<div id="header">
<div id="search">
- <form method="get" action="/syrup/search"
+ <form method="get" action="${rooted('/search')}"
onsubmit="if(q.value.replace(/^\s*/, '').replace(/\s*$/, '') =='') return false;"
>
<input id="q" name="q" maxlength="100" size="25" type="text"
</div>
<span py:if="user.is_authenticated()">
<strong style="padding-right: 18;">Welcome, ${user.first_name or user.username}!</strong>
- <a href="/syrup/accounts/logout">Log Out</a>
- • <a href="/syrup/prefs/">Preferences</a>
+ <a href="${rooted('/accounts/logout')}">Log Out</a>
+ • <a href="${rooted('/prefs/')}">Preferences</a>
</span>
<span py:if="not user.is_authenticated()">
<strong style="padding-right: 18;">Welcome!</strong>
- <a class="loginbutton" href="/syrup/accounts/login/">Log In</a>
- • <a href="/syrup/prefs/">Preferences</a>
+ <a class="loginbutton" href="${rooted('/accounts/login/')}">Log In</a>
+ • <a href="${rooted('/prefs/')}">Preferences</a>
</span>
</div>
<xi:include py:if="user.is_authenticated()" href="tabbar.xhtml"/>
</div>
<div id="footer">
<div>
- <!--
- !We may eventually have a tab bar for non authenticated users,
- but we definitely need a start over option for now. There is
- probably a more elegant way of detecting whether we are on
- the front page but this works for the short term
- -->
- <span py:if="not user.is_authenticated() and not request.META.PATH_INFO == '/syrup/'">
- <a href="/syrup">Start Over</a> -
- </span>
Syrup is a subproject of <a href="http://conifer.mcmaster.ca/">Project Conifer</a> © 2009
</div>
</div>
use one for now
-->
<ul id="tabbar">
- <li><a href="/syrup/">Home</a></li>
- <li><a href="/syrup/browse/">Browse</a></li>
- <li class="active"><a href="/syrup/course/">My Courses</a></li>
+ <li><a href="${rooted('/')}">Home</a></li>
+ <li><a href="${rooted('/browse/')}">Browse</a></li>
+ <li class="active"><a href="${rooted('/course/')}">My Courses</a></li>
<div py:strip="True"
py:if="request.user.is_staff">
- <li><a href="/syrup/admin/">Admin Options</a></li>
- <li><a href="/syrup/phys/">Physical Items</a></li>
+ <li><a href="${rooted('/admin/')}">Admin Options</a></li>
+ <li><a href="${rooted('/phys/')}">Physical Items</a></li>
</div>
</ul>
</html>
# Uncomment the admin/doc line below and add 'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
- (r'^syrup/djadmin/doc/', include('django.contrib.admindocs.urls')),
+ (r'^djadmin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
- (r'^syrup/djadmin/(.*)', admin.site.root),
- (r'^syrup/djmedia/(.*)', 'django.views.static.serve',
+ (r'^djadmin/(.*)', admin.site.root),
+ (r'^djmedia/(.*)', 'django.views.static.serve',
{'document_root': ADMIN_MEDIA_ROOT}),
- (r'^syrup/static/(?P<path>.*)$', 'django.views.static.serve',
+ (r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
- (r'^syrup/accounts/(?P<path>.*)$', 'conifer.syrup.views.auth_handler'),
+ (r'^accounts/(?P<path>.*)$', 'conifer.syrup.views.auth_handler'),
# (r'^syrup/setlang', 'conifer.syrup.views.setlang'),
- (r'^syrup/i18n/', include('django.conf.urls.i18n')),
- (r'^syrup/', include('conifer.syrup.urls')),
+ (r'^i18n/', include('django.conf.urls.i18n')),
+ (r'', include('conifer.syrup.urls')),
)