SHARE
TWEET

Untitled

a guest Feb 26th, 2012 21 Never
  1. import config
  2. import models
  3.  
  4. def GET(request):
  5.     return config.template_plugin.render("import.html")
  6.  
  7. def POST(request):
  8.     import_file = request.form['import_file']
  9.     if import_file.filename.strip():
  10.         content = import_file.file.read().strip()
  11.         groups = (i for i in content.split('\n\n') if i.strip())
  12.         for group in groups:
  13.             detail = group.strip().split('\n')
  14.             task = models.Task(description=detail[0].strip())
  15.             for s in datail[1:]:
  16.                 models.SubTask(description=s.strip(), task=task)
  17.         request.redirect('/task/')
  18.     else:
  19.         return "No file to upload"
RAW Paste Data
Top