Commit a3914cc1 by Piotr Mitros

course.xml includes work

parent 472a3996
...@@ -14,6 +14,14 @@ class UserProfile(models.Model): ...@@ -14,6 +14,14 @@ class UserProfile(models.Model):
meta = models.TextField(blank=True) # JSON dictionary for future expansion meta = models.TextField(blank=True) # JSON dictionary for future expansion
courseware = models.TextField(blank=True, default='course.xml') 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): class Registration(models.Model):
''' Allows us to wait for e-mail before user is registered. A ''' Allows us to wait for e-mail before user is registered. A
registration profile is created when the user creates an registration profile is created when the user creates an
......
...@@ -3,6 +3,7 @@ import hashlib ...@@ -3,6 +3,7 @@ import hashlib
from lxml import etree from lxml import etree
from mako.template import Template from mako.template import Template
from mako.lookup import TemplateLookup
try: # This lets us do __name__ == ='__main__' try: # This lets us do __name__ == ='__main__'
from django.conf import settings from django.conf import settings
...@@ -88,12 +89,17 @@ def id_tag(course): ...@@ -88,12 +89,17 @@ def id_tag(course):
else: else:
elem.set('id', fasthash(etree.tostring(elem))) elem.set('id', fasthash(etree.tostring(elem)))
template_lookup = TemplateLookup(directories = [settings.DATA_DIR],
module_directory = settings.MAKO_MODULE_DIR)
def course_file(user): def course_file(user):
# TODO: Cache. # TODO: Cache.
filename = settings.DATA_DIR+UserProfile.objects.get(user=user).courseware filename = UserProfile.objects.get(user=user).courseware
data_template = Template(filename=filename) 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) id_tag(tree)
return tree return tree
......
import os import os
import sys import sys
import tempfile
import djcelery import djcelery
...@@ -134,10 +135,14 @@ TRACK_MAX_EVENT = 1000 ...@@ -134,10 +135,14 @@ TRACK_MAX_EVENT = 1000
MAXLOG = 500 MAXLOG = 500
LOG_DIR = "/tmp/" LOG_DIR = "/tmp/"
MAKO_MODULE_DIR = None
# Make sure we execute correctly regardless of where we're called from # Make sure we execute correctly regardless of where we're called from
execfile(os.path.join(BASE_DIR, "settings.py")) 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 # A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to # performed by this configuration is to send an email to
# the site admins on every HTTP 500 error. # 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