Commit fa5537ab by Don Mitchell

On first request for handouts, create the db record. (bug 160)

parent 48e58264
import logging
from static_replace import replace_static_urls
from xmodule.modulestore.exceptions import ItemNotFoundError
from xmodule.modulestore import Location
from xmodule.modulestore.django import modulestore
from lxml import etree
import re
from django.http import HttpResponseBadRequest, Http404
from django.http import Http404
def get_module_info(store, location, parent_location=None, rewrite_static_links=False):
......@@ -15,7 +11,9 @@ def get_module_info(store, location, parent_location=None, rewrite_static_links=
else:
module = store.get_item(location)
except ItemNotFoundError:
raise Http404
# create a new one
template_location = Location(['i4x', 'edx', 'templates', location.category, 'Empty'])
module = store.clone_item(template_location, location)
data = module.definition['data']
if rewrite_static_links:
......@@ -40,7 +38,6 @@ def get_module_info(store, location, parent_location=None, rewrite_static_links=
def set_module_info(store, location, post_data):
module = None
isNew = False
try:
if location.revision is None:
module = store.get_item(location)
......@@ -54,7 +51,6 @@ def set_module_info(store, location, post_data):
# presume that we have an 'Empty' template
template_location = Location(['i4x', 'edx', 'templates', location.category, 'Empty'])
module = store.clone_item(template_location, location)
isNew = True
if post_data.get('data') is not None:
data = post_data['data']
......
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