From: gfawcett Date: Tue, 18 Nov 2008 20:58:30 +0000 (+0000) Subject: template re-org; removed need for local_settings.py; added News to model. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=13be435c68f2832b73a8395ff95007dc8f48fc51;p=Syrup.git template re-org; removed need for local_settings.py; added News to model. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@22 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/conifer/local_settings.py.in b/conifer/local_settings.py.in deleted file mode 100644 index 7d7fd74..0000000 --- a/conifer/local_settings.py.in +++ /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/' diff --git a/conifer/settings.py b/conifer/settings.py index ee99c96..76461a1 100644 --- a/conifer/settings.py +++ b/conifer/settings.py @@ -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). diff --git a/conifer/static/main.css b/conifer/static/main.css index a9c7238..c26a6aa 100644 --- a/conifer/static/main.css +++ b/conifer/static/main.css @@ -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; } diff --git a/conifer/syrup/admin.py b/conifer/syrup/admin.py index 1b279c8..c24d19f 100644 --- a/conifer/syrup/admin.py +++ b/conifer/syrup/admin.py @@ -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) diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index 0a97833..3cdaaff 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -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') diff --git a/conifer/syrup/urls.py b/conifer/syrup/urls.py index d9c840f..0e59006 100644 --- a/conifer/syrup/urls.py +++ b/conifer/syrup/urls.py @@ -1,6 +1,7 @@ from django.conf.urls.defaults import * urlpatterns = patterns('conifer.syrup.views', - (r'^$', 'index'), - (r'^course/(?P\d+)/$', 'course_index'), + (r'^$', 'welcome'), + (r'^course/$', 'my_courses'), + (r'^course/(?P\d+)/$', 'course_detail'), ) diff --git a/conifer/syrup/views.py b/conifer/syrup/views.py index ad04cd4..12d89f8 100644 --- a/conifer/syrup/views.py +++ b/conifer/syrup/views.py @@ -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 index 0000000..74c7538 --- /dev/null +++ b/conifer/templates/auth/login.xhtml @@ -0,0 +1,31 @@ + + + + + ${title} + + + +

Please log in.

+
+ + + + + + + + + + +
User ID:
Password:
+

+
+ + diff --git a/conifer/templates/course.xhtml b/conifer/templates/course.xhtml deleted file mode 100644 index f76a969..0000000 --- a/conifer/templates/course.xhtml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - ${title} - - -

${title}

- - diff --git a/conifer/templates/course_detail.xhtml b/conifer/templates/course_detail.xhtml new file mode 100644 index 0000000..f76a969 --- /dev/null +++ b/conifer/templates/course_detail.xhtml @@ -0,0 +1,14 @@ + + + + + ${title} + + +

${title}

+ + diff --git a/conifer/templates/index.xhtml b/conifer/templates/index.xhtml deleted file mode 100644 index 6733c19..0000000 --- a/conifer/templates/index.xhtml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - ${title} - - -

My Courses

- -

You are not part of any courses at this time.

-

- ${course.term}: ${course.code}: ${course.title} -

-
- - diff --git a/conifer/templates/login.xhtml b/conifer/templates/login.xhtml deleted file mode 100644 index fbde612..0000000 --- a/conifer/templates/login.xhtml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - ${title} - - - -

Please log in.

-
- - - - - - - - - - -
User ID:
Password:
-

-
- - diff --git a/conifer/templates/master.xhtml b/conifer/templates/master.xhtml index 8caf273..c5470ca 100644 --- a/conifer/templates/master.xhtml +++ b/conifer/templates/master.xhtml @@ -23,7 +23,7 @@ app_name = 'Syrup E-Reserve System'