예제 #1
0
파일: views.py 프로젝트: ryansb/samnotes
def post_note(request):
    work = DBSession.query(Note).filter(Note.id == request.matchdict['nid']).first()
    if request.json.get('text', None):
        work.text = request.json['text']
    work.modified_at = datetime.now()
    DBSession.add(work)
    DBSession.commit()

    return work.to_dict()
예제 #2
0
 def put(self):
     DBSession.add(self)
     DBSession.flush()
예제 #3
0
 def all(cls):
     return DBSession.query(cls).all()
예제 #4
0
 def get_by_username(cls, username):
     return DBSession.query(cls).filter(cls.username == username).first()
예제 #5
0
파일: views.py 프로젝트: ryansb/samnotes
def del_note(request):
    work = DBSession.query(Note).filter(Note.id == request.matchdict['nid']).first()
    DBSession.delete(work)
    DBSession.commit()
    return "Success"
예제 #6
0
파일: views.py 프로젝트: ryansb/samnotes
def put_note(request):
    work = Note.from_dict(request.json)
    DBSession.add(work)
    DBSession.commit()
    return work.to_dict()
예제 #7
0
파일: views.py 프로젝트: ryansb/samnotes
def get_note(request):
    return {
        'notes': [
            n.to_dict() for n in DBSession.query(Note).all()
        ]
    }