Commit 53bf4324 authored by ale's avatar ale

* fixed bug #15

* converted to sqlalchemy 0.5 syntax
parent 2904bdab
......@@ -53,13 +53,12 @@ class DocsController(BaseController):
doc.parent = None
elif not doc.parent and parent_id:
doc.parent = model.Document.query.get(parent_id)
model.Session.update(doc)
else:
doc = model.Document.create(
title=title, contents=contents,
username=username, parent_id=parent_id
)
model.Session.save(doc)
model.Session.add(doc)
model.Session.commit()
redirect = 'view'
# handle attachment uploads
......
......@@ -46,8 +46,6 @@ class Document(object):
rev1 = DocumentRevision(username=username, contents=contents)
doc.revisions.append(rev1)
Session.add(rev1)
#Session.commit()
#Session.refresh(doc)
return doc
@classmethod
......@@ -87,9 +85,9 @@ class Document(object):
return out
def add_revision(self, contents, username):
rev = DocumentRevision(username=username, contents=contents)
rev = DocumentRevision(username=username, contents=contents,
document=self)
self.revisions.append(rev)
Session.save(rev)
def latest_revision(self):
return DocumentRevision.query.filter_by(document_id=self.id)\
......
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