template re-org; removed need for local_settings.py; added News to model.
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Tue, 18 Nov 2008 20:58:30 +0000 (20:58 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Tue, 18 Nov 2008 20:58:30 +0000 (20:58 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@22 6d9bc8c9-1ec2-4278-b937-99fde70a366f

15 files changed:
conifer/local_settings.py.in [deleted file]
conifer/settings.py
conifer/static/main.css
conifer/syrup/admin.py
conifer/syrup/models.py
conifer/syrup/urls.py
conifer/syrup/views.py
conifer/templates/auth/login.xhtml [new file with mode: 0644]
conifer/templates/course.xhtml [deleted file]
conifer/templates/course_detail.xhtml [new file with mode: 0644]
conifer/templates/index.xhtml [deleted file]
conifer/templates/login.xhtml [deleted file]
conifer/templates/master.xhtml
conifer/templates/my_courses.xhtml [new file with mode: 0644]
conifer/templates/tabbar.xhtml

diff --git a/conifer/local_settings.py.in b/conifer/local_settings.py.in
deleted file mode 100644 (file)
index 7d7fd74..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-# set X_BASE_DIRECTORY to the the name of the directory this file is in!
-X_BASE_DIRECTORY = '/home/graham/projects/evergreen/conifer/'
index ee99c96..76461a1 100644 (file)
@@ -3,7 +3,10 @@
 # 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
@@ -15,7 +18,7 @@ ADMINS = (
 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.
@@ -40,7 +43,7 @@ USE_I18N = True
 
 # 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).
index a9c7238..c26a6aa 100644 (file)
@@ -42,7 +42,7 @@ a:hover {  text-decoration: underline;  }
 /* 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; }
index 1b279c8..c24d19f 100644 (file)
@@ -22,5 +22,5 @@ from conifer.syrup.models import *
 #             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)
index 0a97833..3cdaaff 100644 (file)
@@ -1,5 +1,6 @@
 from django.db import models as m
 from django.contrib.auth.models import User
+from datetime import datetime
 
 #----------------------------------------------------------------------
 # USERS
@@ -70,3 +71,15 @@ class Member(m.Model):
 
     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')
index d9c840f..0e59006 100644 (file)
@@ -1,6 +1,7 @@
 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'),
 )
index ad04cd4..12d89f8 100644 (file)
@@ -5,19 +5,12 @@ from django.contrib.auth import authenticate, login, logout
 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)
@@ -33,3 +26,18 @@ def auth_handler(request, path):
         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)
diff --git a/conifer/templates/auth/login.xhtml b/conifer/templates/auth/login.xhtml
new file mode 100644 (file)
index 0000000..74c7538
--- /dev/null
@@ -0,0 +1,31 @@
+<?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>
diff --git a/conifer/templates/course.xhtml b/conifer/templates/course.xhtml
deleted file mode 100644 (file)
index f76a969..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<?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>
diff --git a/conifer/templates/course_detail.xhtml b/conifer/templates/course_detail.xhtml
new file mode 100644 (file)
index 0000000..f76a969
--- /dev/null
@@ -0,0 +1,14 @@
+<?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>
diff --git a/conifer/templates/index.xhtml b/conifer/templates/index.xhtml
deleted file mode 100644 (file)
index 6733c19..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?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>
diff --git a/conifer/templates/login.xhtml b/conifer/templates/login.xhtml
deleted file mode 100644 (file)
index fbde612..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?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>
index 8caf273..c5470ca 100644 (file)
@@ -23,7 +23,7 @@ app_name = 'Syrup E-Reserve System'
        <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>
        &bull; <a href="/user/prefs">Preferences</a>
        &bull; <a href="/admin/">Admin UI</a>
diff --git a/conifer/templates/my_courses.xhtml b/conifer/templates/my_courses.xhtml
new file mode 100644 (file)
index 0000000..eaf7385
--- /dev/null
@@ -0,0 +1,25 @@
+<?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>
index 29fcd40..9e178a5 100644 (file)
@@ -3,7 +3,8 @@
       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>