+++ /dev/null
-# set X_BASE_DIRECTORY to the the name of the directory this file is in!
-X_BASE_DIRECTORY = '/home/graham/projects/evergreen/conifer/'
# make sure you have a local_settings.py file! Copy from
# local_settings.py.in and customize that file.
-from local_settings import X_BASE_DIRECTORY
+import os
+
+BASE_DIRECTORY = os.path.abspath(os.getcwd())
+HERE = lambda s: os.path.join(BASE_DIRECTORY, s)
DEBUG = True
TEMPLATE_DEBUG = DEBUG
MANAGERS = ADMINS
DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-DATABASE_NAME = X_BASE_DIRECTORY +'syrup.sqlite' # Or path to database file if using sqlite3.
+DATABASE_NAME = HERE('syrup.sqlite') # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
-MEDIA_ROOT = X_BASE_DIRECTORY + 'static'
+MEDIA_ROOT = HERE('static')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
/* actions (e.g. "edit user" link) */
.action a { font-weight: bold; }
-#tabbar { margin: 18 0; padding: 0; }
+#tabbar { margin: 18 0; padding: 0; width: 700; }
#tabbar li { display: inline; }
#tabbar li a { padding: 18 18 4 18; background-color: #ddf; color: black; text-decoration: none; }
#tabbar li a:hover { background-color: #fc8; }
# value.__unicode__ = unicode_fn(firstcharfield)
# admin.site.register(value)
-for m in [Member, Course, Term, UserProfile]:
+for m in [Member, Course, Term, UserProfile, News]:
admin.site.register(m)
from django.db import models as m
from django.contrib.auth.models import User
+from datetime import datetime
#----------------------------------------------------------------------
# USERS
def __unicode__(self):
return '%s--%s--%s' % (self.user, self.role, self.course)
+
+#------------------------------------------------------------
+
+class News(m.Model):
+ subject = m.CharField(max_length=200)
+ body = m.TextField()
+ published = m.DateTimeField(default=datetime.now, blank=True, null=True)
+ encoding = m.CharField(max_length=10,
+ choices = (('plain', 'plain'),
+ ('html', 'html'),
+ ('markdown', 'markdown')),
+ default = 'html')
from django.conf.urls.defaults import *
urlpatterns = patterns('conifer.syrup.views',
- (r'^$', 'index'),
- (r'^course/(?P<course_id>\d+)/$', 'course_index'),
+ (r'^$', 'welcome'),
+ (r'^course/$', 'my_courses'),
+ (r'^course/(?P<course_id>\d+)/$', 'course_detail'),
)
import conifer.genshi_support as g
from conifer.syrup import models
-@login_required
-def index(request):
- return g.render('index.xhtml')
-
-@login_required
-def course_index(request, course_id):
- course = get_object_or_404(models.Course, pk=course_id)
- return g.render('course.xhtml', course=course)
+#------------------------------------------------------------
def auth_handler(request, path):
if path == 'login/':
if request.method == 'GET':
- return g.render('login.xhtml')
+ return g.render('auth/login.xhtml')
else:
userid, password = request.POST['userid'], request.POST['password']
user = authenticate(username=userid, password=password)
return HttpResponse('Logged out. Thanks for coming!')
else:
return HttpResponse('auth_handler: ' + path)
+
+#------------------------------------------------------------
+
+def welcome(request):
+ return g.render('welcome.xhtml')
+
+
+@login_required
+def my_courses(request):
+ return g.render('my_courses.xhtml')
+
+@login_required
+def course_detail(request, course_id):
+ course = get_object_or_404(models.Course, pk=course_id)
+ return g.render('course_detail.xhtml', course=course)
--- /dev/null
+<?python
+title = 'Syrup E-Reserves: Please log in'
+?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:py="http://genshi.edgewall.org/">
+<xi:include href="../master.xhtml"/>
+<head>
+ <title>${title}</title>
+ <script>
+ $(function() {$('#userid').focus();});
+ </script>
+</head>
+<body>
+ <h1>Please log in.</h1>
+ <form action="." method="post">
+ <input type="hidden" name="next" value="${request.GET['next']}"/>
+ <table>
+ <tr>
+ <th>User ID:</th>
+ <td><input type="text" name="userid" id="userid"/></td>
+ </tr>
+ <tr>
+ <th>Password:</th>
+ <td><input type="password" name="password"/></td>
+ </tr>
+ </table>
+ <p><input type="submit" value="Log in"/></p>
+ </form>
+</body>
+</html>
+++ /dev/null
-<?python
-title = '%s: %s (%s)' % (course.code, course.title, course.term)
-?>
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:xi="http://www.w3.org/2001/XInclude"
- xmlns:py="http://genshi.edgewall.org/">
-<xi:include href="master.xhtml"/>
-<head>
- <title>${title}</title>
-</head>
-<body>
- <h1>${title}</h1>
-</body>
-</html>
--- /dev/null
+<?python
+title = '%s: %s (%s)' % (course.code, course.title, course.term)
+?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:py="http://genshi.edgewall.org/">
+<xi:include href="master.xhtml"/>
+<head>
+ <title>${title}</title>
+</head>
+<body>
+ <h1>${title}</h1>
+</body>
+</html>
+++ /dev/null
-<?python
-title = 'Welcome to Syrup E-Reserves!'
-?>
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:xi="http://www.w3.org/2001/XInclude"
- xmlns:py="http://genshi.edgewall.org/">
-<xi:include href="master.xhtml"/>
-<head>
- <title>${title}</title>
-</head>
-<body>
- <h2>My Courses</h2>
- <?python
- if user.is_authenticated():
- my_courses = user.courses()
- else:
- my_courses = []
- ?>
- <p py:if="not my_courses">You are not part of any courses at this time.</p>
- <p py:for="course in my_courses" style="font-size: large;">
- <a href="course/${course.id}/">${course.term}: ${course.code}: ${course.title}</a>
- </p>
- <div class="gap"/>
-</body>
-</html>
+++ /dev/null
-<?python
-title = 'Syrup E-Reserves: Please log in'
-?>
-<html xmlns="http://www.w3.org/1999/xhtml"
- xmlns:xi="http://www.w3.org/2001/XInclude"
- xmlns:py="http://genshi.edgewall.org/">
-<xi:include href="master.xhtml"/>
-<head>
- <title>${title}</title>
- <script>
- $(function() {$('#userid').focus();});
- </script>
-</head>
-<body>
- <h1>Please log in.</h1>
- <form action="." method="post">
- <input type="hidden" name="next" value="${request.GET['next']}"/>
- <table>
- <tr>
- <th>User ID:</th>
- <td><input type="text" name="userid" id="userid"/></td>
- </tr>
- <tr>
- <th>Password:</th>
- <td><input type="password" name="password"/></td>
- </tr>
- </table>
- <p><input type="submit" value="Log in"/></p>
- </form>
-</body>
-</html>
<img src="/static/institution-logo.png" style="height: 50;"/>
</div>
<div id="header" py:if="user.is_authenticated()">
- <strong style="padding-right: 18;">Welcome, ${user.first_name}!</strong>
+ <strong style="padding-right: 18;">Welcome, ${user.first_name or user.username}!</strong>
<a href="/accounts/logout">Log Out</a>
• <a href="/user/prefs">Preferences</a>
• <a href="/admin/">Admin UI</a>
--- /dev/null
+<?python
+title = 'Welcome to Syrup E-Reserves!'
+?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:py="http://genshi.edgewall.org/">
+<xi:include href="master.xhtml"/>
+<head>
+ <title>${title}</title>
+</head>
+<body>
+ <h2>My Courses</h2>
+ <?python
+ if user.is_authenticated():
+ my_courses = user.courses()
+ else:
+ my_courses = []
+ ?>
+ <p py:if="not my_courses">You are not part of any courses at this time.</p>
+ <p py:for="course in my_courses" style="font-size: large;">
+ <a href="${course.id}/">${course.term}: ${course.code}: ${course.title}</a>
+ </p>
+ <div class="gap"/>
+</body>
+</html>
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip="">
<ul id="tabbar">
- <li class="active"><a href="/syrup">My Courses</a></li>
+ <li><a href="/syrup/">Home</a></li>
+ <li class="active"><a href="/syrup/course/">My Courses</a></li>
<li><a href="/syrup">Add a Reserve</a></li>
<li><a href="/syrup">Manage Users</a></li>
<li><a href="/syrup">Preferences</a></li>