~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/util.py

ivle.webapp.testing: Add, with fake request and user.
ivle.webapp.base.test: Add! Test the JSONRESTView, using the new mocks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
177
177
            except ValueError:
178
178
                return "File"
179
179
 
180
 
def get_terms_of_service():
 
180
def send_terms_of_service(req):
181
181
    """
182
182
    Sends the Terms of Service document to the req object.
183
183
    This consults conf to find out where the TOS is located on disk, and sends
185
185
    how to create a real one.
186
186
    """
187
187
    try:
188
 
        return open(ivle.conf.tos_path).read()
 
188
        req.sendfile(ivle.conf.tos_path)
189
189
    except IOError:
190
 
        return """\
 
190
        req.write(
 
191
"""<h1>Terms of Service</h1>
191
192
<p><b>*** SAMPLE ONLY ***</b></p>
192
193
<p>This is the text of the IVLE Terms of Service.</p>
193
194
<p>The administrator should create a license file with an appropriate
205
206
just be the contents of a body element (IVLE will wrap it accordingly).</p>
206
207
<p>This will automatically be used as the license text instead of this
207
208
placeholder text.</p>
208
 
"""
 
209
""")
209
210
 
210
211
def parse_iso8601(str):
211
212
    """Parses ISO8601 string into a datetime object."""