course.xml includes work
This commit is contained in:
@@ -14,6 +14,14 @@ class UserProfile(models.Model):
|
||||
meta = models.TextField(blank=True) # JSON dictionary for future expansion
|
||||
courseware = models.TextField(blank=True, default='course.xml')
|
||||
|
||||
# class UserTestGroup(models.Model):
|
||||
# ''' Group used for user tests.
|
||||
# E.g. groupname = 'metacognition' and groupsection = ['A','B']
|
||||
# '''
|
||||
# groupname = models.TextField(blank=True)
|
||||
# groupsection = models.TextField(blank=True)
|
||||
# user = models.ManyToManyField(User)
|
||||
|
||||
class Registration(models.Model):
|
||||
''' Allows us to wait for e-mail before user is registered. A
|
||||
registration profile is created when the user creates an
|
||||
|
||||
@@ -3,6 +3,7 @@ import hashlib
|
||||
|
||||
from lxml import etree
|
||||
from mako.template import Template
|
||||
from mako.lookup import TemplateLookup
|
||||
|
||||
try: # This lets us do __name__ == ='__main__'
|
||||
from django.conf import settings
|
||||
@@ -88,12 +89,17 @@ def id_tag(course):
|
||||
else:
|
||||
elem.set('id', fasthash(etree.tostring(elem)))
|
||||
|
||||
template_lookup = TemplateLookup(directories = [settings.DATA_DIR],
|
||||
module_directory = settings.MAKO_MODULE_DIR)
|
||||
|
||||
def course_file(user):
|
||||
# TODO: Cache.
|
||||
filename = settings.DATA_DIR+UserProfile.objects.get(user=user).courseware
|
||||
data_template = Template(filename=filename)
|
||||
filename = UserProfile.objects.get(user=user).courseware
|
||||
data_template = template_lookup.get_template(filename)
|
||||
|
||||
tree = etree.XML(data_template.render())
|
||||
options = {'dev_content':True}
|
||||
|
||||
tree = etree.XML(data_template.render(**options))
|
||||
id_tag(tree)
|
||||
return tree
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import djcelery
|
||||
|
||||
@@ -134,10 +135,14 @@ TRACK_MAX_EVENT = 1000
|
||||
MAXLOG = 500
|
||||
|
||||
LOG_DIR = "/tmp/"
|
||||
MAKO_MODULE_DIR = None
|
||||
|
||||
# Make sure we execute correctly regardless of where we're called from
|
||||
execfile(os.path.join(BASE_DIR, "settings.py"))
|
||||
|
||||
if MAKO_MODULE_DIR == None:
|
||||
MAKO_MODULE_DIR = tempfile.mkdtemp('mako')
|
||||
|
||||
# A sample logging configuration. The only tangible logging
|
||||
# performed by this configuration is to send an email to
|
||||
# the site admins on every HTTP 500 error.
|
||||
|
||||
Reference in New Issue
Block a user