Commit a3914cc1 by Piotr Mitros

course.xml includes work

parent 472a3996
......@@ -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)
options = {'dev_content':True}
tree = etree.XML(data_template.render())
tree = etree.XML(data_template.render(**options))
id_tag(tree)
return tree
......
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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment